summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Grasman <kim.grasman@gmail.com>2017-05-01 15:49:28 +0200
committerKim Gräsman <kim.grasman@gmail.com>2017-05-06 16:41:56 +0200
commitc452de6bc9965bf35fd16767e8291afb14eb8a9c (patch)
tree261a58d2e4ad51ae63c0d02764030a9e9d3b66c9
parentf85a15bcaeb1881e83f4d550b3c25dea1082c5ad (diff)
Let scrub-logs accept input from stdin
Use the fileinput module to take input from stdin or a named file. This enables: $ include-what-you-use -Xiwyu -v7 file.cc 2>&1 | ./scrub-logs.py which is very useful for comparing execution flows.
-rwxr-xr-xscrub-logs.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/scrub-logs.py b/scrub-logs.py
index 1abe4ce..d314862 100755
--- a/scrub-logs.py
+++ b/scrub-logs.py
@@ -18,6 +18,7 @@ values and path prefixes from ast-dump output, so they can be diffed directly.
import re
import sys
+import fileinput
def strip_path_prefix(line):
@@ -30,16 +31,15 @@ def strip_addrs(line):
return line
-def main(args):
- with open(args[1]) as fd:
- for line in fd:
- line = line.strip()
- line = strip_addrs(line)
- line = strip_path_prefix(line)
- print(line)
+def main():
+ for line in fileinput.input():
+ line = line.strip()
+ line = strip_addrs(line)
+ line = strip_path_prefix(line)
+ print(line)
return 0
if __name__ == '__main__':
- sys.exit(main(sys.argv))
+ sys.exit(main())