Revert "[#2341] Use common.resource_filename in plugins"
Using common.resource_filename broke plugins so need to find a better solution for non-ascii dirs.
This reverts commit bdb3b509ad
.
This commit is contained in:
parent
3893d3e214
commit
fb4307f748
|
@ -253,27 +253,16 @@ def get_pixmap(fname):
|
|||
|
||||
|
||||
def resource_filename(module, path):
|
||||
"""A workaround for pkg_resources.resource_filename finding wrong package when developing
|
||||
|
||||
When developing and there is a second deluge package (installed globally) and
|
||||
another in develop mode elsewhere. While pkg_resources.require('Deluge')
|
||||
returns the proper deluge instance, resource_filename does not, it returns
|
||||
the first found on the python path, which is not what is wanted.
|
||||
|
||||
Also ensures the filename path is decoded from bytes.
|
||||
|
||||
Args:
|
||||
module (str): The module name in dotted notation.
|
||||
path (str): The relative path to resource.
|
||||
|
||||
Returns:
|
||||
str: The absolute resource path.
|
||||
|
||||
"""While developing, if there's a second deluge package, installed globally
|
||||
and another in develop mode somewhere else, while pkg_resources.require('Deluge')
|
||||
returns the proper deluge instance, pkg_resources.resource_filename does
|
||||
not, it returns the first found on the python path, which is not good
|
||||
enough.
|
||||
This is a work-around that.
|
||||
"""
|
||||
filename = pkg_resources.require('Deluge>=%s' % get_version())[0].get_resource_filename(
|
||||
pkg_resources._manager, os.path.join(*(module.split('.') + [path])))
|
||||
|
||||
return decode_bytes(filename)
|
||||
return pkg_resources.require('Deluge>=%s' % get_version())[0].get_resource_filename(
|
||||
pkg_resources._manager, os.path.join(*(module.split('.') + [path]))
|
||||
)
|
||||
|
||||
|
||||
def open_file(path, timestamp=None):
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from os.path import join
|
||||
import os.path
|
||||
|
||||
from deluge.common import resource_filename
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename('deluge.plugins.autoadd', join('data', filename))
|
||||
return resource_filename('deluge.plugins.autoadd', os.path.join('data', filename))
|
||||
|
|
|
@ -14,15 +14,15 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
from functools import wraps
|
||||
from os.path import join
|
||||
from sys import exc_info
|
||||
|
||||
from deluge.common import resource_filename
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename('deluge.plugins.blocklist', join('data', filename))
|
||||
return resource_filename('deluge.plugins.blocklist', os.path.join('data', filename))
|
||||
|
||||
|
||||
def raises_errors_as(error):
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from os.path import join
|
||||
import os.path
|
||||
|
||||
from deluge.common import resource_filename
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename('deluge.plugins.execute', join('data', filename))
|
||||
return resource_filename('deluge.plugins.execute', os.path.join('data', filename))
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from os.path import join
|
||||
import os.path
|
||||
|
||||
from deluge.common import resource_filename
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename('deluge.plugins.extractor', join('data', filename))
|
||||
return resource_filename('deluge.plugins.extractor', os.path.join('data', filename))
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from os.path import join
|
||||
import os.path
|
||||
|
||||
from deluge.common import resource_filename
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename('deluge.plugins.label', join('data', filename))
|
||||
return resource_filename('deluge.plugins.label', os.path.join('data', filename))
|
||||
|
|
|
@ -15,19 +15,19 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
from os.path import join
|
||||
import os.path
|
||||
|
||||
from pkg_resources import resource_filename
|
||||
from twisted.internet import defer
|
||||
|
||||
from deluge import component
|
||||
from deluge.common import resource_filename
|
||||
from deluge.event import known_events
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename('deluge.plugins.notifications', join('data', filename))
|
||||
return resource_filename('deluge.plugins.notifications', os.path.join('data', filename))
|
||||
|
||||
|
||||
class CustomNotifications(object):
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from os.path import join
|
||||
import os.path
|
||||
|
||||
from deluge.common import resource_filename
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename('deluge.plugins.scheduler', join('data', filename))
|
||||
return resource_filename('deluge.plugins.scheduler', os.path.join('data', filename))
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from os.path import join
|
||||
import os.path
|
||||
|
||||
from deluge.common import resource_filename
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename('deluge.plugins.stats', join('data', filename))
|
||||
return resource_filename('deluge.plugins.stats', os.path.join('data', filename))
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from os.path import join
|
||||
import os.path
|
||||
|
||||
from deluge.common import resource_filename
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename('deluge.plugins.toggle', join('data', filename))
|
||||
return resource_filename('deluge.plugins.toggle', os.path.join('data', filename))
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from os.path import join
|
||||
import os.path
|
||||
|
||||
from deluge.common import resource_filename
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename('deluge.plugins.webui', join('data', filename))
|
||||
return resource_filename('deluge.plugins.webui', os.path.join('data', filename))
|
||||
|
|
|
@ -213,12 +213,13 @@ setup(
|
|||
COMMON = """
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from os.path import join
|
||||
import os.path
|
||||
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
from deluge.common import resource_filename
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename('deluge.plugins.%(safe_name)s', join('data', filename))
|
||||
return resource_filename('deluge.plugins.%(safe_name)s', os.path.join('data', filename))
|
||||
"""
|
||||
|
||||
GTKUI = """
|
||||
|
|
Loading…
Reference in New Issue