summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-19 18:03:46 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-19 18:03:46 +0200
commite1c22fad3fffb485da400e4b34c094f201a2c72e (patch)
treed360610cdf65e2f1906d3cc9c891f6b80066859d
parentPEP-8, Python Zen, refactor and reduce code (part 7 in master module/database) (diff)
downloadpyload-e1c22fad3fffb485da400e4b34c094f201a2c72e.tar.xz
range -> xrange
-rwxr-xr-xpyload/Core.py4
-rw-r--r--pyload/cli/Cli.py2
-rw-r--r--pyload/cli/ManageFiles.py6
-rw-r--r--pyload/database/Backend.py2
-rw-r--r--pyload/database/File.py2
-rw-r--r--pyload/database/User.py4
-rw-r--r--pyload/manager/Thread.py4
-rw-r--r--pyload/network/HTTPChunk.py2
-rw-r--r--pyload/network/HTTPDownload.py4
-rw-r--r--pyload/network/HTTPRequest.py2
-rw-r--r--pyload/plugin/hoster/MegaRapidoNet.py2
-rw-r--r--pyload/remote/thriftbackend/ThriftTest.py2
-rw-r--r--tests/APIExerciser.py4
-rw-r--r--tests/test_api.py2
14 files changed, 21 insertions, 21 deletions
diff --git a/pyload/Core.py b/pyload/Core.py
index 481026a68..d1404d00f 100755
--- a/pyload/Core.py
+++ b/pyload/Core.py
@@ -612,7 +612,7 @@ class Core(object):
self.shutdown()
chdir(owd)
# close some open fds
- for i in range(3, 50):
+ for i in xrange(3, 50):
try:
close(i)
except Exception:
@@ -678,7 +678,7 @@ def deamon():
sys.exit(1)
# Iterate through and close some file descriptors.
- for fd in range(0, 3):
+ for fd in xrange(0, 3):
try:
os.close(fd)
except OSError: # ERROR, fd wasn't open to begin with (ignored)
diff --git a/pyload/cli/Cli.py b/pyload/cli/Cli.py
index a1f192bb3..cd3252220 100644
--- a/pyload/cli/Cli.py
+++ b/pyload/cli/Cli.py
@@ -214,7 +214,7 @@ class Cli(object):
# clear old output
if line < self.lastLowestLine:
- for i in range(line + 1, self.lastLowestLine + 1):
+ for i in xrange(line + 1, self.lastLowestLine + 1):
println(i, "")
self.lastLowestLine = line
diff --git a/pyload/cli/ManageFiles.py b/pyload/cli/ManageFiles.py
index c010895c5..2e7f725dd 100644
--- a/pyload/cli/ManageFiles.py
+++ b/pyload/cli/ManageFiles.py
@@ -113,7 +113,7 @@ class ManageFiles(Handler):
i += 1
except Exception:
pass
- for _i in range(5 - i):
+ for _i in xrange(5 - i):
println(line, "")
line += 1
else:
@@ -128,7 +128,7 @@ class ManageFiles(Handler):
i += 1
except Exception, e:
pass
- for _i in range(5 - i):
+ for _i in xrange(5 - i):
println(line, "")
line += 1
@@ -168,7 +168,7 @@ class ManageFiles(Handler):
inp = inp.strip()
if "-" in inp:
l, _, h = inp.partition("-")
- r = range(int(l), int(h) + 1)
+ r = xrange(int(l), int(h) + 1)
if package:
return [p.pid for p in self.cache if p.pid in r]
diff --git a/pyload/database/Backend.py b/pyload/database/Backend.py
index 8b537511e..b6540b2be 100644
--- a/pyload/database/Backend.py
+++ b/pyload/database/Backend.py
@@ -85,7 +85,7 @@ class DatabaseJob(object):
frame = self.frame.f_back
output = ""
- for _i in range(5):
+ for _i in xrange(5):
output += "\t%s:%s, %s\n" % (basename(frame.f_code.co_filename), frame.f_lineno, frame.f_code.co_name)
frame = frame.f_back
del frame
diff --git a/pyload/database/File.py b/pyload/database/File.py
index d97dc7c5e..a49ba6d3a 100644
--- a/pyload/database/File.py
+++ b/pyload/database/File.py
@@ -670,7 +670,7 @@ class FileMethods(object):
def addLinks(self, links, package):
""" links is a list of tupels (url, plugin)"""
order = self._nextFileOrder(package)
- orders = [order + x for x in range(len(links))]
+ orders = [order + x for x in xrange(len(links))]
links = [(x[0], x[0], ".".join((x[1], x[2])), package, o) for x, o in zip(links, orders)]
self.c.executemany('INSERT INTO links(url, name, plugin, package, linkorder) VALUES(?,?,?,?,?)', links)
diff --git a/pyload/database/User.py b/pyload/database/User.py
index df510c54f..2aedc3bba 100644
--- a/pyload/database/User.py
+++ b/pyload/database/User.py
@@ -30,7 +30,7 @@ class UserMethods(object):
@style.queue
def addUser(db, user, password):
- salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for _i in range(0, 5)])
+ salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for _i in xrange(0, 5)])
h = sha1(salt + password)
password = salt + h.hexdigest()
@@ -53,7 +53,7 @@ class UserMethods(object):
pw = r[2][5:]
h = sha1(salt + oldpw)
if h.hexdigest() == pw:
- salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for _i in range(0, 5)])
+ salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for _i in xrange(0, 5)])
h = sha1(salt + newpw)
password = salt + h.hexdigest()
diff --git a/pyload/manager/Thread.py b/pyload/manager/Thread.py
index a8550e504..782cf7b2a 100644
--- a/pyload/manager/Thread.py
+++ b/pyload/manager/Thread.py
@@ -51,7 +51,7 @@ class ThreadManager(object):
pycurl.global_init(pycurl.GLOBAL_DEFAULT)
- for _i in range(0, self.core.config.get("download", "max_downloads")):
+ for _i in xrange(0, self.core.config.get("download", "max_downloads")):
self.createThread()
@@ -206,7 +206,7 @@ class ThreadManager(object):
("http://checkip.dyndns.org/", ".*Current IP Address: (\S+)</body>.*")]
ip = ""
- for _i in range(10):
+ for _i in xrange(10):
try:
sv = choice(services)
ip = getURL(sv[0])
diff --git a/pyload/network/HTTPChunk.py b/pyload/network/HTTPChunk.py
index 784b64349..aaf29355e 100644
--- a/pyload/network/HTTPChunk.py
+++ b/pyload/network/HTTPChunk.py
@@ -51,7 +51,7 @@ class ChunkInfo(object):
chunk_size = self.size / chunks
current = 0
- for i in range(chunks):
+ for i in xrange(chunks):
end = self.size - 1 if (i == chunks - 1) else current + chunk_size
self.addChunk("%s.chunk%s" % (self.name, i), (current, end))
current += chunk_size + 1
diff --git a/pyload/network/HTTPDownload.py b/pyload/network/HTTPDownload.py
index 77f2ea657..8bf822a15 100644
--- a/pyload/network/HTTPDownload.py
+++ b/pyload/network/HTTPDownload.py
@@ -84,7 +84,7 @@ class HTTPDownload(object):
if self.info.getCount() > 1:
with open(init, "rb+") as fo: #: first chunkfile
- for i in range(1, self.info.getCount()):
+ for i in xrange(1, self.info.getCount()):
#input file
fo.seek(
self.info.getChunkRange(i - 1)[1] + 1) #: seek to beginning of chunk, to get rid of overlapping chunks
@@ -173,7 +173,7 @@ class HTTPDownload(object):
init.setRange(self.info.getChunkRange(0))
- for i in range(1, chunks):
+ for i in xrange(1, chunks):
c = HTTPChunk(i, self, self.info.getChunkRange(i), resume)
handle = c.getHandle()
diff --git a/pyload/network/HTTPRequest.py b/pyload/network/HTTPRequest.py
index 62c0ef72b..d87a3ee7e 100644
--- a/pyload/network/HTTPRequest.py
+++ b/pyload/network/HTTPRequest.py
@@ -24,7 +24,7 @@ def myurlencode(data):
data = dict(data)
return urlencode(dict((encode(x), encode(y)) for x, y in data.iteritems()))
-bad_headers = range(400, 404) + range(405, 418) + range(500, 506)
+bad_headers = xrange(400, 404) + xrange(405, 418) + xrange(500, 506)
class BadHeader(Exception):
diff --git a/pyload/plugin/hoster/MegaRapidoNet.py b/pyload/plugin/hoster/MegaRapidoNet.py
index 311189d1c..54a167b65 100644
--- a/pyload/plugin/hoster/MegaRapidoNet.py
+++ b/pyload/plugin/hoster/MegaRapidoNet.py
@@ -8,7 +8,7 @@ from pyload.plugin.internal.MultiHoster import MultiHoster
def random_with_N_digits(n):
rand = "0."
not_zero = 0
- for _i in range(1, n + 1):
+ for _i in xrange(1, n + 1):
r = randint(0, 9)
if(r > 0):
not_zero += 1
diff --git a/pyload/remote/thriftbackend/ThriftTest.py b/pyload/remote/thriftbackend/ThriftTest.py
index 0c5ea4783..ed4557e2d 100644
--- a/pyload/remote/thriftbackend/ThriftTest.py
+++ b/pyload/remote/thriftbackend/ThriftTest.py
@@ -25,7 +25,7 @@ import xmlrpclib
def bench(f, *args, **kwargs):
s = time()
- ret = [f(*args, **kwargs) for _i in range(0, 100)]
+ ret = [f(*args, **kwargs) for _i in xrange(0, 100)]
e = time()
try:
print "%s: %f s" % (f._Method__name, e-s)
diff --git a/tests/APIExerciser.py b/tests/APIExerciser.py
index d7300b1a5..f4b082479 100644
--- a/tests/APIExerciser.py
+++ b/tests/APIExerciser.py
@@ -17,7 +17,7 @@ from pyload.remote.thriftbackend.ThriftClient import ThriftClient, Destination
def createURLs():
""" create some urls, some may fail """
urls = []
- for x in range(0, randint(20, 100)):
+ for x in xrange(0, randint(20, 100)):
name = "DEBUG_API"
if randint(0, 5) == 5:
name = "" #: this link will fail
@@ -34,7 +34,7 @@ sumCalled = 0
def startApiExerciser(core, n):
- for _i in range(n):
+ for _i in xrange(n):
APIExerciser(core).start()
diff --git a/tests/test_api.py b/tests/test_api.py
index 13e783d54..1e02d8aa3 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -20,5 +20,5 @@ class TestApi(object):
@nottest
def test_random(self):
- for _i in range(0, 100):
+ for _i in xrange(0, 100):
self.api.testAPI()