]> arthur.barton.de Git - bup.git/blobdiff - cmd/drecurse-cmd.py
ssh: simplify the code
[bup.git] / cmd / drecurse-cmd.py
index 611bfdbb3e89bdc3d93d9900fc3b38fc5cb6343d..3fa155fdd27548a748ac8890a9083cdd6045a4a6 100755 (executable)
@@ -5,9 +5,15 @@ exec "$bup_python" "$0" ${1+"$@"}
 """
 # end of bup preamble
 
+from __future__ import absolute_import, print_function
 from os.path import relpath
+import sys
+
 from bup import options, drecurse
-from bup.helpers import *
+from bup.compat import argv_bytes
+from bup.helpers import log, parse_excludes, parse_rx_excludes, saved_errors
+from bup.io import byte_stream
+
 
 optspec = """
 bup drecurse <path>
@@ -26,9 +32,9 @@ o = options.Options(optspec)
 if len(extra) != 1:
     o.fatal("exactly one filename expected")
 
-drecurse_top = extra[0]
+drecurse_top = argv_bytes(extra[0])
 excluded_paths = parse_excludes(flags, o.fatal)
-if not drecurse_top.startswith('/'):
+if not drecurse_top.startswith(b'/'):
     excluded_paths = [relpath(x) for x in excluded_paths]
 exclude_rxs = parse_rx_excludes(flags, o.fatal)
 it = drecurse.recursive_dirlist([drecurse_top], opt.xdev,
@@ -45,8 +51,10 @@ else:
         for i in it:
             pass
     else:
+        sys.stdout.flush()
+        out = byte_stream(sys.stdout)
         for (name,st) in it:
-            print name
+            out.write(name + b'\n')
 
 if saved_errors:
     log('WARNING: %d errors encountered.\n' % len(saved_errors))