From c61a6eb34ba6f5d1f7b7bf2e72c3f6b2b0f9c424 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 30 Dec 2008 03:52:18 +0000 Subject: [PATCH] Add PeerGuardian Text (Gzip) reader --- deluge/plugins/blocklist/blocklist/core.py | 5 +++-- deluge/plugins/blocklist/blocklist/text.py | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/deluge/plugins/blocklist/blocklist/core.py b/deluge/plugins/blocklist/blocklist/core.py index d062b4b7f..031875562 100644 --- a/deluge/plugins/blocklist/blocklist/core.py +++ b/deluge/plugins/blocklist/blocklist/core.py @@ -38,7 +38,7 @@ import deluge.configmanager from deluge.core.rpcserver import export from peerguardian import PGReader, PGException -from text import TextReader, GZMuleReader, PGZip +from text import TextReader, GZMuleReader, PGZip, PGTextReaderGzip DEFAULT_PREFS = { "url": "http://deluge-torrent.org/blocklist/nipfilter.dat.gz", @@ -57,7 +57,8 @@ FORMATS = { 'gzmule': ["Emule IP list (GZip)", GZMuleReader], 'spzip': ["SafePeer Text (Zipped)", PGZip], 'pgtext': ["PeerGuardian Text (Uncompressed)", TextReader], - 'p2bgz': ["PeerGuardian P2B (GZip)", PGReader] + 'p2bgz': ["PeerGuardian P2B (GZip)", PGReader], + 'pgtextgz': ["PeerGuardian Text (GZip)", PGTextReaderGzip] } class Core(CorePluginBase): diff --git a/deluge/plugins/blocklist/blocklist/text.py b/deluge/plugins/blocklist/blocklist/text.py index d607effa1..2c29fefc5 100644 --- a/deluge/plugins/blocklist/blocklist/text.py +++ b/deluge/plugins/blocklist/blocklist/text.py @@ -59,6 +59,13 @@ class PGTextReader(TextBase): regexp = ':(\d+)\.(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)\.(\d+)\.(\d+)\s*$' TextBase.__init__(self, fd, regexp) +class PGTextReaderGzip(PGTextReader): + def __init__(self, filename): + log.debug("PGTextReaderGzip loading") + try: + PGTextReader.__init__(self, gzip.open(filename, "r")) + except: + log.debug("Wrong file type or corrupted blocklist file.") # This reads uncompressed PG text list class TextReader(PGTextReader):