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)
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)
return self.pred(fname)
def __len__(self):
return len(self.files)
- def extend(self, files):
- self.files.extend(files)
+ def collect(self, directory):
+ for dirpath, dirnames, filenames in os.walk(directory):
+ try: dirnames.remove('.svn')
+ except ValueError: pass
+ self.files.extend([ os.path.join(dirpath, f)
+ for f in filenames if self.pred(f) ])
def lines(self):
try:
return self._lines
test_tests = Collection('test/ tests', pred=is_python)
sources = Collection('sources', pred=is_source)
-def t(arg, dirname, names):
- try: names.remove('.svn')
- except ValueError: pass
- names = list(filter(arg, names))
- arg.extend([os.path.join(dirname, n) for n in names])
-
-os.path.walk('src', t, src_Tests_py_tests)
-os.path.walk('src', t, src_test_tests)
-os.path.walk('test', t, test_tests)
-os.path.walk('src/engine', t, sources)
-os.path.walk('src/script', t, sources)
+src_Tests_py_tests.collect('src')
+src_test_tests.collect('src')
+test_tests.collect('test')
+sources.collect('src/engine')
+sources.collect('src/script')
src_tests = Collection('src/ tests', src_Tests_py_tests.files
+ src_test_tests.files)
for t, s in zip(tlist, slist):
open(t, "wb").write(open(s, "rb").read())
-def find_class_files(arg, dirname, names):
- class_files = filter(lambda n: n[-6:] == '.class', names)
- paths = map(lambda n: os.path.join(dirname, n), class_files)
- arg.extend(paths)
-
def JarCom(target, source, env):
target = str(target[0])
class_files = []
for src in map(str, source):
- os.path.walk(src, find_class_files, class_files)
+ for dirpath, dirnames, filenames in os.walk(src):
+ class_files.extend([ os.path.join(dirpath, f)
+ for f in filenames if f.endswith('.class') ])
f = open(target, "wb")
for cf in class_files:
f.write(open(cf, "rb").read())