diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/common.py b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/common.py index 79d152e9a..511692922 100644 --- a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/common.py +++ b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/common.py @@ -14,12 +14,10 @@ from __future__ import unicode_literals -import os.path +from os.path import join -from deluge.common import decode_bytes - -BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__))) +from deluge.common import resource_filename def get_resource(filename): - return os.path.join(BASE_PATH, 'data', filename) + return resource_filename('deluge.plugins.autoadd', join('data', filename)) diff --git a/deluge/plugins/Blocklist/deluge/plugins/blocklist/common.py b/deluge/plugins/Blocklist/deluge/plugins/blocklist/common.py index b53ed2605..c797a65c3 100644 --- a/deluge/plugins/Blocklist/deluge/plugins/blocklist/common.py +++ b/deluge/plugins/Blocklist/deluge/plugins/blocklist/common.py @@ -14,17 +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 decode_bytes - -BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__))) +from deluge.common import resource_filename def get_resource(filename): - return os.path.join(BASE_PATH, 'data', filename) + return resource_filename('deluge.plugins.blocklist', join('data', filename)) def raises_errors_as(error): diff --git a/deluge/plugins/Execute/deluge/plugins/execute/common.py b/deluge/plugins/Execute/deluge/plugins/execute/common.py index 79d152e9a..0bb8c343d 100644 --- a/deluge/plugins/Execute/deluge/plugins/execute/common.py +++ b/deluge/plugins/Execute/deluge/plugins/execute/common.py @@ -14,12 +14,10 @@ from __future__ import unicode_literals -import os.path +from os.path import join -from deluge.common import decode_bytes - -BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__))) +from deluge.common import resource_filename def get_resource(filename): - return os.path.join(BASE_PATH, 'data', filename) + return resource_filename('deluge.plugins.execute', join('data', filename)) diff --git a/deluge/plugins/Extractor/deluge/plugins/extractor/common.py b/deluge/plugins/Extractor/deluge/plugins/extractor/common.py index 79d152e9a..b52c3d92f 100644 --- a/deluge/plugins/Extractor/deluge/plugins/extractor/common.py +++ b/deluge/plugins/Extractor/deluge/plugins/extractor/common.py @@ -14,12 +14,10 @@ from __future__ import unicode_literals -import os.path +from os.path import join -from deluge.common import decode_bytes - -BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__))) +from deluge.common import resource_filename def get_resource(filename): - return os.path.join(BASE_PATH, 'data', filename) + return resource_filename('deluge.plugins.extractor', join('data', filename)) diff --git a/deluge/plugins/Label/deluge/plugins/label/common.py b/deluge/plugins/Label/deluge/plugins/label/common.py index 79d152e9a..2aebe6f80 100644 --- a/deluge/plugins/Label/deluge/plugins/label/common.py +++ b/deluge/plugins/Label/deluge/plugins/label/common.py @@ -14,12 +14,10 @@ from __future__ import unicode_literals -import os.path +from os.path import join -from deluge.common import decode_bytes - -BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__))) +from deluge.common import resource_filename def get_resource(filename): - return os.path.join(BASE_PATH, 'data', filename) + return resource_filename('deluge.plugins.label', join('data', filename)) diff --git a/deluge/plugins/Notifications/deluge/plugins/notifications/common.py b/deluge/plugins/Notifications/deluge/plugins/notifications/common.py index c12754a40..64e3be290 100644 --- a/deluge/plugins/Notifications/deluge/plugins/notifications/common.py +++ b/deluge/plugins/Notifications/deluge/plugins/notifications/common.py @@ -15,21 +15,19 @@ from __future__ import unicode_literals import logging -import os.path +from os.path import join from twisted.internet import defer from deluge import component -from deluge.common import decode_bytes +from deluge.common import resource_filename from deluge.event import known_events log = logging.getLogger(__name__) -BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__))) - def get_resource(filename): - return os.path.join(BASE_PATH, 'data', filename) + return resource_filename('deluge.plugins.notifications', join('data', filename)) class CustomNotifications(object): diff --git a/deluge/plugins/Scheduler/deluge/plugins/scheduler/common.py b/deluge/plugins/Scheduler/deluge/plugins/scheduler/common.py index 79d152e9a..eb752f92e 100644 --- a/deluge/plugins/Scheduler/deluge/plugins/scheduler/common.py +++ b/deluge/plugins/Scheduler/deluge/plugins/scheduler/common.py @@ -14,12 +14,10 @@ from __future__ import unicode_literals -import os.path +from os.path import join -from deluge.common import decode_bytes - -BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__))) +from deluge.common import resource_filename def get_resource(filename): - return os.path.join(BASE_PATH, 'data', filename) + return resource_filename('deluge.plugins.scheduler', join('data', filename)) diff --git a/deluge/plugins/Stats/deluge/plugins/stats/common.py b/deluge/plugins/Stats/deluge/plugins/stats/common.py index 79d152e9a..d3d26d5dc 100644 --- a/deluge/plugins/Stats/deluge/plugins/stats/common.py +++ b/deluge/plugins/Stats/deluge/plugins/stats/common.py @@ -14,12 +14,10 @@ from __future__ import unicode_literals -import os.path +from os.path import join -from deluge.common import decode_bytes - -BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__))) +from deluge.common import resource_filename def get_resource(filename): - return os.path.join(BASE_PATH, 'data', filename) + return resource_filename('deluge.plugins.stats', join('data', filename)) diff --git a/deluge/plugins/Toggle/deluge/plugins/toggle/common.py b/deluge/plugins/Toggle/deluge/plugins/toggle/common.py index 79d152e9a..8177a101e 100644 --- a/deluge/plugins/Toggle/deluge/plugins/toggle/common.py +++ b/deluge/plugins/Toggle/deluge/plugins/toggle/common.py @@ -14,12 +14,10 @@ from __future__ import unicode_literals -import os.path +from os.path import join -from deluge.common import decode_bytes - -BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__))) +from deluge.common import resource_filename def get_resource(filename): - return os.path.join(BASE_PATH, 'data', filename) + return resource_filename('deluge.plugins.toggle', join('data', filename)) diff --git a/deluge/plugins/WebUi/deluge/plugins/webui/common.py b/deluge/plugins/WebUi/deluge/plugins/webui/common.py index 79d152e9a..1e05ed1fc 100644 --- a/deluge/plugins/WebUi/deluge/plugins/webui/common.py +++ b/deluge/plugins/WebUi/deluge/plugins/webui/common.py @@ -14,12 +14,10 @@ from __future__ import unicode_literals -import os.path +from os.path import join -from deluge.common import decode_bytes - -BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__))) +from deluge.common import resource_filename def get_resource(filename): - return os.path.join(BASE_PATH, 'data', filename) + return resource_filename('deluge.plugins.webui', join('data', filename)) diff --git a/deluge/scripts/create_plugin.py b/deluge/scripts/create_plugin.py index c66aba441..83582ade8 100644 --- a/deluge/scripts/create_plugin.py +++ b/deluge/scripts/create_plugin.py @@ -213,16 +213,12 @@ setup( COMMON = """ from __future__ import unicode_literals -import os.path - -from deluge.common import decode_bytes - -BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__))) +from os.path import join +from deluge.common import resource_filename def get_resource(filename): - return os.path.join(BASE_PATH, 'data', filename) - + return resource_filename('deluge.plugins.%(safe_name)s', join('data', filename)) """ GTKUI = """