summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-07-26 02:36:15 +0200
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-08-01 17:01:44 +0200
commita1495eb2f9502fdf29974458845f928025bedf53 (patch)
treeedaf85ed7f15823bfdc271e95d537c5671ea1f86 /module
parent[UpdateManager] Disable reloadplugins schedule on plugin deactivation (diff)
downloadpyload-a1495eb2f9502fdf29974458845f928025bedf53.tar.xz
Prefer single quote for dict key
Diffstat (limited to 'module')
-rw-r--r--module/plugins/Account.py34
-rw-r--r--module/plugins/PluginManager.py60
-rw-r--r--module/plugins/crypter/DuckCryptInfo.py2
-rw-r--r--module/plugins/hoster/UploadedTo.py2
4 files changed, 49 insertions, 49 deletions
diff --git a/module/plugins/Account.py b/module/plugins/Account.py
index 21f65816a..c4d5c982c 100644
--- a/module/plugins/Account.py
+++ b/module/plugins/Account.py
@@ -85,12 +85,12 @@ class Account(Base):
self.logWarning(
_("Could not login with account %(user)s | %(msg)s") % {"user": user
, "msg": _("Wrong Password")})
- success = data["valid"] = False
+ success = data['valid'] = False
except Exception, e:
self.logWarning(
_("Could not login with account %(user)s | %(msg)s") % {"user": user
, "msg": e})
- success = data["valid"] = False
+ success = data['valid'] = False
if self.core.debug:
print_exc()
else:
@@ -120,15 +120,15 @@ class Account(Base):
""" updates account and return true if anything changed """
if user in self.accounts:
- self.accounts[user]["valid"] = True #do not remove or accounts will not login
+ self.accounts[user]['valid'] = True #do not remove or accounts will not login
if password:
- self.accounts[user]["password"] = password
+ self.accounts[user]['password'] = password
self.relogin(user)
return True
if options:
- before = self.accounts[user]["options"]
- self.accounts[user]["options"].update(options)
- return self.accounts[user]["options"] != before
+ before = self.accounts[user]['options']
+ self.accounts[user]['options'].update(options)
+ return self.accounts[user]['options'] != before
else:
self.accounts[user] = {"password": password, "options": options, "valid": True}
self._login(user, self.accounts[user])
@@ -168,7 +168,7 @@ class Account(Base):
self.logDebug("Account Info: %s" % str(infos))
- infos["timestamp"] = time()
+ infos['timestamp'] = time()
self.infos[name] = infos
elif "timestamp" in self.infos[name] and self.infos[name][
"timestamp"] + self.info_threshold * 60 < time():
@@ -180,7 +180,7 @@ class Account(Base):
def isPremium(self, user):
info = self.getAccountInfo(user)
- return info["premium"]
+ return info['premium']
def loadAccountInfo(self, name, req=None):
"""this should be overwritten in account plugin,\
@@ -193,9 +193,9 @@ class Account(Base):
return {
"validuntil": None, # -1 for unlimited
"login": name,
- #"password": self.accounts[name]["password"], #@XXX: security
- "options": self.accounts[name]["options"],
- "valid": self.accounts[name]["valid"],
+ #"password": self.accounts[name]['password'], #@XXX: security
+ "options": self.accounts[name]['options'],
+ "valid": self.accounts[name]['valid'],
"trafficleft": None, # in kb, -1 for unlimited
"maxtraffic": None,
"premium": True, #useful for free accounts
@@ -231,12 +231,12 @@ class Account(Base):
""" returns an valid account name and data"""
usable = []
for user, data in self.accounts.iteritems():
- if not data["valid"]: continue
+ if not data['valid']: continue
- if "time" in data["options"] and data["options"]["time"]:
+ if "time" in data['options'] and data['options']['time']:
time_data = ""
try:
- time_data = data["options"]["time"][0]
+ time_data = data['options']['time'][0]
start, end = time_data.split("-")
if not compare_time(start.split(":"), end.split(":")):
continue
@@ -245,10 +245,10 @@ class Account(Base):
if user in self.infos:
if "validuntil" in self.infos[user]:
- if self.infos[user]["validuntil"] > 0 and time() > self.infos[user]["validuntil"]:
+ if self.infos[user]['validuntil'] > 0 and time() > self.infos[user]['validuntil']:
continue
if "trafficleft" in self.infos[user]:
- if self.infos[user]["trafficleft"] == 0:
+ if self.infos[user]['trafficleft'] == 0:
continue
usable.append((user, data))
diff --git a/module/plugins/PluginManager.py b/module/plugins/PluginManager.py
index b290c2746..adfa5845e 100644
--- a/module/plugins/PluginManager.py
+++ b/module/plugins/PluginManager.py
@@ -65,14 +65,14 @@ class PluginManager:
f = open(join("userplugins", "__init__.py"), "wb")
f.close()
- self.plugins["crypter"] = self.crypterPlugins = self.parse("crypter", pattern=True)
- self.plugins["container"] = self.containerPlugins = self.parse("container", pattern=True)
- self.plugins["hoster"] = self.hosterPlugins = self.parse("hoster", pattern=True)
+ self.plugins['crypter'] = self.crypterPlugins = self.parse("crypter", pattern=True)
+ self.plugins['container'] = self.containerPlugins = self.parse("container", pattern=True)
+ self.plugins['hoster'] = self.hosterPlugins = self.parse("hoster", pattern=True)
- self.plugins["captcha"] = self.captchaPlugins = self.parse("captcha")
- self.plugins["accounts"] = self.accountPlugins = self.parse("accounts")
- self.plugins["hooks"] = self.hookPlugins = self.parse("hooks")
- self.plugins["internal"] = self.internalPlugins = self.parse("internal")
+ self.plugins['captcha'] = self.captchaPlugins = self.parse("captcha")
+ self.plugins['accounts'] = self.accountPlugins = self.parse("accounts")
+ self.plugins['hooks'] = self.hookPlugins = self.parse("hooks")
+ self.plugins['internal'] = self.internalPlugins = self.parse("internal")
self.log.debug("created index of plugins")
@@ -123,20 +123,20 @@ class PluginManager:
# home contains plugins from pyload root
if home and name in home:
- if home[name]["v"] >= version:
+ if home[name]['v'] >= version:
continue
if name in IGNORE or (folder, name) in IGNORE:
continue
plugins[name] = {}
- plugins[name]["v"] = version
+ plugins[name]['v'] = version
module = f.replace(".pyc", "").replace(".py", "")
# the plugin is loaded from user directory
- plugins[name]["user"] = True if home else False
- plugins[name]["name"] = module
+ plugins[name]['user'] = True if home else False
+ plugins[name]['name'] = module
if pattern:
pattern = self.PATTERN.findall(content)
@@ -146,10 +146,10 @@ class PluginManager:
else:
pattern = "^unmachtable$"
- plugins[name]["pattern"] = pattern
+ plugins[name]['pattern'] = pattern
try:
- plugins[name]["re"] = re.compile(pattern)
+ plugins[name]['re'] = re.compile(pattern)
except:
self.log.error(_("%s has a invalid pattern.") % name)
@@ -210,13 +210,13 @@ class PluginManager:
if type(url) not in (str, unicode, buffer): continue
found = False
- if last and last[1]["re"].match(url):
+ if last and last[1]['re'].match(url):
res.append((url, last[0]))
continue
for name, value in chain(self.crypterPlugins.iteritems(), self.hosterPlugins.iteritems(),
self.containerPlugins.iteritems()):
- if value["re"].match(url):
+ if value['re'].match(url):
res.append((url, name))
last = (name, value)
found = True
@@ -239,10 +239,10 @@ class PluginManager:
if not plugin:
self.log.warning("Plugin %s not found." % name)
- plugin = self.hosterPlugins["BasePlugin"]
+ plugin = self.hosterPlugins['BasePlugin']
if "new_module" in plugin and not original:
- return plugin["new_module"]
+ return plugin['new_module']
return self.loadModule(type, name)
@@ -251,7 +251,7 @@ class PluginManager:
plugin, type = self.findPlugin(name)
if "new_name" in plugin:
- return plugin["new_name"]
+ return plugin['new_name']
return name
@@ -263,11 +263,11 @@ class PluginManager:
"""
plugins = self.plugins[type]
if name in plugins:
- if "module" in plugins[name]: return plugins[name]["module"]
+ if "module" in plugins[name]: return plugins[name]['module']
try:
- module = __import__(self.ROOT + "%s.%s" % (type, plugins[name]["name"]), globals(), locals(),
- plugins[name]["name"])
- plugins[name]["module"] = module #cache import, maybe unneeded
+ module = __import__(self.ROOT + "%s.%s" % (type, plugins[name]['name']), globals(), locals(),
+ plugins[name]['name'])
+ plugins[name]['module'] = module #cache import, maybe unneeded
return module
except Exception, e:
self.log.error(_("Error importing %(name)s: %(msg)s") % {"name": name, "msg": str(e)})
@@ -295,10 +295,10 @@ class PluginManager:
if type in self.plugins and name in self.plugins[type]:
#userplugin is a newer version
- if not user and self.plugins[type][name]["user"]:
+ if not user and self.plugins[type][name]['user']:
return self
#imported from userdir, but pyloads is newer
- if user and not self.plugins[type][name]["user"]:
+ if user and not self.plugins[type][name]['user']:
return self
@@ -345,14 +345,14 @@ class PluginManager:
if plugin in self.plugins[type]:
if "module" in self.plugins[type][plugin]:
self.log.debug("Reloading %s" % plugin)
- reload(self.plugins[type][plugin]["module"])
+ reload(self.plugins[type][plugin]['module'])
#index creation
- self.plugins["crypter"] = self.crypterPlugins = self.parse("crypter", pattern=True)
- self.plugins["container"] = self.containerPlugins = self.parse("container", pattern=True)
- self.plugins["hoster"] = self.hosterPlugins = self.parse("hoster", pattern=True)
- self.plugins["captcha"] = self.captchaPlugins = self.parse("captcha")
- self.plugins["accounts"] = self.accountPlugins = self.parse("accounts")
+ self.plugins['crypter'] = self.crypterPlugins = self.parse("crypter", pattern=True)
+ self.plugins['container'] = self.containerPlugins = self.parse("container", pattern=True)
+ self.plugins['hoster'] = self.hosterPlugins = self.parse("hoster", pattern=True)
+ self.plugins['captcha'] = self.captchaPlugins = self.parse("captcha")
+ self.plugins['accounts'] = self.accountPlugins = self.parse("accounts")
if "accounts" in as_dict: #accounts needs to be reloaded
self.core.accountManager.initPlugins()
diff --git a/module/plugins/crypter/DuckCryptInfo.py b/module/plugins/crypter/DuckCryptInfo.py
index 7e13a62f0..456c13606 100644
--- a/module/plugins/crypter/DuckCryptInfo.py
+++ b/module/plugins/crypter/DuckCryptInfo.py
@@ -52,6 +52,6 @@ class DuckCryptInfo(Crypter):
def handleLink(self, url):
src = self.load(url)
soup = BeautifulSoup(src)
- self.urls = [soup.find("iframe")["src"]]
+ self.urls = [soup.find("iframe")['src']]
if not self.urls:
self.logDebug('no links m - (Plugin out of date?)')
diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py
index e41ae2e34..da8cad223 100644
--- a/module/plugins/hoster/UploadedTo.py
+++ b/module/plugins/hoster/UploadedTo.py
@@ -30,7 +30,7 @@ def getAPIData(urls):
for i, url in enumerate(urls):
id = getID(url)
- post["id_%s" % i] = id
+ post['id_%s' % i] = id
idMap[id] = url
for _ in xrange(5):