diff options
author | Kim Grasman <kim.grasman@gmail.com> | 2017-05-01 15:49:28 +0200 |
---|---|---|
committer | Kim Grasman <kim.grasman@gmail.com> | 2017-07-16 11:21:35 +0200 |
commit | 98474541972286c7784fa30b2b26eceeed46ce3b (patch) | |
tree | d7752ab98261847618772f3f8d2622031b01040c | |
parent | 953970c487b004050d44925bfcc5133be9fa0d7f (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-x | scrub-logs.py | 16 |
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()) |