summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2009-12-08 12:19:38 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2009-12-08 12:19:38 +0000
commit62f3671be8e15196345553501c9b25a45ea852c4 (patch)
tree32e6611a2a1462e2c63186e65b8a86955038a733
parentb573d2fc9c63115c76ba83c487ffbaa27bb69699 (diff)
Make log-strip.py process its arguments
-rwxr-xr-xtools/log-strip.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/log-strip.py b/tools/log-strip.py
index c8e6dc54e..3c8ca938f 100755
--- a/tools/log-strip.py
+++ b/tools/log-strip.py
@@ -4,6 +4,8 @@ Strip varying data (PIDs, pointer values) from Gabble logs to make them
easier to compare.
"""
+from __future__ import with_statement
+
import re
import sys
@@ -16,10 +18,18 @@ def sanitise(line):
re.sub("('?<[^ ]+ [^>]*id=)[\"'][^\"']+[\"']",
lambda m: m.group(1) + '"?????"', line))))))
-def main():
- for line in sys.stdin:
+def process(file):
+ for line in file:
print sanitise(line),
+def main():
+ if len(sys.argv) > 1:
+ for fn in sys.argv[1:]:
+ with open(fn) as f:
+ process(f)
+ else:
+ process(sys.stdin)
+
if __name__ == '__main__':
main()