python/retrace: Support gziped traces.
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Thu, 21 Aug 2008 17:45:43 +0000 (18:45 +0100)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Thu, 21 Aug 2008 17:46:04 +0000 (18:46 +0100)
src/gallium/state_trackers/python/retrace/interpreter.py
src/gallium/state_trackers/python/retrace/parser.py

index 7502c096b66d54c10aeca0c6f409671373a26823..f596a54d10242a0dc9bb833b19e406b87cbe948b 100755 (executable)
@@ -471,7 +471,12 @@ class Interpreter:
 
 def main():
     for arg in sys.argv[1:]:
-        parser = TraceParser(open(arg, 'rt'))
+        if arg.endswith('.gz'):
+            import gzip
+            stream = gzip.GzipFile(arg, 'rt')
+        else:
+            stream = open(arg, 'rt')
+        parser = TraceParser(stream)
         trace = parser.parse()
         interpreter = Interpreter()
         interpreter.interpret(trace)
index d02fd7f741f3cc4919b87bbabca912afd4010451..2ee4d3068db7247665c5826b24368713385a79bf 100755 (executable)
@@ -322,9 +322,15 @@ class TraceParser(XmlParser):
 
 def main():
     for arg in sys.argv[1:]:
-        parser = TraceParser(open(arg, 'rt'))
+        if arg.endswith('.gz'):
+            import gzip
+            stream = gzip.GzipFile(arg, 'rt')
+        else:
+            stream = open(arg, 'rt')
+        parser = TraceParser(stream)
         trace = parser.parse()
-        print trace
+        for call in trace.calls:
+            print call
 
 
 if __name__ == '__main__':