From: José Fonseca Date: Thu, 21 Aug 2008 17:45:43 +0000 (+0100) Subject: python/retrace: Support gziped traces. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=10624065b0dc631164d786b2c39f35655e55eadf;p=mesa.git python/retrace: Support gziped traces. --- diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 7502c096b66..f596a54d102 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -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) diff --git a/src/gallium/state_trackers/python/retrace/parser.py b/src/gallium/state_trackers/python/retrace/parser.py index d02fd7f741f..2ee4d3068db 100755 --- a/src/gallium/state_trackers/python/retrace/parser.py +++ b/src/gallium/state_trackers/python/retrace/parser.py @@ -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__':