From f162ae0de0f71391c56957389cc3c8babc8022e1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Apr 2015 16:37:00 +0200 Subject: Use with statement --- pyload/cli/Cli.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'pyload/cli') diff --git a/pyload/cli/Cli.py b/pyload/cli/Cli.py index 84725b625..a1f192bb3 100644 --- a/pyload/cli/Cli.py +++ b/pyload/cli/Cli.py @@ -321,9 +321,8 @@ class Cli(object): print _("File does not exists.") return - f = open(join(owd, path), "rb") - content = f.read() - f.close() + with open(join(owd, path), "rb") as f: + content = f.read() rid = self.client.checkOnlineStatusContainer([], basename(f.name), content).rid self.printOnlineCheck(self.client, rid) -- cgit v1.2.3 From e1c22fad3fffb485da400e4b34c094f201a2c72e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Apr 2015 18:03:46 +0200 Subject: range -> xrange --- pyload/cli/Cli.py | 2 +- pyload/cli/ManageFiles.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'pyload/cli') 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] -- cgit v1.2.3 From bbaac34ea11bf6ffa347a3b1a2effe2b4891fddc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Apr 2015 18:02:35 +0200 Subject: Spare code cosmetics (6) --- pyload/cli/Handler.py | 1 - 1 file changed, 1 deletion(-) (limited to 'pyload/cli') diff --git a/pyload/cli/Handler.py b/pyload/cli/Handler.py index 444d7f6d0..33e5dd8e6 100644 --- a/pyload/cli/Handler.py +++ b/pyload/cli/Handler.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # @author: RaNaN - class Handler(object): def __init__(self, cli): -- cgit v1.2.3 From 892b7cbd4981b764bed30b2ccc5ca73d791c39f2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 20 Apr 2015 22:56:34 +0200 Subject: Spare code cosmetics (9) --- pyload/cli/Cli.py | 8 ++++---- pyload/cli/ManageFiles.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'pyload/cli') diff --git a/pyload/cli/Cli.py b/pyload/cli/Cli.py index cd3252220..fc5236ff9 100644 --- a/pyload/cli/Cli.py +++ b/pyload/cli/Cli.py @@ -55,8 +55,8 @@ class Cli(object): self.lock = Lock() # processor funcions, these will be changed dynamically depending on control flow - self.headerHandler = self # the download status - self.bodyHandler = self # the menu section + self.headerHandler = self #: the download status + self.bodyHandler = self #: the menu section self.inputHandler = self os.system("clear") @@ -158,7 +158,7 @@ class Cli(object): line += 1 for download in data: - if download.status == 12: # downloading + if download.status == 12: #: downloading percent = download.percent z = percent / 4 speed += download.speed @@ -265,7 +265,7 @@ class Cli(object): print "No downloads running." for download in files: - if download.status == 12: # downloading + if download.status == 12: #: downloading print print_status(download) print "\tDownloading: %s @ %s/s\t %s (%s%%)" % ( download.format_eta, formatSize(download.speed), formatSize(download.size - download.bleft), diff --git a/pyload/cli/ManageFiles.py b/pyload/cli/ManageFiles.py index 2e7f725dd..3833b2c48 100644 --- a/pyload/cli/ManageFiles.py +++ b/pyload/cli/ManageFiles.py @@ -15,9 +15,9 @@ class ManageFiles(Handler): def init(self): self.target = Destination.Queue - self.pos = 0 # position in queue - self.package = -1 # choosen package - self.mode = "" # move/delete/restart + self.pos = 0 #: position in queue + self.package = -1 #: choosen package + self.mode = "" #: move/delete/restart self.cache = None self.links = None -- cgit v1.2.3