[py-svn] r18779 - py/dist/py/misc/cmdline
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed Oct 19 23:02:47 CEST 2005
Author: cfbolz
Date: Wed Oct 19 23:02:46 2005
New Revision: 18779
Modified:
py/dist/py/misc/cmdline/countloc.py
Log:
refactor countloc a bit to be able to use it programatically
Modified: py/dist/py/misc/cmdline/countloc.py
==============================================================================
--- py/dist/py/misc/cmdline/countloc.py (original)
+++ py/dist/py/misc/cmdline/countloc.py Wed Oct 19 23:02:46 2005
@@ -48,13 +48,10 @@
numfiles += 1
return numfiles
-def countloc():
- counter = FileCounter()
- args = py.std.sys.argv[1:]
- if not args:
- args = ['.']
- locations = [py.path.local(x) for x in args]
-
+def get_loccount(locations=None):
+ if locations is None:
+ localtions = [py.path.local()]
+ counter = FileCounter()
for loc in locations:
counter.addrecursive(loc, '*.py', rec=nodot)
@@ -67,8 +64,15 @@
numtestfiles = counter.getnumfiles(istestfile)
numtestlines = counter.getnumlines(istestfile)
- #for x,y in counter.counts.items():
- # print "%3d %30s" % (y,x)
+ return counter, numfiles, numlines, numtestfiles, numtestlines
+
+def countloc():
+ args = py.std.sys.argv[1:]
+ if not args:
+ args = ['.']
+ locations = [py.path.local(x) for x in args]
+ (counter, numfiles, numlines, numtestfiles,
+ numtestlines) = get_loccount(locations)
items = counter.file2numlines.items()
items.sort(lambda x,y: cmp(x[1], y[1]))
More information about the pytest-commit
mailing list