summaryrefslogtreecommitdiff
path: root/lab/parse_all.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-02-13 11:10:17 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-02-13 11:10:17 -0500
commit4ed238af81d508941057ad13d3e8a7d90bdd31eb (patch)
treebf823b348facbaab74c3a499e2e672b87d72ff24 /lab/parse_all.py
parent80e701b43f04f6ecca44a11f8c24d8ddfb74d662 (diff)
downloadpython-coveragepy-4ed238af81d508941057ad13d3e8a7d90bdd31eb.tar.gz
Helper to parse a lot of files to test the parser
Diffstat (limited to 'lab/parse_all.py')
-rw-r--r--lab/parse_all.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/lab/parse_all.py b/lab/parse_all.py
new file mode 100644
index 0000000..3760683
--- /dev/null
+++ b/lab/parse_all.py
@@ -0,0 +1,19 @@
+"""Parse every Python file in a tree."""
+
+import os
+import sys
+
+from coverage.misc import CoverageException
+from coverage.parser import PythonParser
+
+for root, dirnames, filenames in os.walk(sys.argv[1]):
+ for filename in filenames:
+ if filename.endswith(".py"):
+ filename = os.path.join(root, filename)
+ print(":: {}".format(filename))
+ try:
+ par = PythonParser(filename=filename)
+ par.parse_source()
+ par.arcs()
+ except Exception as exc:
+ print(" ** {}".format(exc))