Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deluge 2.0 Support #37

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions labelplus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ class CorePlugin(PluginInitBase):

def __init__(self, plugin_name):

from core.core import Core as _plugin_cls
from .core.core import Core as _plugin_cls
self._plugin_cls = _plugin_cls
super(CorePlugin, self).__init__(plugin_name)


class GtkUIPlugin(PluginInitBase):
class Gtk3UIPlugin(PluginInitBase):

def __init__(self, plugin_name):

from gtkui.gtkui import GtkUI as _plugin_cls
from .gtkui.gtkui import GtkUI as _plugin_cls
self._plugin_cls = _plugin_cls
super(GtkUIPlugin, self).__init__(plugin_name)
super(Gtk3UIPlugin, self).__init__(plugin_name)


class WebUIPlugin(PluginInitBase):

def __init__(self, plugin_name):

from webui import WebUI as _plugin_cls
from .webui import WebUI as _plugin_cls
self._plugin_cls = _plugin_cls
super(WebUIPlugin, self).__init__(plugin_name)
55 changes: 33 additions & 22 deletions labelplus/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
STATUS_NAME = "%s_name" % MODULE_NAME

DATETIME_010101 = datetime.datetime(1, 1, 1)

LABEL_UPDATE_TYPE_FULL = "Full"

def get_resource(filename):

Expand All @@ -64,18 +64,6 @@ def get_resource(filename):
MODULE_NAME, os.path.join("data", filename))


class LabelUpdate(object):

TYPE_FULL = "Full"


def __init__(self, type_, timestamp, data):

self.type = type_
self.timestamp = timestamp
self.data = data


# Section: Error

class LabelPlusError(Exception):
Expand Down Expand Up @@ -103,13 +91,8 @@ def tr(self):


def extract_error(failure):

from deluge.ui.client import DelugeRPCError


if (isinstance(failure.value, DelugeRPCError) and
failure.value.exception_type == "LabelPlusError"):
return LabelPlusError(failure.value.exception_msg)
if failure.check(LabelPlusError):
return LabelPlusError(failure.value.message)
else:
return None

Expand Down Expand Up @@ -188,7 +171,7 @@ def copy_dict_value(src, dest, src_key, dest_key, use_deepcopy=False):
# Cumulative dict update
def update_dict(dest, src, use_deepcopy=False):

for key in src.keys():
for key in list(src.keys()):
if key not in dest or not isinstance(src[key], dict):
copy_dict_value(src, dest, key, key, use_deepcopy)
continue
Expand All @@ -199,7 +182,7 @@ def update_dict(dest, src, use_deepcopy=False):

def normalize_dict(dict_in, template):

for key in dict_in.keys():
for key in list(dict_in.keys()):
if key not in template:
del dict_in[key]

Expand Down Expand Up @@ -363,3 +346,31 @@ def recurse(dict_in, dict_out, pos_in, pos_out):
recurse(dict_in, dict_out, 0, 0)

return dict_out


def cmp(a, b):
return (a > b) - (a < b)


def serialize_datetime(dt):
utc_time = dt.time()
return {'Y': dt.year,
'M': dt.month,
'D': dt.day,
'H': utc_time.hour,
'm': utc_time.minute,
's': utc_time.second,
'u': utc_time.microsecond,
'f': utc_time.fold}


def deserialize_datetime(d):
return datetime.datetime(d['Y'],
d['M'],
d['D'],
hour=d['H'],
minute=d['m'],
second=d['s'],
microsecond=d['u'],
tzinfo=None,
fold=d['f'])
2 changes: 1 addition & 1 deletion labelplus/common/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def init_config(config, defaults, version, specs):
raise ValueError("Config file conversion v%s -> v%s not supported" %
(file_ver, version))

for key in config.config.keys():
for key in list(config.config.keys()):
if key not in defaults:
del config.config[key]

Expand Down
2 changes: 1 addition & 1 deletion labelplus/common/config/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def process_spec(spec, dict_in):
if spec["map"].get("*") == "*":
working_dict = dict_in
else:
for src, dest in sorted(spec["map"].items(),
for src, dest in sorted(list(spec["map"].items()),
key=lambda x: x[1].count("/")):
mapped = labelplus.common.get_path_mapped_dict(dict_in, src, dest,
spec["deepcopy"], spec["strict"])
Expand Down
10 changes: 5 additions & 5 deletions labelplus/core/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@

def remove_invalid_keys(dict_in):

for key in dict_in.keys():
for key in list(dict_in.keys()):
if key not in labelplus.common.config.CONFIG_DEFAULTS:
del dict_in[key]

for key in dict_in["prefs"].keys():
for key in list(dict_in["prefs"].keys()):
if key not in labelplus.common.config.CONFIG_DEFAULTS["prefs"]:
del dict_in["prefs"][key]

for key in dict_in["prefs"]["options"].keys():
for key in list(dict_in["prefs"]["options"].keys()):
if key not in labelplus.common.config.OPTION_DEFAULTS:
del dict_in["prefs"]["options"][key]

for key in dict_in["prefs"]["label"].keys():
for key in list(dict_in["prefs"]["label"].keys()):
if key not in labelplus.common.config.LABEL_DEFAULTS:
del dict_in["prefs"]["label"][key]

for id in dict_in["labels"]:
options = dict_in["labels"][id]["options"]
for key in options.keys():
for key in list(options.keys()):
if key not in labelplus.common.config.LABEL_DEFAULTS:
del options[key]
4 changes: 2 additions & 2 deletions labelplus/core/config/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def post_map_v1_v2(spec, dict_in):
def remove_v1_prefix(dict_in):

labels = dict_in["labels"]
for id in labels.keys():
for id in list(labels.keys()):
if id.startswith("-"):
data = labels[id]
del labels[id]
Expand Down Expand Up @@ -88,7 +88,7 @@ def convert_auto_queries(dict_in, op):
convert_auto_queries(label_defaults, op)

labels = dict_in["labels"]
for id in labels.keys():
for id in list(labels.keys()):
if id in labelplus.common.label.RESERVED_IDS:
del labels[id]
continue
Expand Down
Loading