From: José Fonseca Date: Mon, 13 Apr 2009 12:38:50 +0000 (+0100) Subject: Handle compressed XML. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=745d1cb6566a58f0d00af593480f0efecb6194c7;p=apitrace Handle compressed XML. --- diff --git a/xml2txt.py b/xml2txt.py index f9fde2e..8b40a55 100755 --- a/xml2txt.py +++ b/xml2txt.py @@ -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)