Author: johnnyg

Revision: 6053

Log:
        More relaxed definition of what a commented line is in a blocklist.
Decorate readranges with raiseError rather than parse to increase performance.

Diff:
Modified: branches/1.2_RC/ChangeLog
===================================================================
--- branches/1.2_RC/ChangeLog   2009-12-21 13:48:00 UTC (rev 6052)
+++ branches/1.2_RC/ChangeLog   2009-12-21 13:58:24 UTC (rev 6053)
@@ -12,6 +12,8 @@
 ==== Blocklist ====
        * Fix blocklist status icon not opening the blocklist preference
          page in certain locales
+       * Fix blocklist not recognising comments that begin with whitespace
+       * Minor speedup in parsing blocklists
 
 === Deluge 1.2.0_rc5 (17 December 2009) ===
 ==== Web ====

Modified: branches/1.2_RC/deluge/plugins/blocklist/blocklist/readers.py
===================================================================
--- branches/1.2_RC/deluge/plugins/blocklist/blocklist/readers.py       
2009-12-21 13:48:00 UTC (rev 6052)
+++ branches/1.2_RC/deluge/plugins/blocklist/blocklist/readers.py       
2009-12-21 13:58:24 UTC (rev 6053)
@@ -60,7 +60,8 @@
 
     def is_ignored(self, line):
         """Ignore commented lines and blank lines"""
-        return line.startswith('#') or not line.strip()
+        line = line.strip()
+        return line.startswith('#') or not line
 
     def is_valid(self):
         """Determines whether file is valid for this reader"""
@@ -80,6 +81,7 @@
         blocklist.close()
         return valid
 
+    @raiseError(ReaderParseError)
     def readranges(self):
         """Yields each ip range from the file"""
         blocklist = self.open()
@@ -90,13 +92,11 @@
 
 class EmuleReader(BaseReader):
     """Blocklist reader for emule style blocklists"""
-    @raiseError(ReaderParseError)
     def parse(self, line):
         return line.strip().split(" , ")[0].split(" - ")
 
 class SafePeerReader(BaseReader):
     """Blocklist reader for SafePeer style blocklists"""
-    @raiseError(ReaderParseError)
     def parse(self, line):
         return line.strip().split(":")[-1].split("-")
 

Modified: trunk/deluge/plugins/blocklist/blocklist/readers.py
===================================================================
--- trunk/deluge/plugins/blocklist/blocklist/readers.py 2009-12-21 13:48:00 UTC 
(rev 6052)
+++ trunk/deluge/plugins/blocklist/blocklist/readers.py 2009-12-21 13:58:24 UTC 
(rev 6053)
@@ -60,7 +60,8 @@
 
     def is_ignored(self, line):
         """Ignore commented lines and blank lines"""
-        return line.startswith('#') or not line.strip()
+        line = line.strip()
+        return line.startswith('#') or not line
 
     def is_valid(self):
         """Determines whether file is valid for this reader"""
@@ -80,6 +81,7 @@
         blocklist.close()
         return valid
 
+    @raiseError(ReaderParseError)
     def readranges(self):
         """Yields each ip range from the file"""
         blocklist = self.open()
@@ -90,13 +92,11 @@
 
 class EmuleReader(BaseReader):
     """Blocklist reader for emule style blocklists"""
-    @raiseError(ReaderParseError)
     def parse(self, line):
         return line.strip().split(" , ")[0].split(" - ")
 
 class SafePeerReader(BaseReader):
     """Blocklist reader for SafePeer style blocklists"""
-    @raiseError(ReaderParseError)
     def parse(self, line):
         return line.strip().split(":")[-1].split("-")
 


--

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