summaryrefslogtreecommitdiff
path: root/pyflakes/scripts
diff options
context:
space:
mode:
authorJonathan Lange <jml@canonical.com>2012-07-08 14:21:01 +0100
committerJonathan Lange <jml@canonical.com>2012-07-08 14:21:01 +0100
commitee58bb55142b514dab62dc201c80056331f64405 (patch)
tree1ce4e8a234713cb6a67acb420fabe6e042161ca4 /pyflakes/scripts
parent5b3224fe27aa4157297277f3fe352a4d7b2d5af4 (diff)
downloadpyflakes-ee58bb55142b514dab62dc201c80056331f64405.tar.gz
Split out the bit that checks recursively.
Diffstat (limited to 'pyflakes/scripts')
-rw-r--r--pyflakes/scripts/pyflakes.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/pyflakes/scripts/pyflakes.py b/pyflakes/scripts/pyflakes.py
index ad9124c..3d74052 100644
--- a/pyflakes/scripts/pyflakes.py
+++ b/pyflakes/scripts/pyflakes.py
@@ -156,14 +156,29 @@ def iterSourceCode(paths):
-def main():
+def checkRecursive(paths, reporter):
+ """
+ Recursively check all source files in C{paths}.
+
+ @param paths: A list of paths to Python source files and directories
+ containing Python source files.
+ @param reporter: A L{Reporter} where all of the warnings and errors
+ will be reported to.
+ @return: The number of warnings found.
+ """
warnings = 0
+ for sourcePath in iterSourceCode(paths):
+ warnings += checkPath(sourcePath, reporter)
+ return warnings
+
+
+
+def main():
args = sys.argv[1:]
reporter = Reporter(None, sys.stderr)
if args:
- for sourcePath in iterSourceCode(args):
- warnings += checkPath(sourcePath, reporter)
+ warnings = checkRecursive(args, reporter)
else:
- warnings += check(sys.stdin.read(), '<stdin>')
+ warnings = check(sys.stdin.read(), '<stdin>')
raise SystemExit(warnings > 0)