From 4cbd40dffffe177b2cb438c5f3d9bf0d16932036 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 11 Apr 2014 11:58:46 +0200 Subject: Replace range with xrange Merges vuolter/pyload@a50c8ff (cherry picked from commit 0424017acbd34e14a33002e130c618c5dd6df222) Conflicts: module/plugins/PluginManager.py module/plugins/captcha/LinksaveIn.py --- pyload/plugins/accounts/BayfilesCom.py | 2 +- pyload/plugins/accounts/FilecloudIo.py | 2 +- pyload/plugins/addons/Captcha9kw.py | 2 +- pyload/plugins/addons/CaptchaBrotherhood.py | 2 +- pyload/plugins/addons/DeathByCaptcha.py | 2 +- pyload/plugins/crypter/FilefactoryComFolder.py | 2 +- pyload/plugins/crypter/LixIn.py | 2 +- pyload/plugins/crypter/SafelinkingNet.py | 2 +- pyload/plugins/crypter/StealthTo.py | 2 +- pyload/plugins/crypter/UlozToFolder.py | 2 +- pyload/plugins/hoster/BasePlugin.py | 4 ++-- pyload/plugins/hoster/BezvadataCz.py | 2 +- pyload/plugins/hoster/BitshareCom.py | 2 +- pyload/plugins/hoster/CzshareCom.py | 2 +- pyload/plugins/hoster/DataportCz.py | 2 +- pyload/plugins/hoster/DateiTo.py | 2 +- pyload/plugins/hoster/DepositfilesCom.py | 2 +- pyload/plugins/hoster/EgoFilesCom.py | 2 +- pyload/plugins/hoster/FilecloudIo.py | 2 +- pyload/plugins/hoster/FilepostCom.py | 8 ++++---- pyload/plugins/hoster/FilerNet.py | 2 +- pyload/plugins/hoster/FileserveCom.py | 2 +- pyload/plugins/hoster/GigapetaCom.py | 2 +- pyload/plugins/hoster/IfileIt.py | 2 +- pyload/plugins/hoster/IfolderRu.py | 2 +- pyload/plugins/hoster/Keep2shareCC.py | 2 +- pyload/plugins/hoster/LuckyShareNet.py | 2 +- pyload/plugins/hoster/MediafireCom.py | 4 ++-- pyload/plugins/hoster/MegasharesCom.py | 2 +- pyload/plugins/hoster/NarodRu.py | 2 +- pyload/plugins/hoster/NetloadIn.py | 2 +- pyload/plugins/hoster/RyushareCom.py | 2 +- pyload/plugins/hoster/SendspaceCom.py | 2 +- pyload/plugins/hoster/StreamcloudEu.py | 4 ++-- pyload/plugins/hoster/TurbobitNet.py | 4 ++-- pyload/plugins/hoster/UnibytesCom.py | 2 +- pyload/plugins/hoster/UnrestrictLi.py | 2 +- pyload/plugins/hoster/UploadedTo.py | 4 ++-- pyload/plugins/hoster/UploadheroCom.py | 2 +- pyload/plugins/hoster/Xdcc.py | 2 +- pyload/plugins/hoster/ZeveraCom.py | 2 +- pyload/plugins/hoster/ZippyshareCom.py | 2 +- pyload/plugins/internal/OCR.py | 2 +- pyload/plugins/internal/SimpleCrypter.py | 2 +- 44 files changed, 52 insertions(+), 52 deletions(-) diff --git a/pyload/plugins/accounts/BayfilesCom.py b/pyload/plugins/accounts/BayfilesCom.py index 0a9e11ec8..d9330158a 100644 --- a/pyload/plugins/accounts/BayfilesCom.py +++ b/pyload/plugins/accounts/BayfilesCom.py @@ -32,7 +32,7 @@ class BayfilesCom(Account): __author_mail__ = "zoidberg@mujmail.cz" def loadAccountInfo(self, user, req): - for i in range(2): + for _ in xrange(2): response = json_loads(req.load("http://api.bayfiles.com/v1/account/info")) self.logDebug(response) if not response["error"]: diff --git a/pyload/plugins/accounts/FilecloudIo.py b/pyload/plugins/accounts/FilecloudIo.py index 93ae02006..15e1d90be 100644 --- a/pyload/plugins/accounts/FilecloudIo.py +++ b/pyload/plugins/accounts/FilecloudIo.py @@ -31,7 +31,7 @@ class FilecloudIo(Account): def loadAccountInfo(self, user, req): # It looks like the first API request always fails, so we retry 5 times, it should work on the second try - for _ in range(5): + for _ in xrange(5): rep = req.load("https://secure.filecloud.io/api-fetch_apikey.api", post={"username": user, "password": self.accounts[user]['password']}) rep = json_loads(rep) diff --git a/pyload/plugins/addons/Captcha9kw.py b/pyload/plugins/addons/Captcha9kw.py index 3a1b9fe8f..b2895a357 100755 --- a/pyload/plugins/addons/Captcha9kw.py +++ b/pyload/plugins/addons/Captcha9kw.py @@ -92,7 +92,7 @@ class Captcha9kw(Hook): if response.isdigit(): self.logInfo(_("New CaptchaID from upload: %s : %s") % (response, task.captchaFile)) - for i in range(1, 100, 1): + for _ in xrange(1, 100, 1): response2 = getURL(self.API_URL, get={"apikey": self.getConfig("passkey"), "id": response, "pyload": "1", "source": "pyload", "action": "usercaptchacorrectdata"}) diff --git a/pyload/plugins/addons/CaptchaBrotherhood.py b/pyload/plugins/addons/CaptchaBrotherhood.py index 9a4efaa95..0901925c0 100644 --- a/pyload/plugins/addons/CaptchaBrotherhood.py +++ b/pyload/plugins/addons/CaptchaBrotherhood.py @@ -112,7 +112,7 @@ class CaptchaBrotherhood(Hook): ticket = response[3:] - for i in range(15): + for _ in xrange(15): sleep(5) response = self.get_api("askCaptchaResult", ticket) if response.startswith("OK-answered"): diff --git a/pyload/plugins/addons/DeathByCaptcha.py b/pyload/plugins/addons/DeathByCaptcha.py index 9e466e193..334fd8467 100644 --- a/pyload/plugins/addons/DeathByCaptcha.py +++ b/pyload/plugins/addons/DeathByCaptcha.py @@ -147,7 +147,7 @@ class DeathByCaptcha(Hook): raise DeathByCaptchaException(response) ticket = response['captcha'] - for i in range(24): + for _ in xrange(24): sleep(5) response = self.call_api("captcha/%d" % ticket, False) if response['text'] and response['is_correct']: diff --git a/pyload/plugins/crypter/FilefactoryComFolder.py b/pyload/plugins/crypter/FilefactoryComFolder.py index 4f7ed6281..6a1ffea2c 100644 --- a/pyload/plugins/crypter/FilefactoryComFolder.py +++ b/pyload/plugins/crypter/FilefactoryComFolder.py @@ -23,7 +23,7 @@ class FilefactoryComFolder(Crypter): html = self.load(url_base) new_links = [] - for i in range(1, 100): + for i in xrange(1, 100): self.logInfo("Fetching links from page %i" % i) found = re.search(self.FOLDER_PATTERN, html, re.DOTALL) if found is None: self.fail("Parse error (FOLDER)") diff --git a/pyload/plugins/crypter/LixIn.py b/pyload/plugins/crypter/LixIn.py index 601490ddd..f180e5677 100644 --- a/pyload/plugins/crypter/LixIn.py +++ b/pyload/plugins/crypter/LixIn.py @@ -37,7 +37,7 @@ class LixIn(Crypter): matches = re.search(self.CAPTCHA_PATTERN, self.html) if matches: - for i in range(5): + for _ in xrange(5): matches = re.search(self.CAPTCHA_PATTERN, self.html) if matches: self.logDebug("trying captcha") diff --git a/pyload/plugins/crypter/SafelinkingNet.py b/pyload/plugins/crypter/SafelinkingNet.py index 458a1f337..e0a3e14af 100644 --- a/pyload/plugins/crypter/SafelinkingNet.py +++ b/pyload/plugins/crypter/SafelinkingNet.py @@ -43,7 +43,7 @@ class SafelinkingNet(Crypter): postData["link-password"] = password if "altcaptcha" in self.html: - for i in xrange(5): + for _ in xrange(5): m = re.search(self.__Solvemedia_pattern__, self.html) if m: captchaKey = m.group(1) diff --git a/pyload/plugins/crypter/StealthTo.py b/pyload/plugins/crypter/StealthTo.py index 8a73cdfbb..713c9376c 100644 --- a/pyload/plugins/crypter/StealthTo.py +++ b/pyload/plugins/crypter/StealthTo.py @@ -38,7 +38,7 @@ class StealthTo(Crypter): if re.search(r"name=\"id\"", input[0]): ids.append(re.search(r"value=\"([^\"]+)", input[0]).group(1)) - for i in range(0, len(ids)): + for i in xrange(0, len(ids)): self.req.load(url + "/web", post={"authenticity_token": ats[i], "id": str(ids[i]), "link": ("download_" + str(ids[i]))}, cookies=True) diff --git a/pyload/plugins/crypter/UlozToFolder.py b/pyload/plugins/crypter/UlozToFolder.py index d42605acc..ba049d3b9 100644 --- a/pyload/plugins/crypter/UlozToFolder.py +++ b/pyload/plugins/crypter/UlozToFolder.py @@ -21,7 +21,7 @@ class UlozToFolder(Crypter): html = self.load(self.pyfile.url) new_links = [] - for i in range(1, 100): + for i in xrange(1, 100): self.logInfo("Fetching links from page %i" % i) found = re.search(self.FOLDER_PATTERN, html, re.DOTALL) if found is None: diff --git a/pyload/plugins/hoster/BasePlugin.py b/pyload/plugins/hoster/BasePlugin.py index 7ea1dba17..2b8f7c848 100644 --- a/pyload/plugins/hoster/BasePlugin.py +++ b/pyload/plugins/hoster/BasePlugin.py @@ -38,7 +38,7 @@ class BasePlugin(Hoster): # self.decryptCaptcha("http://localhost:9000/captcha") # # if pyfile.url == "79": - # self.core.api.addPackage("test", [str(i) for i in range(80)], 1) + # self.core.api.addPackage("test", [str(i) for i in xrange(80)], 1) # # return if pyfile.url.startswith("http"): @@ -74,7 +74,7 @@ class BasePlugin(Hoster): def downloadFile(self, pyfile): url = pyfile.url - for i in range(5): + for _ in xrange(5): header = self.load(url, just_header=True) # self.load does not raise a BadHeader on 404 responses, do it here diff --git a/pyload/plugins/hoster/BezvadataCz.py b/pyload/plugins/hoster/BezvadataCz.py index 831eca195..e6cd4c809 100644 --- a/pyload/plugins/hoster/BezvadataCz.py +++ b/pyload/plugins/hoster/BezvadataCz.py @@ -47,7 +47,7 @@ class BezvadataCz(SimpleHoster): #captcha form self.html = self.load(url) self.checkErrors() - for i in range(5): + for _ in xrange(5): action, inputs = self.parseHtmlForm('frm-stahnoutFreeForm') if not inputs: self.parseError("FreeForm") diff --git a/pyload/plugins/hoster/BitshareCom.py b/pyload/plugins/hoster/BitshareCom.py index 389401feb..d48329c0d 100644 --- a/pyload/plugins/hoster/BitshareCom.py +++ b/pyload/plugins/hoster/BitshareCom.py @@ -105,7 +105,7 @@ class BitshareCom(SimpleHoster): self.logDebug("File is captcha protected") id = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1) # Try up to 3 times - for i in range(3): + for i in xrange(3): self.logDebug("Resolving ReCaptcha with key [%s], round %d" % (id, i + 1)) recaptcha = ReCaptcha(self) challenge, code = recaptcha.challenge(id) diff --git a/pyload/plugins/hoster/CzshareCom.py b/pyload/plugins/hoster/CzshareCom.py index 57d110608..763bbbd29 100644 --- a/pyload/plugins/hoster/CzshareCom.py +++ b/pyload/plugins/hoster/CzshareCom.py @@ -108,7 +108,7 @@ class CzshareCom(SimpleHoster): # get and decrypt captcha captcha_url = 'http://czshare.com/captcha.php' - for i in range(5): + for _ in xrange(5): inputs['captchastring2'] = self.decryptCaptcha(captcha_url) self.html = self.load(parsed_url, cookies=True, post=inputs, decode=True) if u"
  • Zadaný ověřovací kód nesouhlasí!
  • " in self.html: diff --git a/pyload/plugins/hoster/DataportCz.py b/pyload/plugins/hoster/DataportCz.py index 374c7a469..58ac39c73 100644 --- a/pyload/plugins/hoster/DataportCz.py +++ b/pyload/plugins/hoster/DataportCz.py @@ -39,7 +39,7 @@ class DataportCz(SimpleHoster): def handleFree(self): captchas = {"1": "jkeG", "2": "hMJQ", "3": "vmEK", "4": "ePQM", "5": "blBd"} - for i in range(60): + for _ in xrange(60): action, inputs = self.parseHtmlForm('free_download_form') self.logDebug(action, inputs) if not action or not inputs: diff --git a/pyload/plugins/hoster/DateiTo.py b/pyload/plugins/hoster/DateiTo.py index 11b47240a..c08b775a4 100644 --- a/pyload/plugins/hoster/DateiTo.py +++ b/pyload/plugins/hoster/DateiTo.py @@ -45,7 +45,7 @@ class DateiTo(SimpleHoster): recaptcha = ReCaptcha(self) - for i in range(10): + for _ in xrange(10): self.logDebug("URL", url, "POST", data) self.html = self.load(url, post=data) self.checkErrors() diff --git a/pyload/plugins/hoster/DepositfilesCom.py b/pyload/plugins/hoster/DepositfilesCom.py index c15dbb5c7..20d88f8a0 100644 --- a/pyload/plugins/hoster/DepositfilesCom.py +++ b/pyload/plugins/hoster/DepositfilesCom.py @@ -71,7 +71,7 @@ class DepositfilesCom(SimpleHoster): self.wait() recaptcha = ReCaptcha(self) - for i in range(5): + for _ in xrange(5): self.html = self.load("http://depositfiles.com/get_file.php", get=params) if '' def handleFree(self): - for i in range(5): + for _ in xrange(5): self.html = self.load('http://narod.ru/disk/getcapchaxml/?rnd=%d' % int(random() * 777)) found = re.search(self.CAPTCHA_PATTERN, self.html) if not found: diff --git a/pyload/plugins/hoster/NetloadIn.py b/pyload/plugins/hoster/NetloadIn.py index d34e8b6af..f09565001 100644 --- a/pyload/plugins/hoster/NetloadIn.py +++ b/pyload/plugins/hoster/NetloadIn.py @@ -159,7 +159,7 @@ class NetloadIn(Hoster): self.pyfile.name = name captchawaited = False - for i in range(10): + for i in xrange(10): if not page: page = self.load(self.url) diff --git a/pyload/plugins/hoster/RyushareCom.py b/pyload/plugins/hoster/RyushareCom.py index 92844b360..4d3e9b7f3 100644 --- a/pyload/plugins/hoster/RyushareCom.py +++ b/pyload/plugins/hoster/RyushareCom.py @@ -53,7 +53,7 @@ class RyushareCom(XFileSharingPro): if retry: self.retry() - for i in xrange(5): + for _ in xrange(5): m = re.search(self.SOLVEMEDIA_PATTERN, self.html) if not m: self.parseError("Error parsing captcha") diff --git a/pyload/plugins/hoster/SendspaceCom.py b/pyload/plugins/hoster/SendspaceCom.py index 4efffb784..9f08003ed 100644 --- a/pyload/plugins/hoster/SendspaceCom.py +++ b/pyload/plugins/hoster/SendspaceCom.py @@ -38,7 +38,7 @@ class SendspaceCom(SimpleHoster): def handleFree(self): params = {} - for i in range(3): + for _ in xrange(3): found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) if found: if 'captcha_hash' in params: diff --git a/pyload/plugins/hoster/StreamcloudEu.py b/pyload/plugins/hoster/StreamcloudEu.py index 670962ad5..a61588508 100644 --- a/pyload/plugins/hoster/StreamcloudEu.py +++ b/pyload/plugins/hoster/StreamcloudEu.py @@ -27,7 +27,7 @@ class StreamcloudEu(XFileSharingPro): if found: return found.group(1) - for i in range(5): + for i in xrange(5): self.logDebug("Getting download link: #%d" % i) data = self.getPostParameters() httpRequest = HTTPRequest(options=self.req.options) @@ -53,7 +53,7 @@ class StreamcloudEu(XFileSharingPro): return found.group(1) def getPostParameters(self): - for i in range(3): + for _ in xrange(3): if not self.errmsg: self.checkErrors() diff --git a/pyload/plugins/hoster/TurbobitNet.py b/pyload/plugins/hoster/TurbobitNet.py index f33775f80..5bed39712 100644 --- a/pyload/plugins/hoster/TurbobitNet.py +++ b/pyload/plugins/hoster/TurbobitNet.py @@ -70,7 +70,7 @@ class TurbobitNet(SimpleHoster): self.downloadFile() def solveCaptcha(self): - for i in range(5): + for _ in xrange(5): found = re.search(self.LIMIT_WAIT_PATTERN, self.html) if found: wait_time = int(found.group(1)) @@ -135,7 +135,7 @@ class TurbobitNet(SimpleHoster): found = re.search("(/\w+/timeout\.js\?\w+=)([^\"\'<>]+)", self.html) url = "http://turbobit.net%s%s" % (found.groups() if found else ( - '/files/timeout.js?ver=', ''.join(random.choice('0123456789ABCDEF') for x in range(32)))) + '/files/timeout.js?ver=', ''.join(random.choice('0123456789ABCDEF') for _ in xrange(32)))) fun = self.load(url) self.setWait(65, False) diff --git a/pyload/plugins/hoster/UnibytesCom.py b/pyload/plugins/hoster/UnibytesCom.py index eb1132e99..c7deba89c 100644 --- a/pyload/plugins/hoster/UnibytesCom.py +++ b/pyload/plugins/hoster/UnibytesCom.py @@ -40,7 +40,7 @@ class UnibytesCom(SimpleHoster): action, post_data = self.parseHtmlForm('id="startForm"') self.req.http.c.setopt(FOLLOWLOCATION, 0) - for i in range(8): + for _ in xrange(8): self.logDebug(action, post_data) self.html = self.load(self.DOMAIN + action, post=post_data) diff --git a/pyload/plugins/hoster/UnrestrictLi.py b/pyload/plugins/hoster/UnrestrictLi.py index bac2ed791..622d43674 100644 --- a/pyload/plugins/hoster/UnrestrictLi.py +++ b/pyload/plugins/hoster/UnrestrictLi.py @@ -54,7 +54,7 @@ class UnrestrictLi(Hoster): self.fail("No Unrestrict.li account provided") else: self.logDebug("Old URL: %s" % pyfile.url) - for i in xrange(5): + for _ in xrange(5): page = self.req.load('https://unrestrict.li/unrestrict.php', post={'link': pyfile.url, 'domain': 'long'}) self.logDebug("JSON data: " + page) diff --git a/pyload/plugins/hoster/UploadedTo.py b/pyload/plugins/hoster/UploadedTo.py index 56d8b1628..5b53b0aa5 100644 --- a/pyload/plugins/hoster/UploadedTo.py +++ b/pyload/plugins/hoster/UploadedTo.py @@ -33,7 +33,7 @@ def getAPIData(urls): post["id_%s" % i] = id idMap[id] = url - for i in xrange(5): + for _ in xrange(5): api = unicode(getURL("http://uploaded.net/api/filemultiple", post=post, decode=False), 'iso-8859-1') if api != "can't find request": break @@ -189,7 +189,7 @@ class UploadedTo(Hoster): url = "http://uploaded.net/io/ticket/captcha/%s" % self.fileID downloadURL = "" - for i in range(5): + for _ in xrange(5): re_captcha = ReCaptcha(self) challenge, result = re_captcha.challenge(challengeId.group(1)) options = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": result} diff --git a/pyload/plugins/hoster/UploadheroCom.py b/pyload/plugins/hoster/UploadheroCom.py index 7b047e028..993f34a0f 100644 --- a/pyload/plugins/hoster/UploadheroCom.py +++ b/pyload/plugins/hoster/UploadheroCom.py @@ -53,7 +53,7 @@ class UploadheroCom(SimpleHoster): self.parseError("Captcha URL") captcha_url = "http://uploadhero.co" + found.group(1) - for i in range(5): + for _ in xrange(5): captcha = self.decryptCaptcha(captcha_url) self.html = self.load(self.pyfile.url, get={"code": captcha}) found = re.search(self.FREE_URL_PATTERN, self.html) diff --git a/pyload/plugins/hoster/Xdcc.py b/pyload/plugins/hoster/Xdcc.py index 90de28013..e1c423453 100644 --- a/pyload/plugins/hoster/Xdcc.py +++ b/pyload/plugins/hoster/Xdcc.py @@ -55,7 +55,7 @@ class Xdcc(Hoster): self.req = pyfile.m.core.requestFactory.getRequest(self.__name__, type="XDCC") self.pyfile = pyfile - for i in range(0, 3): + for _ in xrange(0, 3): try: nmn = self.doDownload(pyfile.url) self.logDebug("%s: Download of %s finished." % (self.__name__, nmn)) diff --git a/pyload/plugins/hoster/ZeveraCom.py b/pyload/plugins/hoster/ZeveraCom.py index 9546f09d3..760703ee1 100644 --- a/pyload/plugins/hoster/ZeveraCom.py +++ b/pyload/plugins/hoster/ZeveraCom.py @@ -51,7 +51,7 @@ class ZeveraCom(Hoster): # last_size = retries = 0 # olink = self.pyfile.url #quote(self.pyfile.url.encode('utf_8')) # - # for i in range(100): + # for _ in xrange(100): # self.retData = self.account.loadAPIRequest(self.req, cmd = 'download_request', olink = olink) # self.checkAPIErrors(self.retData) # diff --git a/pyload/plugins/hoster/ZippyshareCom.py b/pyload/plugins/hoster/ZippyshareCom.py index ea861025d..54e8eee21 100644 --- a/pyload/plugins/hoster/ZippyshareCom.py +++ b/pyload/plugins/hoster/ZippyshareCom.py @@ -200,7 +200,7 @@ class ZippyshareCom(SimpleHoster): recaptcha = ReCaptcha(self) - for i in range(5): + for _ in xrange(5): challenge, code = recaptcha.challenge(captcha_key) response = json_loads(self.load(self.file_info['HOST'] + '/rest/captcha/test', diff --git a/pyload/plugins/internal/OCR.py b/pyload/plugins/internal/OCR.py index 9f8b7ef8c..c30125a03 100644 --- a/pyload/plugins/internal/OCR.py +++ b/pyload/plugins/internal/OCR.py @@ -185,7 +185,7 @@ class OCR(object): highest = {} counts = {} - for angle in range(-45, 45): + for angle in xrange(-45, 45): tmpimage = self.image.rotate(angle) diff --git a/pyload/plugins/internal/SimpleCrypter.py b/pyload/plugins/internal/SimpleCrypter.py index e93f5346d..4606b8016 100644 --- a/pyload/plugins/internal/SimpleCrypter.py +++ b/pyload/plugins/internal/SimpleCrypter.py @@ -98,6 +98,6 @@ class SimpleCrypter(Crypter): else: pages = 1 - for p in range(2, pages + 1): + for p in xrange(2, pages + 1): self.html = self.loadPage(p) self.package_links += self.getLinks() -- cgit v1.2.3