X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=cmd%2Fdrecurse-cmd.py;h=3fa155fdd27548a748ac8890a9083cdd6045a4a6;hb=57aaebfd07e7f35aed2ebd44191669b1d9db49df;hp=e52805549c5a32c5b0be89b1af902d46202642f6;hpb=e61643be081b242015dbd315e65fa9c922dde094;p=bup.git diff --git a/cmd/drecurse-cmd.py b/cmd/drecurse-cmd.py index e528055..3fa155f 100755 --- a/cmd/drecurse-cmd.py +++ b/cmd/drecurse-cmd.py @@ -1,8 +1,19 @@ -#!/usr/bin/env python +#!/bin/sh +"""": # -*-python-*- +bup_python="$(dirname "$0")/bup-python" || exit $? +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 @@ -10,6 +21,8 @@ bup drecurse x,xdev,one-file-system don't cross filesystem boundaries exclude= a path to exclude from the backup (can be used more than once) exclude-from= a file that contains exclude paths (can be used more than once) +exclude-rx= skip paths matching the unanchored regex (may be repeated) +exclude-rx-from= skip --exclude-rx patterns in file (may be repeated) q,quiet don't actually print filenames profile run under the python profiler """ @@ -19,12 +32,14 @@ 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, - excluded_paths=excluded_paths) + excluded_paths=excluded_paths, + exclude_rxs=exclude_rxs) if opt.profile: import cProfile def do_it(): @@ -36,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))