diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-12-01 23:53:07 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-12-01 23:53:07 +0100 |
commit | 004a80bfaad38f9400e8aebcb8f980353a232295 (patch) | |
tree | 1e786d2d14a3040767aac237982544b74a9567cb /pyload/cli/ManageFiles.py | |
parent | Fix previous merge (diff) | |
download | pyload-004a80bfaad38f9400e8aebcb8f980353a232295.tar.xz |
PEP-8, Python Zen, refactor and reduce code (thx FedeG)
Diffstat (limited to 'pyload/cli/ManageFiles.py')
-rw-r--r-- | pyload/cli/ManageFiles.py | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/pyload/cli/ManageFiles.py b/pyload/cli/ManageFiles.py index 335ea1ec1..9bf49c54c 100644 --- a/pyload/cli/ManageFiles.py +++ b/pyload/cli/ManageFiles.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -#Copyright (C) 2011-2014 RaNaN +# Copyright (C) 2011-2014 RaNaN # #This program is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by @@ -25,15 +25,15 @@ from pyload.utils.printer import * from pyload.api import Destination, PackageData + class ManageFiles(Handler): """ possibility to manage queue/collector """ def init(self): self.target = Destination.Queue - self.pos = 0 #position in queue + self.pos = 0 #position in queue self.package = -1 #choosen package - self.mode = "" # move/delete/restart - + self.mode = "" # move/delete/restart self.cache = None self.links = None self.time = 0 @@ -81,7 +81,7 @@ class ManageFiles(Handler): #look into package try: self.package = int(input) - except: + except Exception: pass self.cache = None @@ -90,7 +90,6 @@ class ManageFiles(Handler): self.mode = "" self.setInput() - def renderBody(self, line): if self.package < 0: println(line, white(_("Manage Packages:"))) @@ -111,7 +110,7 @@ class ManageFiles(Handler): else: println(line, _("Choose what yout want to do or enter package number.")) println(line + 1, ("%s - %%s, %s - %%s, %s - %%s" % (mag("d"), mag("m"), mag("r"))) % ( - _("delete"), _("move"), _("restart"))) + _("delete"), _("move"), _("restart"))) line += 2 if self.package < 0: @@ -135,7 +134,7 @@ class ManageFiles(Handler): for value in islice(pack.links, self.pos, self.pos + 5): try: println(line, mag(value.fid) + ": %s | %s | %s" % ( - value.name, value.statusmsg, value.plugin)) + value.name, value.statusmsg, value.plugin)) line += 1 i += 1 except Exception, e: @@ -146,10 +145,8 @@ class ManageFiles(Handler): println(line, mag("p") + _(" - previous") + " | " + mag("n") + _(" - next")) println(line + 1, mag("0.") + _(" back to main menu")) - return line + 2 - def getPackages(self): if self.cache and self.time + 2 < time(): return self.cache @@ -159,7 +156,6 @@ class ManageFiles(Handler): else: data = self.client.getCollector() - self.cache = data self.time = time() @@ -168,15 +164,12 @@ class ManageFiles(Handler): def getLinks(self): if self.links and self.time + 1 < time(): return self.links - try: data = self.client.getPackageData(self.package) - except: + except Exception: data = PackageData(links=[]) - self.links = data self.time = time() - return data def parseInput(self, inp, package=True): @@ -196,8 +189,6 @@ class ManageFiles(Handler): for l in self.links.links: if l.lid in r: ret.append(l.lid) - return ret - else: return [int(x) for x in inp.split(",")] |