diff options
author | Rob Austein <sra@hactrn.net> | 2013-02-04 05:31:03 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2013-02-04 05:31:03 +0000 |
commit | f6902e5ab90e8927b01dbb102270e7bf8386cefa (patch) | |
tree | 77485fbb38d0af4d4f133660a02bb43b02539551 /buildtools/wrap-tree.py | |
parent | cb3c0c95b314dcc3f4c8a18f095ab8828833466b (diff) |
Allow naming tree(s) on command line.
svn path=/branches/tk377/; revision=5024
Diffstat (limited to 'buildtools/wrap-tree.py')
-rw-r--r-- | buildtools/wrap-tree.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/buildtools/wrap-tree.py b/buildtools/wrap-tree.py index 5aa1c8bc..2123b79b 100644 --- a/buildtools/wrap-tree.py +++ b/buildtools/wrap-tree.py @@ -26,14 +26,17 @@ import sys result = {} -for root, dirs, files in os.walk("."): - for dn in dirs: - dn = os.path.relpath(os.path.join(root, dn)) - result[dn] = None - for fn in files: - fn = os.path.relpath(os.path.join(root, fn)) - with open(fn, "r") as f: - result[fn] = f.read() +for root in sys.argv[1:] or ["."]: + if root != ".": + result[root] = None + for dirpath, dirs, files in os.walk(root): + for dn in dirs: + dn = os.path.relpath(os.path.join(dirpath, dn)) + result[dn] = None + for fn in files: + fn = os.path.relpath(os.path.join(dirpath, fn)) + with open(fn, "r") as f: + result[fn] = f.read() sys.stdout.write("# Automatically generated. Hack if you like, but beware of overwriting.\n\nimport os\n") |