def _verify_archive(catalog, manifest, flavor=None, check_shas=True):

    if not check_shas:
        yield Message.warn('Skipping SHA digest verification for archive members.')

    archive_name = catalog.path_helper.archive_name(manifest.bundle_name, manifest.version, flavor=flavor)
    all_files = manifest.get_all_files(flavor=flavor)

    with catalog._read_archive(manifest.bundle_name, manifest.version, flavor=flavor) as fileobj:

        tar = tarfile.open(fileobj=fileobj)

        # Note: getmembers and getnames return objects in the same order
        members = tar.getmembers()
        member_names = tar.getnames()

        found_error = False

        for file in all_files:
            sha = manifest.sha_for_file(file)
            format, info = manifest.get_format_info_for_file(file, preferred_formats=defaults['catalog_preferred_formats'])
            target_member_name = helpers.append_file_extension_for_format(sha, format)
            if target_member_name not in member_names:
                found_error = True
                yield Message.error((target_member_name, helpers.make_bundle_descriptor(manifest.bundle_name, manifest.version, flavor=flavor)) % 'File \'%s\' not found in %s.')
            else:
                member = members[member_names.index(target_member_name)]
                if check_shas:
                    f = tar.extractfile(member)
                    b = f.read()
                    f.close()
                    if format == Formats.GZ:
                        b = utils.gunzip_bytes(b)
                    digest = hashlib.sha1(b).hexdigest()
                    if digest != sha:
                        found_error = True
                        yield Message.error('File \'%s\' digest does not match: %s.' % (target_member_name, digest))
                else:
                    # check length only
                    if info['size'] != member.size:
                        found_error = True
                        yield Message.error('File \'%s\' has size %d, expected %d.' % (target_member_name, info['size'], member.size))

        tar.close()

    if not found_error:
        yield Message.info('Archive %s OK' % (archive_name))
dataset/ETHPy150Open mindsnacks/Zinc/src/zinc/client.py/_verify_archive/swapped operands of `%`