diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-20 21:38:42 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-20 23:01:29 +0200 |
commit | 9327b55e147d95b5865f23788f980c7268ea03e3 (patch) | |
tree | 0260b6f90b9e6fab5548e29e44b6d66f3334c98e | |
parent | PEP-8, Python Zen, refactor and reduce code (part 9 in master module/network) (diff) | |
download | pyload-9327b55e147d95b5865f23788f980c7268ea03e3.tar.xz |
Spare code cosmetics (7)
-rw-r--r-- | pyload/config/Setup.py | 2 | ||||
-rw-r--r-- | pyload/manager/Plugin.py | 6 | ||||
-rw-r--r-- | pyload/network/JsEngine.py | 2 | ||||
-rw-r--r-- | pyload/plugin/Account.py | 2 | ||||
-rw-r--r-- | pyload/plugin/account/CloudzillaTo.py | 2 | ||||
-rw-r--r-- | pyload/plugin/account/Keep2ShareCc.py | 2 | ||||
-rw-r--r-- | pyload/plugin/account/MegasharesCom.py | 2 | ||||
-rw-r--r-- | pyload/plugin/account/MultishareCz.py | 2 | ||||
-rw-r--r-- | pyload/plugin/account/QuickshareCz.py | 2 | ||||
-rw-r--r-- | pyload/plugin/account/UlozTo.py | 2 | ||||
-rw-r--r-- | pyload/plugin/account/UploadedTo.py | 2 | ||||
-rw-r--r-- | pyload/plugin/account/UploadingCom.py | 2 | ||||
-rw-r--r-- | pyload/plugin/account/YibaishiwuCom.py | 2 | ||||
-rw-r--r-- | pyload/plugin/addon/UpdateManager.py | 2 | ||||
-rw-r--r-- | pyload/plugin/extractor/UnRar.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/SimpleHoster.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/XFSAccount.py | 2 | ||||
-rw-r--r-- | pyload/remote/thriftbackend/Processor.py | 2 | ||||
-rw-r--r-- | pyload/webui/app/pyloadweb.py | 2 | ||||
-rw-r--r-- | pyload/webui/app/utils.py | 4 |
20 files changed, 23 insertions, 23 deletions
diff --git a/pyload/config/Setup.py b/pyload/config/Setup.py index ce5a5fb88..c879eb9e0 100644 --- a/pyload/config/Setup.py +++ b/pyload/config/Setup.py @@ -261,7 +261,7 @@ class SetupAssistant(object): web = sqlite and beaker - js = True if JsEngine.find() else False + js = bool(JsEngine.find()) self.print_dep(_("JS engine"), js) if not python: diff --git a/pyload/manager/Plugin.py b/pyload/manager/Plugin.py index a081a643e..9417a6935 100644 --- a/pyload/manager/Plugin.py +++ b/pyload/manager/Plugin.py @@ -126,7 +126,7 @@ class PluginManager(object): module = f.replace(".pyc", "").replace(".py", "") # the plugin is loaded from user directory - plugins[name]['user'] = True if rootplugins else False + plugins[name]['user'] = bool(rootplugins) plugins[name]['name'] = module pattern = self.PATTERN.findall(content) @@ -162,7 +162,7 @@ class PluginManager(object): config = [list(config)] if folder not in ("account", "internal") and not [True for item in config if item[0] == "activated"]: - config.insert(0, ["activated", "bool", "Activated", False if folder in ("addon", "hook") else True]) + config.insert(0, ["activated", "bool", "Activated", not folder in ("addon", "hook")]) self.core.config.addPluginConfig("%s_%s" % (name, folder), config, desc) except Exception: @@ -398,4 +398,4 @@ class PluginManager(object): def reloadPlugin(self, type_plugin): """ reload and reindex ONE plugin """ - return True if self.reloadPlugins(type_plugin) else False + return bool(self.reloadPlugins(type_plugin)) diff --git a/pyload/network/JsEngine.py b/pyload/network/JsEngine.py index c64e8c490..b59d07dc4 100644 --- a/pyload/network/JsEngine.py +++ b/pyload/network/JsEngine.py @@ -112,7 +112,7 @@ class AbstractEngine(object): def __init__(self, force=False): self.setup() - self.available = True if force else self.find() + self.available = force or self.find() def setup(self): diff --git a/pyload/plugin/Account.py b/pyload/plugin/Account.py index c46eae5e3..f025170b3 100644 --- a/pyload/plugin/Account.py +++ b/pyload/plugin/Account.py @@ -260,7 +260,7 @@ class Account(Base): def canUse(self): - return False if self.selectAccount() == (None, None) else True + return self.selectAccount() != (None, None) def parseTraffic(self, value, unit=None): #: return bytes diff --git a/pyload/plugin/account/CloudzillaTo.py b/pyload/plugin/account/CloudzillaTo.py index af3544da9..bee7c5a17 100644 --- a/pyload/plugin/account/CloudzillaTo.py +++ b/pyload/plugin/account/CloudzillaTo.py @@ -21,7 +21,7 @@ class CloudzillaTo(Account): def loadAccountInfo(self, user, req): html = req.load("http://www.cloudzilla.to/") - premium = True if re.search(self.PREMIUM_PATTERN, html) else False + premium = re.search(self.PREMIUM_PATTERN, html) is not None return {'validuntil': -1, 'trafficleft': -1, 'premium': premium} diff --git a/pyload/plugin/account/Keep2ShareCc.py b/pyload/plugin/account/Keep2ShareCc.py index 6ee45c256..56ac5e9ab 100644 --- a/pyload/plugin/account/Keep2ShareCc.py +++ b/pyload/plugin/account/Keep2ShareCc.py @@ -46,7 +46,7 @@ class Keep2ShareCc(Account): self.logError(e) else: - premium = True if validuntil > time.mktime(time.gmtime()) else False + premium = validuntil > time.mktime(time.gmtime()) m = re.search(self.TRAFFIC_LEFT_PATTERN, html) if m: diff --git a/pyload/plugin/account/MegasharesCom.py b/pyload/plugin/account/MegasharesCom.py index 42ecfc17d..593583a0e 100644 --- a/pyload/plugin/account/MegasharesCom.py +++ b/pyload/plugin/account/MegasharesCom.py @@ -23,7 +23,7 @@ class MegasharesCom(Account): #self.relogin(user) html = req.load("http://d01.megashares.com/myms.php", decode=True) - premium = False if '>Premium Upgrade<' in html else True + premium = '>Premium Upgrade<' not in html validuntil = trafficleft = -1 try: diff --git a/pyload/plugin/account/MultishareCz.py b/pyload/plugin/account/MultishareCz.py index b743fd28a..6d41a2b18 100644 --- a/pyload/plugin/account/MultishareCz.py +++ b/pyload/plugin/account/MultishareCz.py @@ -25,7 +25,7 @@ class MultishareCz(Account): m = re.search(self.TRAFFIC_LEFT_PATTERN, html) trafficleft = self.parseTraffic(m.group('S') + m.group('U')) if m else 0 - self.premium = True if trafficleft else False + self.premium = bool(trafficleft) html = req.load("http://www.multishare.cz/", decode=True) mms_info = dict(re.findall(self.ACCOUNT_INFO_PATTERN, html)) diff --git a/pyload/plugin/account/QuickshareCz.py b/pyload/plugin/account/QuickshareCz.py index 67dd11ac3..2f71d9ae8 100644 --- a/pyload/plugin/account/QuickshareCz.py +++ b/pyload/plugin/account/QuickshareCz.py @@ -24,7 +24,7 @@ class QuickshareCz(Account): m = re.search(self.TRAFFIC_LEFT_PATTERN, html) if m: trafficleft = self.parseTraffic(m.group(1)) - premium = True if trafficleft else False + premium = bool(trafficleft) else: trafficleft = None premium = False diff --git a/pyload/plugin/account/UlozTo.py b/pyload/plugin/account/UlozTo.py index 34e56d325..c43246e7d 100644 --- a/pyload/plugin/account/UlozTo.py +++ b/pyload/plugin/account/UlozTo.py @@ -27,7 +27,7 @@ class UlozTo(Account): m = re.search(self.TRAFFIC_LEFT_PATTERN, html) trafficleft = float(m.group(1).replace(' ', '').replace(',', '.')) * 1000 * 1.048 if m else 0 - premium = True if trafficleft else False + premium = bool(trafficleft) return {'validuntil': -1, 'trafficleft': trafficleft, 'premium': premium} diff --git a/pyload/plugin/account/UploadedTo.py b/pyload/plugin/account/UploadedTo.py index 61765faf8..1b8ae5b27 100644 --- a/pyload/plugin/account/UploadedTo.py +++ b/pyload/plugin/account/UploadedTo.py @@ -28,7 +28,7 @@ class UploadedTo(Account): html = req.load("http://uploaded.net/me") - premium = True if re.search(self.PREMIUM_PATTERN, html) else False + premium = re.search(self.PREMIUM_PATTERN, html) is not None m = re.search(self.VALID_UNTIL_PATTERN, html, re.M) if m: diff --git a/pyload/plugin/account/UploadingCom.py b/pyload/plugin/account/UploadingCom.py index f5333dd4c..992e63615 100644 --- a/pyload/plugin/account/UploadingCom.py +++ b/pyload/plugin/account/UploadingCom.py @@ -28,7 +28,7 @@ class UploadingCom(Account): html = req.load("http://uploading.com/") - premium = False if re.search(self.PREMIUM_PATTERN, html) else True + premium = re.search(self.PREMIUM_PATTERN, html) is None m = re.search(self.VALID_UNTIL_PATTERN, html) if m: diff --git a/pyload/plugin/account/YibaishiwuCom.py b/pyload/plugin/account/YibaishiwuCom.py index ad9b089a9..0a15c29de 100644 --- a/pyload/plugin/account/YibaishiwuCom.py +++ b/pyload/plugin/account/YibaishiwuCom.py @@ -23,7 +23,7 @@ class YibaishiwuCom(Account): html = req.load("http://115.com/", decode=True) m = re.search(self.ACCOUNT_INFO_PATTERN, html, re.S) - premium = True if m and 'is_vip: 1' in m.group(1) else False + premium = m and 'is_vip: 1' in m.group(1) validuntil = trafficleft = (-1 if m else 0) return dict({"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium}) diff --git a/pyload/plugin/addon/UpdateManager.py b/pyload/plugin/addon/UpdateManager.py index cf8349e79..84d282bde 100644 --- a/pyload/plugin/addon/UpdateManager.py +++ b/pyload/plugin/addon/UpdateManager.py @@ -120,7 +120,7 @@ class UpdateManager(Addon): reloads.append(id) self.mtimes[id] = mtime - return True if self.core.pluginManager.reloadPlugins(reloads) else False + return bool(self.core.pluginManager.reloadPlugins(reloads)) def server_response(self): diff --git a/pyload/plugin/extractor/UnRar.py b/pyload/plugin/extractor/UnRar.py index cad58ff4f..38ae4e8f2 100644 --- a/pyload/plugin/extractor/UnRar.py +++ b/pyload/plugin/extractor/UnRar.py @@ -81,7 +81,7 @@ class UnRar(Extractor): @classmethod def isMultipart(cls, filename): - return True if cls.re_multipart.search(filename) else False + return cls.re_multipart.search(filename) is not None def verify(self, password): diff --git a/pyload/plugin/internal/SimpleHoster.py b/pyload/plugin/internal/SimpleHoster.py index 930f5a313..02231decc 100644 --- a/pyload/plugin/internal/SimpleHoster.py +++ b/pyload/plugin/internal/SimpleHoster.py @@ -332,7 +332,7 @@ class SimpleHoster(Hoster): @classmethod def getInfo(cls, url="", html=""): info = cls.apiInfo(url) - online = False if info['status'] != 2 else True + online = info['status'] == 2 try: info['pattern'] = re.match(cls.__pattern, url).groupdict() #: pattern groups will be saved here diff --git a/pyload/plugin/internal/XFSAccount.py b/pyload/plugin/internal/XFSAccount.py index 13c2351ce..d8c5a91f1 100644 --- a/pyload/plugin/internal/XFSAccount.py +++ b/pyload/plugin/internal/XFSAccount.py @@ -67,7 +67,7 @@ class XFSAccount(Account): html = req.load(self.HOSTER_URL, get={'op': "my_account"}, decode=True) - premium = True if re.search(self.PREMIUM_PATTERN, html) else False + premium = re.search(self.PREMIUM_PATTERN, html) is not None m = re.search(self.VALID_UNTIL_PATTERN, html) if m: diff --git a/pyload/remote/thriftbackend/Processor.py b/pyload/remote/thriftbackend/Processor.py index 7ccc2bee2..204047e2f 100644 --- a/pyload/remote/thriftbackend/Processor.py +++ b/pyload/remote/thriftbackend/Processor.py @@ -57,7 +57,7 @@ class Processor(Pyload.Processor): # api login self.authenticated[trans] = self._handler.checkAuth(args.username, args.password, trans.remoteaddr[0]) - result.success = True if self.authenticated[trans] else False + result.success = bool(self.authenticated[trans]) oprot.writeMessageBegin("login", Pyload.TMessageType.REPLY, seqid) result.write(oprot) oprot.writeMessageEnd() diff --git a/pyload/webui/app/pyloadweb.py b/pyload/webui/app/pyloadweb.py index 154409655..f4edb6bd4 100644 --- a/pyload/webui/app/pyloadweb.py +++ b/pyload/webui/app/pyloadweb.py @@ -486,7 +486,7 @@ def admin(): for data in user.itervalues(): data['perms'] = {} get_permission(data['perms'], data['permission']) - data['perms']['admin'] = True if data['role'] is 0 else False + data['perms']['admin'] = data['role'] is 0 s = request.environ.get('beaker.session') if request.environ.get('REQUEST_METHOD', "GET") == "POST": diff --git a/pyload/webui/app/utils.py b/pyload/webui/app/utils.py index 69067d8fe..8957f061e 100644 --- a/pyload/webui/app/utils.py +++ b/pyload/webui/app/utils.py @@ -80,8 +80,8 @@ def set_session(request, info): def parse_userdata(session): - return {"name": session.get("name", "Anonymous"), - "is_admin": True if session.get("role", 1) == 0 else False, + return {"name" : session.get("name", "Anonymous"), + "is_admin" : session.get("role", 1) == 0, "is_authenticated": session.get("authenticated", False)} |