]> git.cworth.org Git - apitrace/commitdiff
Handle compressed XML.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 13 Apr 2009 12:38:50 +0000 (13:38 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 13 Apr 2009 12:38:50 +0000 (13:38 +0100)
xml2txt.py

index f9fde2e77b3da8d7492d91cbc16aa2535fd2dbc5..8b40a55bf081870a6fd2a704155f7232e8bf7c27 100755 (executable)
@@ -322,7 +322,15 @@ def main():
     args = sys.argv[1:]
     if args:
         for arg in args:
-            parser = TraceParser(open(arg, 'rt'), formatter)
+            if arg.endswith('.gz'):
+                from gzip import GzipFile
+                stream = GzipFile(arg, 'rt')
+            elif arg.endswith('.bz2'):
+                from bz2 import BZ2File
+                stream = BZ2File(arg, 'rt')
+            else:
+                stream = open(arg, 'rt')
+            parser = TraceParser(stream, formatter)
             parser.parse()
     else:
             parser = TraceParser(sys.stdin, formatter)