From 730b160e28d711fad96e6a61070e374ad0966566 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Apr 2015 01:07:33 +0200 Subject: Spare code cosmetics (2) --- pyload/utils/pylgettext.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'pyload/utils') diff --git a/pyload/utils/pylgettext.py b/pyload/utils/pylgettext.py index 0e3ebad80..1f31cf42d 100644 --- a/pyload/utils/pylgettext.py +++ b/pyload/utils/pylgettext.py @@ -6,12 +6,10 @@ _searchdirs = None origfind = find + def setpaths(pathlist): global _searchdirs - if isinstance(pathlist, list): - _searchdirs = pathlist - else: - _searchdirs = list(pathlist) + _searchdirs = pathlist if isinstance(pathlist, list) else list(pathlist) def addpath(path): @@ -32,8 +30,7 @@ def delpath(path): def clearpath(): global _searchdirs - if _searchdirs is not None: - _searchdirs = None + _searchdirs = None def find(domain, localedir=None, languages=None, all=False): @@ -51,8 +48,7 @@ def find(domain, localedir=None, languages=None, all=False): results = filter(lambda x: x is not None, results) if len(results) == 0: return None - else: - return results[0] + return results[0] else: return results -- cgit v1.2.3 From e48abf98766b0a9c5799f17073d867dc09b23663 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Apr 2015 17:54:19 +0200 Subject: PEP-8, Python Zen, refactor and reduce code (part 3 in master module) Conflicts: module/InitHomeDir.py module/debug.py module/forwarder.py module/unescape.py pyload/datatype/Package.py pyload/manager/Event.py pyload/manager/Thread.py pyload/manager/event/Scheduler.py pyload/utils/__init__.py pyload/webui/filters.py --- pyload/utils/__init__.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'pyload/utils') diff --git a/pyload/utils/__init__.py b/pyload/utils/__init__.py index 648432c26..2e23bf99b 100644 --- a/pyload/utils/__init__.py +++ b/pyload/utils/__init__.py @@ -116,13 +116,17 @@ def compare_time(start, end): start = map(int, start) end = map(int, end) - if start == end: return True + if start == end: + return True now = list(time.localtime()[3:5]) - if start < now < end: return True - elif start > end and (now > start or now < end): return True - elif start < now > end < start: return True - else: return False + if start < now < end: + return True + elif start > end and (now > start or now < end): + return True + elif start < now > end < start: + return True + return False def formatSize(size): -- cgit v1.2.3 From ba3686d499f6df9793989486d178cbc55f1ee4bf Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Apr 2015 20:11:06 +0200 Subject: PEP-8, Python Zen, refactor and reduce code (part 6 in master module/common) Conflicts: locale/pavement.py module/common/ImportDebugger.py module/common/JsEngine.py module/common/json_layer.py module/common/packagetools.py tests/APIExerciser.py tests/test_api.py tests/test_json.py --- pyload/utils/pylgettext.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pyload/utils') diff --git a/pyload/utils/pylgettext.py b/pyload/utils/pylgettext.py index 1f31cf42d..86cfc586a 100644 --- a/pyload/utils/pylgettext.py +++ b/pyload/utils/pylgettext.py @@ -48,7 +48,8 @@ def find(domain, localedir=None, languages=None, all=False): results = filter(lambda x: x is not None, results) if len(results) == 0: return None - return results[0] + else: + return results[0] else: return results -- cgit v1.2.3 From bb5a115533711fd8bb87f53cb32ff7342137208d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 18 Apr 2015 00:29:55 +0200 Subject: Spare code cosmetics (5) --- pyload/utils/packagetools.py | 2 +- pyload/utils/printer.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'pyload/utils') diff --git a/pyload/utils/packagetools.py b/pyload/utils/packagetools.py index 9dbde9b50..0ab68a869 100644 --- a/pyload/utils/packagetools.py +++ b/pyload/utils/packagetools.py @@ -136,7 +136,7 @@ def parseNames(files): else: name = "" - # fallback: package by hoster + #@NOTE: fallback: package by hoster if not name: name = urlparse(file).netloc if name: diff --git a/pyload/utils/printer.py b/pyload/utils/printer.py index 5d333e238..1122c7f4c 100644 --- a/pyload/utils/printer.py +++ b/pyload/utils/printer.py @@ -5,6 +5,7 @@ import colorama colorama.init(autoreset=True) + def color(color, text): return colorama.Fore.(c.upper())(text) -- cgit v1.2.3