From b82bc24308b3c34caf6d9ef3786c9da4ef5fd3af Mon Sep 17 00:00:00 2001 From: Graham Northup Date: Tue, 5 Feb 2019 00:20:44 -0500 Subject: lotsa stuff --- shiv.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'shiv.py') diff --git a/shiv.py b/shiv.py index e8cc37d..72569a2 100644 --- a/shiv.py +++ b/shiv.py @@ -4,6 +4,8 @@ import xml.etree.ElementTree as ET import optparse import sys import math +import gzip +import bz2 parser = optparse.OptionParser() parser.add_option('-n', '--number', dest='number', action='store_true', help='Show number of tracks') @@ -122,7 +124,13 @@ for fname in args: print print 'File :', fname try: - iv = ET.parse(fname).getroot() + if fname.endswith('.ivz'): + ivf = gzip.open(fname, 'rb') + elif fname.endswith('.ivb'): + ivf = bz2.BZ2File(fname, 'r') + else: + ivf = open(fname, 'rb') + iv = ET.parse(ivf).getroot() except Exception: import traceback traceback.print_exc() -- cgit v1.2.3-70-g09d2