]> arthur.barton.de Git - bup.git/blob - cmd-drecurse.py
Speed up cmd-drecurse by 40%.
[bup.git] / cmd-drecurse.py
1 #!/usr/bin/env python
2 import options, drecurse
3 from helpers import *
4
5 optspec = """
6 bup drecurse <path>
7 --
8 x,xdev,one-file-system   don't cross filesystem boundaries
9 q,quiet  don't actually print filenames
10 profile  run under the python profiler
11 """
12 o = options.Options('bup drecurse', optspec)
13 (opt, flags, extra) = o.parse(sys.argv[1:])
14
15 if len(extra) != 1:
16     log("drecurse: exactly one filename expected\n")
17     o.usage()
18
19 it = drecurse.recursive_dirlist(extra, opt.xdev)
20 if opt.profile:
21     import cProfile
22     def do_it():
23         for i in it:
24             pass
25     cProfile.run('do_it()')
26 else:
27     if opt.quiet:
28         for i in it:
29             pass
30     else:
31         for (name,st) in it:
32             print name
33
34 if saved_errors:
35     log('WARNING: %d errors encountered.\n' % len(saved_errors))
36     sys.exit(1)