Use cStringIO to open zip files in python 2.5
This commit is contained in:
parent
34b2ada0db
commit
5a35d60178
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user