summaryrefslogtreecommitdiff
path: root/lab/parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-09-08 08:17:32 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-09-08 08:17:32 -0400
commite7f51a120a9b71a4a2a00ae5094857abb5bbf26a (patch)
tree164f622bd4813968b143c78cbacff36ca41cf0fb /lab/parser.py
parent2e509c4d8465379843d768da6db48fad39f8b131 (diff)
downloadpython-coveragepy-git-e7f51a120a9b71a4a2a00ae5094857abb5bbf26a.tar.gz
Make this helper a little easier to use
Diffstat (limited to 'lab/parser.py')
-rw-r--r--lab/parser.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/lab/parser.py b/lab/parser.py
index 67c41e80..09d59f37 100644
--- a/lab/parser.py
+++ b/lab/parser.py
@@ -9,8 +9,8 @@ from coverage.misc import CoverageException
from coverage.parser import ByteParser, CodeParser
-class AdHocMain(object):
- """An ad-hoc main for code parsing experiments."""
+class ParserMain(object):
+ """A main for code parsing experiments."""
def main(self, args):
"""A main function for trying the code from the command line."""
@@ -45,11 +45,13 @@ class AdHocMain(object):
root = "."
for root, _, _ in os.walk(root):
for f in glob.glob(root + "/*.py"):
- self.adhoc_one_file(options, f)
+ self.one_file(options, f)
+ elif not args:
+ parser.print_help()
else:
- self.adhoc_one_file(options, args[0])
+ self.one_file(options, args[0])
- def adhoc_one_file(self, options, filename):
+ def one_file(self, options, filename):
"""Process just one file."""
if options.dis or options.chunks:
@@ -173,5 +175,5 @@ class AdHocMain(object):
return arc_width, arc_chars
if __name__ == '__main__':
- AdHocMain().main(sys.argv[1:])
+ ParserMain().main(sys.argv[1:])