summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Garland <johnnyg@gmail.com>2009-12-21 13:58:24 +0000
committerJohn Garland <johnnyg@gmail.com>2009-12-21 13:58:24 +0000
commit6b396f1f77143a252b3edd5d9f61f489e113a6ce (patch)
treefdbdd38dbacf17a09e6215589c674becf20bfd65
parentb2990e89cb19d79718b8bc0672534c4923efa9ee (diff)
downloaddeluge-6b396f1f77143a252b3edd5d9f61f489e113a6ce.tar.gz
deluge-6b396f1f77143a252b3edd5d9f61f489e113a6ce.tar.bz2
deluge-6b396f1f77143a252b3edd5d9f61f489e113a6ce.zip
More relaxed definition of what a commented line is in a blocklist.
Decorate readranges with raiseError rather than parse to increase performance.
-rw-r--r--ChangeLog2
-rw-r--r--deluge/plugins/blocklist/blocklist/readers.py6
2 files changed, 5 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 91fc9c992..3e44b5ae0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 ====
diff --git a/deluge/plugins/blocklist/blocklist/readers.py b/deluge/plugins/blocklist/blocklist/readers.py
index a520fad3c..125fe6a2a 100644
--- a/deluge/plugins/blocklist/blocklist/readers.py
+++ b/deluge/plugins/blocklist/blocklist/readers.py
@@ -60,7 +60,8 @@ class BaseReader(object):
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 @@ class BaseReader(object):
blocklist.close()
return valid
+ @raiseError(ReaderParseError)
def readranges(self):
"""Yields each ip range from the file"""
blocklist = self.open()
@@ -90,13 +92,11 @@ class BaseReader(object):
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("-")