summaryrefslogtreecommitdiff
path: root/bin/linecount.py
diff options
context:
space:
mode:
authorLuca Falavigna <dktrkranz@debian.org>2010-06-15 14:28:22 +0000
committerLuca Falavigna <dktrkranz@debian.org>2010-06-15 14:28:22 +0000
commit738149c9bfb9965d013d01ef99f9bb1c2819e7e8 (patch)
tree0397d9bf3b12c903dc73419585df231397ff343c /bin/linecount.py
parente7885e3af440eaef38a9301fd92a105afc8ddebb (diff)
Imported Upstream version 2.0.0upstream/2.0.0
Diffstat (limited to 'bin/linecount.py')
-rw-r--r--bin/linecount.py29
1 files changed, 13 insertions, 16 deletions
diff --git a/bin/linecount.py b/bin/linecount.py
index 23ac7c9..7d6e457 100644
--- a/bin/linecount.py
+++ b/bin/linecount.py
@@ -21,12 +21,11 @@
# in each category, the number of non-blank lines, and the number of
# non-comment lines. The last figure (non-comment) lines is the most
# interesting one for most purposes.
-#
+from __future__ import division
-__revision__ = "bin/linecount.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "bin/linecount.py 5023 2010/06/14 22:05:46 scons"
import os.path
-import string
fmt = "%-16s %5s %7s %9s %11s %11s"
@@ -43,8 +42,12 @@ class Collection(object):
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
@@ -82,17 +85,11 @@ src_test_tests = Collection('src/ test_*.py', pred=is_test_)
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 = filter(arg, names)
- arg.extend(map(lambda n, d=dirname: os.path.join(d, n), 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)