Use cStringIO to open zip files in python 2.5

This commit is contained in:
John Garland 2010-01-07 15:27:05 +00:00
parent 34b2ada0db
commit 5a35d60178
2 changed files with 8 additions and 1 deletions

View file

@ -28,6 +28,7 @@
* Minor speedup in parsing blocklists
* Blocklist now attempts to download the URL multiple times before giving
up
* Fix blocklist not being able to open zipped blocklists with python 2.5
==== Web ====
* Put the default password in the manpage.

View file

@ -39,7 +39,13 @@ def Zipped(reader):
"""Blocklist reader for zipped blocklists"""
def open(self):
z = zipfile.ZipFile(self.file)
return z.open(z.namelist()[0])
if hasattr(z, 'open'):
f = z.open(z.namelist()[0])
else:
# Handle python 2.5
import cStringIO
f = cStringIO.StringIO(z.read(z.namelist()[0]))
return f
reader.open = open
return reader