Author: andar
Revision: 5811
Log:
Fix blocklist plugin
Diff:
Modified: trunk/deluge/plugins/blocklist/blocklist/core.py
===================================================================
--- trunk/deluge/plugins/blocklist/blocklist/core.py 2009-10-04 19:25:10 UTC
(rev 5810)
+++ trunk/deluge/plugins/blocklist/blocklist/core.py 2009-10-04 22:47:27 UTC
(rev 5811)
@@ -291,7 +291,9 @@
self.auto_detect(blocklist)
self.auto_detected = True
- d =
threads.deferToThread(self.reader(blocklist).read(on_read_ip_range))
+ log.debug("Importing using reader: %s",self.reader)
+ log.debug("Reader type: %s compression: %s", self.config["list_type"],
self.config["list_compression"])
+ d = threads.deferToThread(self.reader(blocklist).read,
on_read_ip_range)
d.addCallback(on_finish_read)
return d
@@ -345,6 +347,9 @@
"""
self.config["list_compression"] = detect_compression(blocklist)
self.config["list_type"] = detect_format(blocklist,
self.config["list_compression"])
+ log.debug("Auto-detected type: %s compression: %s",
self.config["list_type"], self.config["list_compression"])
if not self.config["list_type"]:
self.config["list_compression"] = ""
raise UnknownFormatError
+ else:
+ self.reader = create_reader(self.config["list_type"],
self.config["list_compression"])
Modified: trunk/deluge/plugins/blocklist/blocklist/detect.py
===================================================================
--- trunk/deluge/plugins/blocklist/blocklist/detect.py 2009-10-04 19:25:10 UTC
(rev 5810)
+++ trunk/deluge/plugins/blocklist/blocklist/detect.py 2009-10-04 22:47:27 UTC
(rev 5811)
@@ -37,9 +37,9 @@
from readers import EmuleReader, SafePeerReader, PeerGuardianReader
COMPRESSION_TYPES = {
- "PK" : "zip",
- "\x1f\x8b" : "gzip",
- "BZ" : "bzip2"
+ "PK" : "Zip",
+ "\x1f\x8b" : "GZip",
+ "BZ" : "BZ ip2"
}
DECOMPRESSERS = {
Modified: trunk/deluge/plugins/blocklist/blocklist/gtkui.py
===================================================================
--- trunk/deluge/plugins/blocklist/blocklist/gtkui.py 2009-10-04 19:25:10 UTC
(rev 5810)
+++ trunk/deluge/plugins/blocklist/blocklist/gtkui.py 2009-10-04 22:47:27 UTC
(rev 5811)
@@ -116,7 +116,7 @@
deluge.common.fsize(status["file_size"]))
self.glade.get_widget("label_modified").set_text(
str(status["file_date"]))
-
+
self.glade.get_widget("label_type").set_text(status["file_type"])
self.glade.get_widget("label_url").set_text(
status["file_url"])
Modified: trunk/deluge/plugins/blocklist/blocklist/readers.py
===================================================================
--- trunk/deluge/plugins/blocklist/blocklist/readers.py 2009-10-04 19:25:10 UTC
(rev 5810)
+++ trunk/deluge/plugins/blocklist/blocklist/readers.py 2009-10-04 22:47:27 UTC
(rev 5811)
@@ -36,6 +36,26 @@
from deluge.log import LOG as log
from common import raiseError
+def remove_zeros(ip):
+ """
+ Removes unneeded zeros from ip addresses.
+
+ Example: 000.000.000.003 -> 0.0.0.3
+
+ :param ip: the ip address
+ :type ip: string
+
+ :returns: the ip address without the unneeded zeros
+ :rtype: string
+
+ """
+ new_ip = []
+ for part in ip.split("."):
+ while part[0] == "0" and len(part) > 1:
+ part = part[1:]
+ new_ip.append(part)
+ return ".".join(new_ip)
+
class ReaderParseError(Exception):
pass
@@ -56,7 +76,7 @@
def read(self, callback):
"""Calls callback on each ip range in the file"""
for start, end in self.readranges():
- callback(start, end)
+ callback(remove_zeros(start), remove_zeros(end))
def is_ignored(self, line):
"""Ignore commented lines and blank lines"""
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---