Mercurial > hg > config
comparison python/randomize.py @ 249:12299cbc45ee
update this awful program
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 01 Dec 2012 17:49:12 -0800 |
parents | f3ab51c79813 |
children | 08da6a1bb4c9 |
comparison
equal
deleted
inserted
replaced
248:c7dd4631b526 | 249:12299cbc45ee |
---|---|
5 import subprocess | 5 import subprocess |
6 import sys | 6 import sys |
7 | 7 |
8 from optparse import OptionParser | 8 from optparse import OptionParser |
9 | 9 |
10 """randomize a bunch of files""" | |
11 | |
10 if __name__ == '__main__': | 12 if __name__ == '__main__': |
11 parser = OptionParser() | 13 usage = '%prog [options] file_or_directory <...>' |
14 parser = OptionParser(usage=usage, description=__doc__) | |
12 parser.add_option("-e", "--exec", dest="callable", | 15 parser.add_option("-e", "--exec", dest="callable", |
13 help="program to execute") | 16 help="program to execute for each file") |
14 (options, argv) = parser.parse_args() | 17 options, argv = parser.parse_args() |
18 if not argv: | |
19 argv = ['.'] | |
15 args = [] | 20 args = [] |
16 for i in argv: | 21 for i in argv: |
17 if os.path.isdir(i): | 22 if os.path.isdir(i): |
18 for root, dirs, files in os.walk(i): | 23 for root, dirs, files in os.walk(i): |
19 args.extend([os.path.join(root, f) for f in files]) | 24 args.extend([os.path.join(root, f) for f in files]) |