summaryrefslogtreecommitdiffstats
path: root/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 21:38:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 21:38:38 +0000
commit2e2851dc13d73352530dd4495c7e05603b2e520d (patch)
tree622b9cd8e5d32091c9aa9e4937b533975a40356c /deluge/plugins/Blocklist/deluge_blocklist/decompressers.py
parentInitial commit. (diff)
downloaddeluge-2e2851dc13d73352530dd4495c7e05603b2e520d.tar.xz
deluge-2e2851dc13d73352530dd4495c7e05603b2e520d.zip
Adding upstream version 2.1.2~dev0+20240219.upstream/2.1.2_dev0+20240219upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'deluge/plugins/Blocklist/deluge_blocklist/decompressers.py')
-rw-r--r--deluge/plugins/Blocklist/deluge_blocklist/decompressers.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py b/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py
new file mode 100644
index 0000000..cd2ee8c
--- /dev/null
+++ b/deluge/plugins/Blocklist/deluge_blocklist/decompressers.py
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
+#
+# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+# the additional special exception to link portions of this program with the OpenSSL library.
+# See LICENSE for more details.
+#
+# pylint: disable=redefined-builtin
+
+import bz2
+import gzip
+import zipfile
+
+
+def Zipped(reader): # NOQA: N802
+ """Blocklist reader for zipped blocklists"""
+
+ def _open(self):
+ z = zipfile.ZipFile(self.file)
+ f = z.open(z.namelist()[0])
+ return f
+
+ reader.open = _open
+ return reader
+
+
+def GZipped(reader): # NOQA: N802
+ """Blocklist reader for gzipped blocklists"""
+
+ def _open(self):
+ return gzip.open(self.file)
+
+ reader.open = _open
+ return reader
+
+
+def BZipped2(reader): # NOQA: N802
+ """Blocklist reader for bzipped2 blocklists"""
+
+ def _open(self):
+ return bz2.BZ2File(self.file)
+
+ reader.open = _open
+ return reader