Author: johnnyg

Revision: 6080

Log:
        Use cStringIO to open zip files in python 2.5

Diff:
Modified: branches/1.2_RC/ChangeLog
===================================================================
--- branches/1.2_RC/ChangeLog   2010-01-07 00:45:47 UTC (rev 6079)
+++ branches/1.2_RC/ChangeLog   2010-01-07 15:27:05 UTC (rev 6080)
@@ -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.

Modified: branches/1.2_RC/deluge/plugins/blocklist/blocklist/decompressers.py
===================================================================
--- branches/1.2_RC/deluge/plugins/blocklist/blocklist/decompressers.py 
2010-01-07 00:45:47 UTC (rev 6079)
+++ branches/1.2_RC/deluge/plugins/blocklist/blocklist/decompressers.py 
2010-01-07 15:27:05 UTC (rev 6080)
@@ -39,7 +39,13 @@
     """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
 

Modified: trunk/deluge/plugins/blocklist/blocklist/decompressers.py
===================================================================
--- trunk/deluge/plugins/blocklist/blocklist/decompressers.py   2010-01-07 
00:45:47 UTC (rev 6079)
+++ trunk/deluge/plugins/blocklist/blocklist/decompressers.py   2010-01-07 
15:27:05 UTC (rev 6080)
@@ -39,7 +39,13 @@
     """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
 


-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.


Reply via email to