From 745d1cb6566a58f0d00af593480f0efecb6194c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 13 Apr 2009 13:38:50 +0100 Subject: [PATCH] Handle compressed XML. --- xml2txt.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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) -- 2.45.2