diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2013-01-12 20:17:04 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-01-12 20:17:04 -0500 |
commit | 642292108bb163862c20627e4c2067b5b58f100c (patch) | |
tree | 0c7380b497b499f41fa7fd20bcf9e84c23cf75d2 /lab/show_pyc.py | |
parent | b633db4938105d286afa3eae6f1aff81d3a6d569 (diff) | |
download | python-coveragepy-git-642292108bb163862c20627e4c2067b5b58f100c.tar.gz |
Improvements to bytecode tools.
Diffstat (limited to 'lab/show_pyc.py')
-rw-r--r-- | lab/show_pyc.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lab/show_pyc.py b/lab/show_pyc.py index a0834e88..7dacc2b0 100644 --- a/lab/show_pyc.py +++ b/lab/show_pyc.py @@ -12,6 +12,9 @@ def show_pyc_file(fname): def show_py_file(fname):
text = open(fname).read().replace('\r\n', '\n')
+ show_py_text(text, fname=fname)
+
+def show_py_text(text, fname="<string>"):
code = compile(text, fname, "exec")
show_code(code)
@@ -55,10 +58,13 @@ def show_file(fname): show_py_file(fname)
else:
print "Odd file:", fname
-
+
def main(args):
- for a in args:
- show_file(a)
-
+ if args[0] == '-c':
+ show_py_text(" ".join(args[1:]).replace(";", "\n"))
+ else:
+ for a in args:
+ show_file(a)
+
if __name__ == '__main__':
main(sys.argv[1:])
|