From 78e26bfd3b940034748256e4d0237e0ae5d33d60 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 8 Dec 2014 23:19:08 +0100 Subject: [SkipRev] Update (2) --- module/plugins/hooks/SkipRev.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 76a48a255..f3edcc9dc 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- -import re - from urllib import unquote -from urlparse import urljoin, urlparse +from urlparse import urlparse from module.plugins.Hook import Hook from module.plugins.Plugin import SkipDownload @@ -12,11 +10,9 @@ from module.plugins.Plugin import SkipDownload class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.13" + __version__ = "0.14" - __config__ = [("auto", "bool", "Automatically keep all rev files needed by package", True), - ("tokeep", "int" , "Min number of rev files to keep for package" , 1), - ("unskip", "bool", "Restart a skipped rev when download fails" , True)] + __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] __description__ = """Skip files ending with extension rev""" __license__ = "GPLv3" @@ -55,11 +51,11 @@ class SkipRev(Hook): tokeep = self.getConfig("tokeep") - if tokeep > 0: + if tokeep: saved = [True for link in pyfile.package().getChildren() \ if link.name.endswith(".rev") and (link.hasStatus("finished") or link.hasStatus("downloading"))].count(True) - if saved < tokeep: + if not saved or saved < tokeep: #: keep one rev at least in auto mode return pyfile.setCustomStatus("SkipRev", "skipped") @@ -67,15 +63,15 @@ class SkipRev(Hook): def downloadFailed(self, pyfile): - if self.getConfig("auto") is False: - - if self.getConfig("unskip") is False: - return + tokeep = self.getConfig("tokeep") - if not pyfile.name.endswith(".rev"): - return + if not tokeep: + return for link in pyfile.package().getChildren(): if link.hasStatus("skipped") and link.name.endswith(".rev"): - link.setCustomStatus("unskipped", "queued") + if tokeep > -1 or pyfile.name.endswith(".rev"): + link.setStatus("queued") + else: + link.setCustomStatus("unskipped", "queued") return -- cgit v1.2.3