X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=t%2Fhardlink-sets;h=bcb3cd0ebcae5c5e0a1ec4b10e614f53f189c2d0;hb=ea0cb087050dc86bae886c0b2605b83aa819b7d3;hp=9dffe1410060be110e55a11a77b122ad190863bc;hpb=7e0fcaa5b28eb1aa022a59e5056679e7854070b9;p=bup.git diff --git a/t/hardlink-sets b/t/hardlink-sets index 9dffe14..bcb3cd0 100755 --- a/t/hardlink-sets +++ b/t/hardlink-sets @@ -5,14 +5,19 @@ exec "$bup_python" "$0" ${1+"$@"} """ # end of bup preamble +from __future__ import absolute_import, print_function import os, stat, sys +from bup.compat import argv_bytes +from bup.io import byte_stream + + # Print the full paths of all the files in each hardlink set # underneath one of the paths. Separate sets with a blank line, sort # the paths within each set, and sort the sets by their first path. def usage(): - print >> sys.stderr, "Usage: hardlink-sets " + print("Usage: hardlink-sets ", file=sys.stderr) if len(sys.argv) < 2: usage() @@ -21,15 +26,18 @@ if len(sys.argv) < 2: def on_walk_error(e): raise e +sys.stdout.flush() +out = byte_stream(sys.stdout) + hardlink_set = {} -for p in sys.argv[1:]: +for p in (argv_bytes(x) for x in sys.argv[1:]): for root, dirs, files in os.walk(p, onerror = on_walk_error): for filename in files: full_path = os.path.join(root, filename) st = os.lstat(full_path) if not stat.S_ISDIR(st.st_mode): - node = '%s:%s' % (st.st_dev, st.st_ino) + node = b'%d:%d' % (st.st_dev, st.st_ino) link_paths = hardlink_set.get(node) if link_paths: link_paths.append(full_path) @@ -46,8 +54,8 @@ for link_paths in sorted(hardlink_set.values(), key = lambda x : x[0]): if first_set: first_set = False else: - print + out.write(b'\n') for p in sorted(link_paths): - print p + out.write(p + b'\n') sys.exit(0)