diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-07-14 20:59:01 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-07-14 20:59:01 +0200 |
commit | 853d29a0f12cdcb6c406b829a57439c7ea9b570d (patch) | |
tree | 047d94a11037617521c7a50130a6ead538c5daf7 | |
parent | fixed config on webif + show description (diff) | |
download | pyload-853d29a0f12cdcb6c406b829a57439c7ea9b570d.tar.xz |
has_key refractored, package name generator by Geek
27 files changed, 251 insertions, 98 deletions
diff --git a/module/Api.py b/module/Api.py index ffb88c6af..fd65dff92 100644 --- a/module/Api.py +++ b/module/Api.py @@ -64,7 +64,7 @@ class Api(Iface): items.append(item) section.items = items sections[sectionName] = section - if sub.has_key("outline"): + if "outline" in sub: section.outline = sub["outline"] return sections @@ -90,7 +90,6 @@ class Api(Iface): :param section: 'plugin' or 'core """ self.core.hookManager.dispatchEvent("configChanged", category, option, value, section) - print category, option, value, section if section == "core": self.core.config[category][option] = value @@ -727,7 +726,7 @@ class Api(Iface): :return: bool """ cont = self.core.hookManager.methods - return cont.has_key(plugin) and cont[plugin].has_key(func) + return plugin in cont and func in cont[plugin] def call(self, info): """Calls a service (a method in hook plugin). @@ -765,7 +764,7 @@ class Api(Iface): :return: dict of attr names mapped to value {"name": value} """ info = self.core.hookManager.getAllInfo() - if info.has_key(plugin): + if plugin in info: return info[plugin] else: return {} diff --git a/module/ConfigParser.py b/module/ConfigParser.py index aa8367fb4..2a3469b21 100644 --- a/module/ConfigParser.py +++ b/module/ConfigParser.py @@ -95,8 +95,8 @@ class ConfigParser: try: homeconf = self.parseConfig("pyload.conf") - if homeconf["remote"].has_key("username"): - if homeconf["remote"].has_key("password"): + if "username" in homeconf["remote"]: + if "password" in homeconf["remote"]: self.oldRemoteData = {"username": homeconf["remote"]["username"]["value"], "password": homeconf["remote"]["username"]["value"]} del homeconf["remote"]["password"] @@ -197,11 +197,11 @@ class ConfigParser: """sets the config values from a parsed config file to values in destination""" for section in config.iterkeys(): - if dest.has_key(section): + if section in dest: for option in config[section].iterkeys(): if option in ("desc", "outline"): continue - if dest[section].has_key(option): + if option in dest[section]: dest[section][option]["value"] = config[section][option]["value"] #else: @@ -320,7 +320,7 @@ class ConfigParser: #---------------------------------------------------------------------- def addPluginConfig(self, name, config, outline=""): """adds config options with tuples (name, type, desc, default)""" - if not self.plugin.has_key(name): + if name not in self.plugin: conf = {"desc": name, "outline": outline} self.plugin[name] = conf @@ -329,7 +329,7 @@ class ConfigParser: conf["outline"] = outline for item in config: - if conf.has_key(item[0]): + if item[0] in conf: conf[item[0]]["type"] = item[1] else: conf[item[0]] = { @@ -342,7 +342,7 @@ class ConfigParser: """ remove old plugins from config """ for name in IGNORE: - if self.plugin.has_key(name): + if name in self.plugin: del self.plugin[name] ######################################################################## diff --git a/module/HookManager.py b/module/HookManager.py index 94faaba6e..47e7d88fb 100644 --- a/module/HookManager.py +++ b/module/HookManager.py @@ -87,7 +87,7 @@ class HookManager: plugin = plugin.rpartition(".")[2] doc = doc.strip() if doc else "" - if self.methods.has_key(plugin): + if plugin in self.methods: self.methods[plugin][func] = doc else: self.methods[plugin] = {func: doc} @@ -234,23 +234,23 @@ class HookManager: def addEvent(self, event, func): """Adds an event listener for event name""" - if self.events.has_key(event): + if event in self.events: self.events[event].append(func) else: self.events[event] = [func] def removeEvent(self, event, func): """removes previously added event listener""" - if self.events.has_key(event): + if event in self.events: self.events[event].remove(func) def dispatchEvent(self, event, *args): """dispatches event with args""" - if self.events.has_key(event): + if event in self.events: for f in self.events[event]: try: f(*args) except Exception, e: self.log.debug("Error calling event handler %s: %s, %s, %s" % (event, f, args, str(e))) -
\ No newline at end of file + diff --git a/module/PluginThread.py b/module/PluginThread.py index ff5014f63..e0e3b17c9 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -94,7 +94,7 @@ class PluginThread(Thread): dump += "<ERROR WHILE PRINTING VALUE> "+ str(e) +"\n" - if self.m.core.config.plugin.has_key(pyfile.pluginname): + if pyfile.pluginname in self.m.core.config.plugin: dump += "\n\nCONFIG: \n\n" dump += pformat(self.m.core.config.plugin[pyfile.pluginname]) +"\n" @@ -436,7 +436,7 @@ class InfoThread(PluginThread): plugins = {} for url, plugin in self.data: - if plugins.has_key(plugin): + if plugin in plugins: plugins[plugin].append(url) else: plugins[plugin] = [url] diff --git a/module/ThreadManager.py b/module/ThreadManager.py index a0025879c..2c3d9af95 100644 --- a/module/ThreadManager.py +++ b/module/ThreadManager.py @@ -249,7 +249,7 @@ class ThreadManager: thread.put(job) else: #put job back - if not self.core.files.jobCache.has_key(occ): + if occ not in self.core.files.jobCache: self.core.files.jobCache[occ] = [] self.core.files.jobCache[occ].append(job.id) diff --git a/module/common/packagetools.py b/module/common/packagetools.py new file mode 100644 index 000000000..36f4d753f --- /dev/null +++ b/module/common/packagetools.py @@ -0,0 +1,154 @@ +#!/usr/bin/env python + +# JDownloader/src/jd/controlling/LinkGrabberPackager.java + +import re +from urlparse import urlparse + +def parseNames(files): + packs = {} + + endings = "\\.(3gp|7zip|7z|abr|ac3|aiff|aifc|aif|ai|au|avi|bin|bz2|cbr|cbz|ccf|cue|cvd|chm|dta|deb|divx|djvu|dlc|dmg|doc|docx|dot|eps|exe|ff|flv|f4v|gsd|gif|gz|iwd|iso|ipsw|java|jar|jpg|jpeg|jdeatme|load|mws|mw|m4v|m4a|mkv|mp2|mp3|mp4|mov|movie|mpeg|mpe|mpg|msi|msu|msp|nfo|npk|oga|ogg|ogv|otrkey|pkg|png|pdf|pptx|ppt|pps|ppz|pot|psd|qt|rmvb|rm|rar|ram|ra|rev|rnd|r\\d+|rpm|run|rsdf|rtf|sh(!?tml)|srt|snd|sfv|swf|tar|tif|tiff|ts|txt|viv|vivo|vob|wav|wmv|xla|xls|xpi|zeno|zip|z\\d+|_[_a-z]{2}|\\d+$)" + + pat0 = re.compile("(.*)(\\.|_|-)pa?r?t?\\.?[0-9]+.(rar|exe)$", re.I) + pat1 = re.compile("(.*)(\\.|_|-)part\\.?[0]*[1].(rar|exe)$", re.I) + pat3 = re.compile("(.*)\\.rar$", re.I) + pat4 = re.compile("(.*)\\.r\\d+$", re.I) + pat5 = re.compile("(.*)(\\.|_|-)\\d+$", re.I) + rarPats = [ pat0, pat1, pat3, pat4, pat5 ] + + pat6 = re.compile("(.*)\\.zip$", re.I) + pat7 = re.compile("(.*)\\.z\\d+$", re.I) + pat8 = re.compile("(?is).*\\.7z\\.[\\d]+$", re.I) + pat9 = re.compile("(.*)\\.a.$", re.I) + zipPats = [ pat6, pat7, pat8, pat9 ] + + pat10 = re.compile("(.*)\\._((_[a-z])|([a-z]{2}))(\\.|$)") + pat11 = re.compile("(.*)(\\.|_|-)[\\d]+(" + endings + "$)", re.I) + ffsjPats = [ pat10, pat11 ] + + pat12 = re.compile("(\\.?CD\\d+)", re.I) + pat13 = re.compile("(\\.?part\\d+)", re.I) + + pat14 = re.compile("(.+)[\\.\\-_]+$") + + pat17 = re.compile("(.+)\\.\\d+\\.xtm$") + + pat18 = re.compile("(.*)\\.isz$", re.I) + pat19 = re.compile("(.*)\\.i\\d{2}$", re.I) + iszPats = [ pat18, pat19 ] + + for file in files: + #check if a already existing package may be ok for this file + found = False + for name in packs: + if name in file: + packs[name].append(file) + found = True + break + + if found: continue + + # remove trailing / + name = file.rstrip('/') + + # extract last path part .. if there is a path + split = name.rsplit("/", 1) + if len(split) > 1: + name = split.pop(1) + + # unrar pattern + for pattern in rarPats: + r = pattern.search(name) + if r is not None: + name = r.group(1) + break + + # 7zip/zip and hjmerge pattern + for pattern in zipPats: + r = pattern.search(name) + if r is not None: + name = r.group(1) + break + + # isz pattern + for pattern in iszPats: + r = pattern.search(name) + if r is not None: + name = r.group(1) + break + + # xtremsplit pattern + r = pat17.search(name) + if r is not None: + name = r.group(1) + + # FFSJ pattern + for pattern in ffsjPats: + r = pattern.search(name) + if r is not None: + name = r.group(1) + break + + # remove part and cd pattern + r = pat12.search(name) + if r is not None: + name = name.replace(r.group(0), "") + + r = pat13.search(name) + if r is not None: + name = name.replace(r.group(0), "") + + # remove extension + index = name.rfind(".") + if index <= 0: + index = name.rfind("_") + if index > 0: + length = len(name) - index + if length <= 4: + name = name[:-length] + + # remove endings like . _ - + r = pat14.search(name) + if r is not None: + name = r.group(1) + + # replace . and _ with space + name = name.replace(".", " ") + name = name.replace("_", " ") + + name = name.strip() + + # checks if name could be a hash + if file.find("file/"+name) >= 0: + name = "" + + if file.find("files/"+name) >= 0: + name = "" + + r = re.search("^[0-9]+$", name, re.I) + if r is not None: + name = "" + + r = re.search("^[0-9a-z]+$", name, re.I) + if r is not None: + r1 = re.search("[0-9]+.+[0-9]", name) + r2 = re.search("[a-z]+.+[a-z]+", name, re.I) + if r1 is not None and r2 is not None: + name = "" + + # fallback: package by hoster + if not len(name): + name = urlparse(file).hostname + + # fallback : default name + if not name: + name = "unknown" + + # build mapping + if name in packs: + packs[name].append(file) + else: + packs[name] = [file] + + return packs
\ No newline at end of file diff --git a/module/database/FileDatabase.py b/module/database/FileDatabase.py index 3e2f37976..9b2a2c67e 100644 --- a/module/database/FileDatabase.py +++ b/module/database/FileDatabase.py @@ -99,7 +99,7 @@ class FileHandler: packs.update([(str(x.id), x.toDict()[x.id]) for x in self.packageCache.values() if x.queue == queue]) for key, value in data.iteritems(): - if packs.has_key(str(value["package"])): + if str(value["package"]) in packs: packs[str(value["package"])]["links"][key] = value return packs @@ -148,7 +148,7 @@ class FileHandler: p = self.getPackage(id) if not p: - if self.packageCache.has_key(id): del self.packageCache[id] + if id in self.packageCache: del self.packageCache[id] return e = RemoveEvent("pack", id, "collector" if not p.queue else "queue") @@ -164,7 +164,7 @@ class FileHandler: self.core.pullManager.addEvent(e) self.core.hookManager.dispatchEvent("packageDeleted", id) - if self.packageCache.has_key(id): + if id in self.packageCache: del self.packageCache[id] #---------------------------------------------------------------------- @@ -184,7 +184,7 @@ class FileHandler: if id in self.core.threadManager.processingIds(): self.cache[id].abortDownload() - if self.cache.has_key(id): + if id in self.cache: del self.cache[id] self.db.deleteLink(f) @@ -198,13 +198,13 @@ class FileHandler: #---------------------------------------------------------------------- def releaseLink(self, id): """removes pyfile from cache""" - if self.cache.has_key(id): + if id in self.cache: del self.cache[id] #---------------------------------------------------------------------- def releasePackage(self, id): """removes package from cache""" - if self.packageCache.has_key(id): + if id in self.packageCache: del self.packageCache[id] #---------------------------------------------------------------------- @@ -227,7 +227,7 @@ class FileHandler: def getPackage(self, id): """return package instance""" - if self.packageCache.has_key(id): + if id in self.packageCache: return self.packageCache[id] else: return self.db.getPackage(id) @@ -259,7 +259,7 @@ class FileHandler: #---------------------------------------------------------------------- def getFileData(self, id): """returns dict with file information""" - if self.cache.has_key(id): + if id in self.cache: return self.cache[id].toDbDict() return self.db.getLinkData(id) @@ -267,7 +267,7 @@ class FileHandler: #---------------------------------------------------------------------- def getFile(self, id): """returns pyfile instance""" - if self.cache.has_key(id): + if id in self.cache: return self.cache[id] else: return self.db.getFile(id) @@ -280,7 +280,7 @@ class FileHandler: #@TODO clean mess #@TODO improve selection of valid jobs - if self.jobCache.has_key(occ): + if occ in self.jobCache: if self.jobCache[occ]: id = self.jobCache[occ].pop() if id == "empty": @@ -319,7 +319,7 @@ class FileHandler: @lock def getDecryptJob(self): """return job for decrypting""" - if self.jobCache.has_key("decrypt"): + if "decrypt" in self.jobCache: return None plugins = self.core.pluginManager.crypterPlugins.keys() + self.core.pluginManager.containerPlugins.keys() @@ -385,7 +385,7 @@ class FileHandler: self.db.restartPackage(id) - if self.packageCache.has_key(id): + if id in self.packageCache: self.packageCache[id].setFinished = False e = UpdateEvent("pack", id, "collector" if not self.getPackage(id).queue else "queue") @@ -395,7 +395,7 @@ class FileHandler: @change def restartFile(self, id): """ restart file""" - if self.cache.has_key(id): + if id in self.cache: self.cache[id].status = 3 self.cache[id].name = self.cache[id].url self.cache[id].error = "" @@ -478,7 +478,7 @@ class FileHandler: if pyfile.order <= position and pyfile.order > f["order"]: pyfile.order -= 1 - if self.cache.has_key(id): + if id in self.cache: self.cache[id].order = position self.db.commit() @@ -533,7 +533,7 @@ class FileHandler: deleted = [] for id in old_packs.iterkeys(): - if not new_packs.has_key(str(id)): + if str(id) not in new_packs: deleted.append(id) self.deletePackage(int(id)) diff --git a/module/gui/CNLServer.py b/module/gui/CNLServer.py index 1c654c54e..5ecac8277 100644 --- a/module/gui/CNLServer.py +++ b/module/gui/CNLServer.py @@ -75,7 +75,7 @@ class CNLHandler(BaseHTTPRequestHandler): print "queue", queue def get_post(self, name, default=""): - if self.post.has_key(name): + if name in self.post: return self.post[name] else: return default @@ -223,4 +223,4 @@ if __name__ == "__main__": except KeyboardInterrupt: s.stop = True s.stopped = True - print "quiting.."
\ No newline at end of file + print "quiting.." diff --git a/module/gui/SettingsWidget.py b/module/gui/SettingsWidget.py index 8123fe139..0f8a9c88e 100644 --- a/module/gui/SettingsWidget.py +++ b/module/gui/SettingsWidget.py @@ -107,10 +107,10 @@ class SettingsWidget(QWidget): def reloadSection(self, sections, pdata): for k, section in enumerate(pdata): - if sections.has_key(k): + if k in sections: widget = sections[k] for item in section.items: - if widget.inputs.has_key(item.name): + if item.name in widget.inputs: i = widget.inputs[item.name] if item.type == "int": @@ -136,10 +136,10 @@ class SettingsWidget(QWidget): def saveSection(self, sections, pdata, sec="core"): for k, section in enumerate(pdata): - if sections.has_key(k): + if k in sections: widget = sections[k] for item in section.items: - if widget.inputs.has_key(item.name): + if item.name in widget.inputs: i = widget.inputs[item.name] if item.type == "int": diff --git a/module/network/CookieJar.py b/module/network/CookieJar.py index c9ae6cb6c..c05812334 100644 --- a/module/network/CookieJar.py +++ b/module/network/CookieJar.py @@ -34,7 +34,7 @@ class CookieJar(): return self.cookies.values() def parseCookie(self, name): - if self.cookies.has_key(name): + if name in self.cookies: return self.cookies[name].split("\t")[6] else: return None @@ -47,4 +47,4 @@ class CookieJar(): self.cookies[name] = s def clear(self): - self.cookies = {}
\ No newline at end of file + self.cookies = {} diff --git a/module/network/FTPBase.py b/module/network/FTPBase.py index ce4627d0c..d8fc5a20d 100644 --- a/module/network/FTPBase.py +++ b/module/network/FTPBase.py @@ -43,10 +43,10 @@ class FTPBase(FTP): proxytype = None proxy = None - if proxies.has_key("socks5"): + if "socks5" in proxies: proxytype = socks.PROXY_TYPE_SOCKS5 proxy = proxies["socks5"] - elif proxies.has_key("socks4"): + elif "socks4" in proxies: proxytype = socks.PROXY_TYPE_SOCKS4 proxy = proxies["socks4"] if proxytype: diff --git a/module/network/RequestFactory.py b/module/network/RequestFactory.py index 1a38ace43..774249a70 100644 --- a/module/network/RequestFactory.py +++ b/module/network/RequestFactory.py @@ -69,7 +69,7 @@ class RequestFactory(): return rep def getCookieJar(self, pluginName, account=None): - if self.cookiejars.has_key((pluginName, account)): + if (pluginName, account) in self.cookiejars: return self.cookiejars[(pluginName, account)] cj = CookieJar(pluginName, account) @@ -121,4 +121,4 @@ def getURL(*args, **kwargs): def getRequest(*args, **kwargs): - return pyreq.getHTTPRequest()
\ No newline at end of file + return pyreq.getHTTPRequest() diff --git a/module/plugins/Account.py b/module/plugins/Account.py index adee39559..86d4b8335 100644 --- a/module/plugins/Account.py +++ b/module/plugins/Account.py @@ -93,7 +93,7 @@ class Account(): if req: req.cj.clear() req.close() - if self.infos.has_key(user): + if user in self.infos: del self.infos[user] #delete old information self._login(user, self.accounts[user]) @@ -107,7 +107,7 @@ class Account(): def updateAccounts(self, user, password=None, options={}): """ updates account and return true if anything changed """ - if self.accounts.has_key(user): + if user in self.accounts: self.accounts[user]["valid"] = True #do not remove or accounts will not login if password: self.accounts[user]["password"] = password @@ -123,11 +123,11 @@ class Account(): return True def removeAccount(self, user): - if self.accounts.has_key(user): + if user in self.accounts: del self.accounts[user] - if self.infos.has_key(user): + if user in self.infos: del self.infos[user] - if self.timestamps.has_key(user): + if user in self.timestamps: del self.timestamps[user] def getAccountInfo(self, name, force=False): @@ -140,7 +140,7 @@ class Account(): """ data = Account.loadAccountInfo(self, name) - if force or not self.infos.has_key(name): + if force or name not in self.infos: self.logDebug("Get Account Info for %s" % name) req = self.getAccountRequest(name) @@ -157,7 +157,7 @@ class Account(): infos["timestamp"] = time() self.infos[name] = infos - elif self.infos[name].has_key("timestamp") and self.infos[name][ + elif "timestamp" in self.infos[name] and self.infos[name][ "timestamp"] + self.info_threshold * 60 < time(): self.scheduleRefresh(name) @@ -219,7 +219,7 @@ class Account(): for user, data in self.accounts.iteritems(): if not data["valid"]: continue - if data["options"].has_key("time") and data["options"]["time"]: + if "time" in data["options"] and data["options"]["time"]: time_data = "" try: time_data = data["options"]["time"][0] @@ -229,11 +229,11 @@ class Account(): except: self.logWarning(_("Your Time %s has wrong format, use: 1:22-3:44") % time_data) - if self.infos.has_key(user): - if self.infos[user].has_key("validuntil"): + if user in self.infos: + if "validuntil" in self.infos[user]: if self.infos[user]["validuntil"] > 0 and time() > self.infos[user]["validuntil"]: continue - if self.infos[user].has_key("trafficleft"): + if "trafficleft" in self.infos[user]: if self.infos[user]["trafficleft"] == 0: continue @@ -252,14 +252,14 @@ class Account(): raise WrongPassword def empty(self, user): - if self.infos.has_key(user): + if user in self.infos: self.logWarning(_("Account %s has not enough traffic, checking again in 30min") % user) self.infos[user].update({"trafficleft": 0}) self.scheduleRefresh(user, 30 * 60) def expired(self, user): - if self.infos.has_key(user): + if user in self.infos: self.logWarning(_("Account %s is expired, checking again in 1h") % user) self.infos[user].update({"validuntil": time() - 1}) @@ -272,7 +272,7 @@ class Account(): def checkLogin(self, user): """ checks if user is still logged in """ - if self.timestamps.has_key(user): + if user in self.timestamps: if self.timestamps[user] + self.login_timeout * 60 < time(): self.logDebug("Reached login timeout for %s" % user) self.relogin(user) diff --git a/module/plugins/AccountManager.py b/module/plugins/AccountManager.py index 94af7cd82..4b218d8f8 100644 --- a/module/plugins/AccountManager.py +++ b/module/plugins/AccountManager.py @@ -49,8 +49,8 @@ class AccountManager(): #---------------------------------------------------------------------- def getAccountPlugin(self, plugin): """get account instance for plugin or None if anonymous""" - if self.accounts.has_key(plugin): - if not self.plugins.has_key(plugin): + if plugin in self.accounts: + if plugin not in self.plugins: self.plugins[plugin] = self.core.pluginManager.getAccountPlugin(plugin)(self, self.accounts[plugin]) return self.plugins[plugin] @@ -143,7 +143,7 @@ class AccountManager(): @lock def updateAccount(self, plugin , user, password=None, options={}): """add or update account""" - if self.accounts.has_key(plugin): + if plugin in self.accounts: p = self.getAccountPlugin(plugin) updated = p.updateAccounts(user, password, options) #since accounts is a ref in plugin self.accounts doesnt need to be updated here @@ -155,7 +155,7 @@ class AccountManager(): def removeAccount(self, plugin, user): """remove account""" - if self.accounts.has_key(plugin): + if plugin in self.accounts: p = self.getAccountPlugin(plugin) p.removeAccount(user) diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index ec8a0151a..c1b6684af 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -300,7 +300,7 @@ class Plugin(object): temp_file.write(img) temp_file.close() - has_plugin = self.core.pluginManager.captchaPlugins.has_key(self.__name__) + has_plugin = self.__name__ in self.core.pluginManager.captchaPlugins if self.core.captcha: Ocr = self.core.pluginManager.getCaptchaPlugin(self.__name__) @@ -398,7 +398,7 @@ class Plugin(object): key = key.lower().strip() value = value.strip() - if header.has_key(key): + if key in header: if type(header[key]) == list: header[key].append(value) else: diff --git a/module/plugins/PluginManager.py b/module/plugins/PluginManager.py index 17405ce8b..333f9e247 100644 --- a/module/plugins/PluginManager.py +++ b/module/plugins/PluginManager.py @@ -130,7 +130,7 @@ class PluginManager(): else: version = 0 - if home and home.has_key(name): + if home and name in home: if home[name]["v"] >= version: continue @@ -223,17 +223,17 @@ class PluginManager(): """return plugin module from hoster|decrypter|container""" plugin = None - if self.containerPlugins.has_key(name): + if name in self.containerPlugins: plugin = self.containerPlugins[name] - if self.crypterPlugins.has_key(name): + if name in self.crypterPlugins: plugin = self.crypterPlugins[name] - if self.hosterPlugins.has_key(name): + if name in self.hosterPlugins: plugin = self.hosterPlugins[name] - if plugin.has_key("new_module") and not original: + if "new_module" in plugin and not original: return plugin["new_module"] - if plugin.has_key("module"): + if "module" in plugin: return plugin["module"] plugin["module"] = __import__(plugin["path"], globals(), locals(), [plugin["name"]], -1) @@ -243,14 +243,14 @@ class PluginManager(): def getPluginName(self, name): """ used to obtain new name if other plugin was injected""" plugin = None - if self.containerPlugins.has_key(name): + if name in self.containerPlugins: plugin = self.containerPlugins[name] - if self.crypterPlugins.has_key(name): + if name in self.crypterPlugins: plugin = self.crypterPlugins[name] - if self.hosterPlugins.has_key(name): + if name in self.hosterPlugins: plugin = self.hosterPlugins[name] - if plugin.has_key("new_name"): + if "new_name" in plugin: return plugin["new_name"] return name @@ -259,9 +259,9 @@ class PluginManager(): def getCaptchaPlugin(self, name): """return captcha modul if existent""" - if self.captchaPlugins.has_key(name): + if name in self.captchaPlugins: plugin = self.captchaPlugins[name] - if plugin.has_key("class"): + if "class" in plugin: return plugin["class"] module = __import__(plugin["path"], globals(), locals(), [plugin["name"]], -1) @@ -274,9 +274,9 @@ class PluginManager(): def getAccountPlugin(self, name): """return account class if existent""" - if self.accountPlugins.has_key(name): + if name in self.accountPlugins: plugin = self.accountPlugins[name] - if plugin.has_key("class"): + if "class" in plugin: return plugin["class"] module = __import__(plugin["path"], globals(), locals(), [plugin["name"]], -1) @@ -302,7 +302,7 @@ class PluginManager(): classes = [] for name, value in self.hookPlugins.iteritems(): - if value.has_key("class"): + if "class" in value: classes.append(value["class"]) continue diff --git a/module/plugins/crypter/SerienjunkiesOrg.py b/module/plugins/crypter/SerienjunkiesOrg.py index 21afc88e8..5b6295fe7 100644 --- a/module/plugins/crypter/SerienjunkiesOrg.py +++ b/module/plugins/crypter/SerienjunkiesOrg.py @@ -72,7 +72,7 @@ class SerienjunkiesOrg(Crypter): n = unescape(v.string) n = n.strip() n = re.sub(r"^([:]?)(.*?)([:]?)$", r'\2', n) - if not opts.has_key(n.strip()): + if n.strip() not in opts: continue val = v.nextSibling if not val: @@ -99,7 +99,7 @@ class SerienjunkiesOrg(Crypter): linkgroups = {} for link in linklist: key = re.sub("^http://download\.serienjunkies\.org/f-.*?/(.{2})_", "", link) - if not linkgroups.has_key(key): + if key not in linkgroups: linkgroups[key] = [] linkgroups[key].append(link) for group in linkgroups.values(): diff --git a/module/plugins/hooks/CaptchaTrader.py b/module/plugins/hooks/CaptchaTrader.py index c41ed9f97..a0e8a0453 100644 --- a/module/plugins/hooks/CaptchaTrader.py +++ b/module/plugins/hooks/CaptchaTrader.py @@ -132,12 +132,12 @@ class CaptchaTrader(Hook): self.logInfo(_("Your CaptchaTrader Account has not enough credits")) def captchaCorrect(self, task): - if task.data.has_key("ticket"): + if "ticket" in task.data: ticket = task.data["ticket"] self.respond(ticket, True) def captchaInvalid(self, task): - if task.data.has_key("ticket"): + if "ticket" in task.data: ticket = task.data["ticket"] self.respond(ticket, False) diff --git a/module/plugins/hooks/Ev0InFetcher.py b/module/plugins/hooks/Ev0InFetcher.py index 5eb4e09c1..c7191cd4e 100644 --- a/module/plugins/hooks/Ev0InFetcher.py +++ b/module/plugins/hooks/Ev0InFetcher.py @@ -42,7 +42,7 @@ class Ev0InFetcher(Hook, PluginStorage): sortedLinks = {} for url, hoster in results: - if not sortedLinks.has_key(hoster): + if hoster not in sortedLinks: sortedLinks[hoster] = [] sortedLinks[hoster].append(url) diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index dc7bd3b49..f15148538 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -71,7 +71,7 @@ class Interface(object): self.history = {} def lastPluginAccess(self, pluginName, account): - if self.history.has_key((pluginName, account)): + if (pluginName, account) in self.history: return self.history[(pluginName, account)] return 0 diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index 2c8bf1259..59035926a 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -48,7 +48,7 @@ class RealdebridCom(Hook): for hoster in self.getHostersCached(): name = removeChars(hoster.lower(), "-.") - if pluginMap.has_key(name): + if name in pluginMap: supported.append(pluginMap[name]) else: new_supported.append(hoster) diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 324ef9b91..48b0fd826 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -60,7 +60,7 @@ class RehostTo(Hook): for hoster in self.getHostersCached(): name = removeChars(hoster.lower(), "-.") - if pluginMap.has_key(name): + if name in pluginMap: supported.append(pluginMap[name]) else: new_supported.append(hoster) @@ -81,4 +81,4 @@ class RehostTo(Hook): dict = self.core.pluginManager.hosterPlugins["RehostTo"] dict["pattern"] = regexp - dict["re"] = re.compile(regexp)
\ No newline at end of file + dict["re"] = re.compile(regexp) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index dc8eafbb8..7f4d57947 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -106,7 +106,7 @@ class UpdateManager(Hook): plugins = getattr(self.core.pluginManager, "%sPlugins" % type) - if plugins.has_key(tmp_name): + if tmp_name in plugins: if float(plugins[tmp_name]["v"]) >= float(version): continue diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index c698800ec..94f6e8320 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -42,7 +42,7 @@ def getAPIData(urls): for line in api.splitlines(): data = line.split(",") - if idMap.has_key(data[1]): + if data[1] in idMap: result[data[1]] = (data[0], data[2], data[4], data[3], idMap[data[1]]) return result @@ -94,7 +94,7 @@ class UploadedTo(Hoster): api = getAPIData([pyfile.url]) - if not len(api) or not api.has_key(self.fileID): + if not len(api) or self.fileID not in api: self.offline() self.data = api[self.fileID] diff --git a/module/remote/thriftbackend/Processor.py b/module/remote/thriftbackend/Processor.py index 8ea45f109..a8fc94298 100644 --- a/module/remote/thriftbackend/Processor.py +++ b/module/remote/thriftbackend/Processor.py @@ -9,11 +9,11 @@ class Processor(Pyload.Processor): def process(self, iprot, oprot): trans = oprot.trans - if not self.authenticated.has_key(trans): + if trans not in self.authenticated: self.authenticated[trans] = False oldclose = trans.close def wrap(): - if self.authenticated.has_key(self): + if self in self.authenticated: del self.authenticated[trans] oldclose() trans.close = wrap diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py index 0131e888f..22003da43 100644 --- a/module/web/pyload_app.py +++ b/module/web/pyload_app.py @@ -307,13 +307,13 @@ def config(): t = time.localtime(data.validuntil) data.validuntil = time.strftime("%d.%m.%Y", t) - if data.options.has_key("time"): + if "time" in data.options: try: data.options["time"] = data.options["time"][0] except: data.options["time"] = "0:00-0:00" - if data.options.has_key("limitDL"): + if "limitDL" in data.options: data.options["limitdl"] = data.options["limitDL"][0] else: data.options["limitdl"] = "0" diff --git a/module/web/utils.py b/module/web/utils.py index 1455c3c01..b99736216 100644 --- a/module/web/utils.py +++ b/module/web/utils.py @@ -92,7 +92,7 @@ def login_required(perm=None): if s.get("name", None) and s.get("authenticated", False): if perm: perms = parse_permissions(s) - if not perms.has_key(perm) or not perms[perm]: + if perm not in perms or not perms[perm]: if request.headers.get('X-Requested-With') == 'XMLHttpRequest': return HTTPError(403, "Forbidden") else: |