diff options
Diffstat (limited to 'bin/import-test.py')
-rw-r--r-- | bin/import-test.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/bin/import-test.py b/bin/import-test.py index 18f7428..906bab0 100644 --- a/bin/import-test.py +++ b/bin/import-test.py @@ -25,7 +25,7 @@ # """ triple-quotes will need to have their contents edited by hand. # -__revision__ = "bin/import-test.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "bin/import-test.py 5023 2010/06/14 22:05:46 scons" import os.path import sys @@ -35,16 +35,13 @@ directory = sys.argv[1] Top = None TopPath = None -class Dir: +class Dir(object): def __init__(self, path): self.path = path self.entries = {} def call_for_each_entry(self, func): - entries = self.entries - names = entries.keys() - names.sort() - for name in names: - func(name, entries[name]) + for name in sorted(self.entries.keys()): + func(name, self.entries[name]) def lookup(dirname): global Top, TopPath @@ -60,11 +57,6 @@ def lookup(dirname): node = t.entries[dirs[-1]] = Dir(dirs) return node -def make_nodes(arg, dirname, fnames): - dir = lookup(dirname) - for f in fnames: - dir.entries[f] = None - def collect_dirs(l, dir): if dir.path: l.append(dir.path) @@ -78,7 +70,7 @@ def print_files(dir): if not d: l = dir.path + [n] sys.stdout.write('\ntest.write(%s, """\\\n' % l) - p = os.path.join(*([directory] + l)) + p = os.path.join(directory, *l) sys.stdout.write(open(p, 'r').read()) sys.stdout.write('""")\n') dir.call_for_each_entry(print_a_file) @@ -88,7 +80,10 @@ def print_files(dir): print_files(d) dir.call_for_each_entry(recurse) -os.path.walk(directory, make_nodes, None) +for dirpath, dirnames, filenames in os.walk(directory): + dir = lookup(dirpath) + for f in fnames: + dir.entries[f] = None subdir_list = [] collect_dirs(subdir_list, Top) |