def write_manifest(backend, name, entry_generator): """ @param backend A storage backend (dedicated to manifests) @type name A string. @param name Name of manifest; must not contain dots. @param entry_generator Backup entry generator producting all entries, in order, for inclusion in the manifest. """ assert "." not in name, "manifest names cannot contain dots" mf_lines = ["shastity", "version 1", "end"] for (path, metadata, hashes) in entry_generator: md = metadata.to_string() pth = spencode.spencode(path) rest = " ".join(["%s,%s" % (algo, hex) for (algo, hex) in hashes]) mf_lines.append("%s | %s | %s" % (md, pth, rest)) backend.put(name, "\n".join(mf_lines))
def write_manifest(backend, name, entry_generator): """ @param backend A storage backend (dedicated to manifests) @type name A string. @param name Name of manifest; must not contain dots. @param entry_generator Backup entry generator producting all entries, in order, for inclusion in the manifest. """ assert '.' not in name, 'manifest names cannot contain dots' mf_lines = ['shastity', 'version 1', 'end'] for (path, metadata, hashes) in entry_generator: md = metadata.to_string() pth = spencode.spencode(path) rest = ' '.join(['%s,%s' % (algo, hex) for (algo, hex) in hashes]) mf_lines.append('%s | %s | %s' % (md, pth, rest)) backend.put(name, '\n'.join(mf_lines))
def to_comparable(entry): path, md, algos = entry return (path, md.to_string(), algos)