This commit reverts namespace for the plugins and uses a module prefix
"deluge_" in it's place. The distribution package name remains the same
for now but will also be considered to use a prefix to help find the
third-party plugins e.g. Deluge-{Plugin} and the pluginmanager will
strip the prefix for displaying.
The change is a result of problems trying to package Deluge with
pyinstaller and the pkg_resources namespaces is not compatible.
Testing alternatives to using the pkgutil or PEP420 (native) namespaces
did not yield any joy either as importing eggs with namespaces does not
work. [1]
At this point importable eggs are considered deprecated but there is no
viable alternative yet. [2]
[1] https://github.com/pypa/packaging-problems/issues/212
[2] https://github.com/pypa/packaging-problems/issues/244
48 lines
1.0 KiB
Python
48 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
#
|
|
# 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
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
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
|