From dad722ac7255640e7e0541c4094a4d2e4de79cd3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 00:05:58 +0200 Subject: Code cosmetics (2) --- module/plugins/hooks/BypassCaptcha.py | 2 +- module/plugins/hooks/Checksum.py | 4 ++-- module/plugins/hooks/ClickAndLoad.py | 4 ++-- module/plugins/hooks/DeleteFinished.py | 4 ++-- module/plugins/hooks/DownloadScheduler.py | 2 +- module/plugins/hooks/ExpertDecoders.py | 2 +- module/plugins/hooks/ExtractArchive.py | 28 ++++++++++++++-------------- module/plugins/hooks/IRCInterface.py | 6 +++--- module/plugins/hooks/ImageTyperz.py | 2 +- module/plugins/hooks/RestartFailed.py | 2 +- module/plugins/hooks/SkipRev.py | 2 +- module/plugins/hooks/UnSkipOnFail.py | 26 +++++++++++++------------- module/plugins/hooks/UpdateManager.py | 22 +++++++++++----------- module/plugins/hooks/XFileSharingPro.py | 6 +++--- module/plugins/hooks/XMPPInterface.py | 8 ++++---- 15 files changed, 60 insertions(+), 60 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index ab08c68c1..42c30ba25 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -63,7 +63,7 @@ class BypassCaptcha(Hook): def submit(self, captcha, captchaType="file", match=None): req = get_request() - # raise timeout threshold + #: Raise timeout threshold req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 7f42347df..4d2dbf576 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -110,7 +110,7 @@ class Checksum(Hook): if not os.path.isfile(local_file): self.check_failed(pyfile, None, "File does not exist") - #: validate file size + #: Validate file size if "size" in data: api_size = int(data['size']) file_size = os.path.getsize(local_file) @@ -121,7 +121,7 @@ class Checksum(Hook): data.pop('size', None) - #: validate checksum + #: Validate checksum if data and self.get_config('check_checksum'): if not 'md5' in data: diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 109452105..c361d51b2 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -91,12 +91,12 @@ class ClickAndLoad(Hook): except NameError: self.log_error(_("pyLoad's webinterface is configured to use HTTPS, Please install python's ssl lib or disable HTTPS")) - client_socket.close() #: reset the connection. + client_socket.close() #: Reset the connection. continue except Exception, e: self.log_error(_("SSL error: %s") % e.message) - client_socket.close() #: reset the connection. + client_socket.close() #: Reset the connection. continue server_socket.connect(("127.0.0.1", webport)) diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index ec708eb10..5c613f5c6 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -50,8 +50,8 @@ class DeleteFinished(Hook): def activate(self): self.info['sleep'] = True - #: interval = self.get_config('interval') - #: self.plugin_config_changed(self.__name__, 'interval', interval) + # interval = self.get_config('interval') + # self.plugin_config_changed(self.__name__, 'interval', interval) self.interval = max(self.MIN_CHECK_INTERVAL, self.get_config('interval') * 60 * 60) self.add_event('package_finished', self.wakeup) diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index ed43683fa..e1114d615 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -25,7 +25,7 @@ class DownloadScheduler(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - self.cb = None #: callback to scheduler job; will be by removed hookmanager when hook unloaded + self.cb = None #: Callback to scheduler job; will be by removed hookmanager when hook unloaded def activate(self): diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index 919445db8..17890f691 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -56,7 +56,7 @@ class ExpertDecoders(Hook): data = f.read() req = get_request() - # raise timeout threshold + #: Raise timeout threshold req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 9ca7bf854..ad9f67a1a 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -23,7 +23,7 @@ if sys.version_info < (2, 7) and os.name != "nt": raise - #: unsued timeout option for older python version + #: Unsued timeout option for older python version def wait(self, timeout=0): """ Wait for child process to terminate. Returns returncode @@ -36,8 +36,8 @@ if sys.version_info < (2, 7) and os.name != "nt": except OSError, e: if e.errno != errno.ECHILD: raise - #: This happens if SIGCLD is set to be ignored or waiting - #: for child processes has otherwise been disabled for our + #: This happens if SIGCLD is set to be ignored or waiting + #: For child processes has otherwise been disabled for our #: process. This child is dead, we can't get the status. sts = 0 self._handle_exitstatus(sts) @@ -196,7 +196,7 @@ class ExtractArchive(Hook): packages = self.queue.get() while packages: - if self.last_package: #: called from allDownloadsProcessed + if self.last_package: #: Called from allDownloadsProcessed self.last_package = False if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now self.manager.dispatchEvent("all_archives_extracted") @@ -205,7 +205,7 @@ class ExtractArchive(Hook): if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now pass - packages = self.queue.get() #: check for packages added during extraction + packages = self.queue.get() #: Check for packages added during extraction self.extracting = False @@ -272,12 +272,12 @@ class ExtractArchive(Hook): if extensions: self.log_debug("Use for extensions: %s" % "|.".join(extensions)) - #: reload from txt file + #: Reload from txt file self.reload_passwords() download_folder = self.core.config.get("general", "download_folder") - #: iterate packages -> extractors -> targets + #: Iterate packages -> extractors -> targets for pid in ids: pypack = self.core.files.getPackage(pid) @@ -287,8 +287,8 @@ class ExtractArchive(Hook): self.log_info(_("Check package: %s") % pypack.name) - #: determine output folder - out = fs_join(download_folder, pypack.folder, destination, "") #: force trailing slash + #: Determine output folder + out = fs_join(download_folder, pypack.folder, destination, "") #: Force trailing slash if subfolder: out = fs_join(out, pypack.folder) @@ -299,9 +299,9 @@ class ExtractArchive(Hook): matched = False success = True files_ids = dict((pylink['name'],((fs_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ - in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: remove duplicates + in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: Remove duplicates - #: check as long there are unseen files + #: Check as long there are unseen files while files_ids: new_files_ids = [] @@ -351,7 +351,7 @@ class ExtractArchive(Hook): success = False continue - #: remove processed file and related multiparts from list + #: Remove processed file and related multiparts from list files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ if fname not in archive.getDeleteFiles()] self.log_debug("Extracted files: %s" % new_files) @@ -364,11 +364,11 @@ class ExtractArchive(Hook): continue if recursive and os.path.isfile(file): - new_files_ids.append((filename, fid, os.path.dirname(filename))) #: append as new target + new_files_ids.append((filename, fid, os.path.dirname(filename))) #: Append as new target self.manager.dispatchEvent("archive_extracted", pyfile, archive) - files_ids = new_files_ids #: also check extracted files + files_ids = new_files_ids #: Also check extracted files if matched: if success: diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 32597aa42..5d8376b4e 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -84,7 +84,7 @@ class IRCInterface(Thread, Hook): def run(self): - #: connect to IRC etc. + #: Connect to IRC etc. self.sock = socket.socket() host = self.get_config('host') self.sock.connect((host, self.get_config('port'))) @@ -339,12 +339,12 @@ class IRCInterface(Thread, Hook): if not pack: return ["ERROR: Package doesn't exists."] - # TODO add links + #@TODO: add links return ["INFO: Added %d links to Package %s [#%d]" % (len(links), pack['name'], id)] except Exception: - #: create new package + #: Create new package id = self.core.api.addPackage(pack, links, 1) return ["INFO: Created new Package %s [#%d] with %d links." % (pack, id, len(links))] diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 5e2f21c8b..b46728a0d 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -75,7 +75,7 @@ class ImageTyperz(Hook): def submit(self, captcha, captchaType="file", match=None): req = get_request() - # raise timeout threshold + #: Raise timeout threshold req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index e19705d31..52752861f 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -41,5 +41,5 @@ class RestartFailed(Hook): def activate(self): - #: self.plugin_config_changed(self.__name__, "interval", self.get_config('interval')) + # self.plugin_config_changed(self.__name__, "interval", self.get_config('interval')) self.interval = max(self.MIN_CHECK_INTERVAL, self.get_config('interval') * 60) diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 9f5f4f231..5ec6290ac 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -73,7 +73,7 @@ class SkipRev(Hook): queued = [True for link in self.core.api.getPackageData(pyfile.package().id).links \ if link.status not in status_list and pyname.match(link.name)].count(True) - if not queued or queued < revtokeep: #: keep one rev at least in auto mode + if not queued or queued < revtokeep: #: Keep one rev at least in auto mode return pyfile.setCustomStatus("SkipRev", "skipped") diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 4e1e60f61..5507cd20f 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -35,13 +35,13 @@ class UnSkipOnFail(Hook): if link: self.log_info(_("Queue found duplicate: %s (pid:%s)") % (link.name, link.packageID)) - # Change status of "link" to "new_status". - # "link" has to be a valid FileData object, - # "new_status" has to be a valid status name - # (i.e. "queued" for this Plugin) - # It creates a temporary PyFile object using - # "link" data, changes its status, and tells - # the core.files-manager to save its data. + #: Change status of "link" to "new_status". + #: "link" has to be a valid FileData object, + #: "new_status" has to be a valid status name + #: (i.e. "queued" for this Plugin) + #: It creates a temporary PyFile object using + #: "link" data, changes its status, and tells + #: The core.files-manager to save its data. pylink = self._pyfile(link) pylink.setCustomStatus(_("unskipped"), "queued") @@ -63,22 +63,22 @@ class UnSkipOnFail(Hook): the data for "pyfile" iotselöf. It does MOT check the link's status. """ - queue = self.core.api.getQueue() #: get packages (w/o files, as most file data is useless here) + queue = self.core.api.getQueue() #: Get packages (w/o files, as most file data is useless here) for package in queue: - #: check if package-folder equals pyfile's package folder + #: Check if package-folder equals pyfile's package folder if package.folder != pyfile.package().folder: continue - #: now get packaged data w/ files/links + #: Now get packaged data w/ files/links pdata = self.core.api.getPackageData(package.pid) for link in pdata.links: - #: check if link is "skipped" + #: Check if link is "skipped" if link.status != 4: continue - #: check if link name collides with pdata's name - #: AND at last check if it is not pyfile itself + #: Check if link name collides with pdata's name + #: and at last check if it is not pyfile itself if link.name == pyfile.name and link.fid != pyfile.id: return link diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 50e818c66..6f6ad9838 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -61,7 +61,7 @@ class UpdateManager(Hook): def setup(self): self.info = {'pyload': False, 'version': None, 'plugins': False, 'last_check': time.time()} - self.mtimes = {} #: store modification time for each plugin + self.mtimes = {} #: Store modification time for each plugin self.event_map = {'allDownloadsProcessed': "all_downloads_processed"} @@ -182,11 +182,11 @@ class UpdateManager(Hook): self.info['version'] = data[0] exitcode = 3 - # Exit codes: - # -1 = No plugin updated, new pyLoad version available - # 0 = No plugin updated - # 1 = Plugins updated - # 2 = Plugins updated, but restart required + #: Exit codes: + #: -1 = No plugin updated, new pyLoad version available + #: 0 = No plugin updated + #: 1 = Plugins updated + #: 2 = Plugins updated, but restart required return exitcode @@ -294,10 +294,10 @@ class UpdateManager(Hook): else: self.log_info(_("No plugin updates available")) - # Exit codes: - # 0 = No plugin updated - # 1 = Plugins updated - # 2 = Plugins updated, but restart required + #: Exit codes: + #: 0 = No plugin updated + #: 1 = Plugins updated + #: 2 = Plugins updated, but restart required return exitcode @@ -350,4 +350,4 @@ class UpdateManager(Hook): id = (type, name) removed.add(id) - return list(removed) #: return a list of the plugins successfully removed + return list(removed) #: Return a list of the plugins successfully removed diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 9c42d1c0a..45acc9976 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -34,12 +34,12 @@ class XFileSharingPro(Hook): "junkyvideo.com", "linestorage.com", "ravishare.com", "ryushare.com", "salefiles.com", "sendmyway.com", "sharebeast.com", "sharesix.com", "thefile.me", "verzend.be", "worldbytez.com", "xvidstage.com", - # NOT TESTED: + #: NOT TESTED: "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", "vidbull.com", "zalaa.com", "zomgupload.com", - # NOT WORKING: + #: NOT WORKING: "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", "laoupload.com", "rd-fs.com"] CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] @@ -105,7 +105,7 @@ class XFileSharingPro(Hook): def deactivate(self): - #: self.unload_hoster("BasePlugin") + # self.unload_hoster("BasePlugin") for type, plugin in (("hoster", "XFileSharingPro"), ("crypter", "XFileSharingProFolder")): self._unload(type, plugin) diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index a2c32166f..4262d3034 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -36,7 +36,7 @@ class XMPPInterface(IRCInterface, JabberClient): self.jid = JID(self.get_config('jid')) password = self.get_config('pw') - #: if bare JID is provided add a resource -- it is required + #: If bare JID is provided add a resource -- it is required if not self.jid.resource: self.jid = JID(self.jid.node, self.jid.domain, "pyLoad") @@ -47,8 +47,8 @@ class XMPPInterface(IRCInterface, JabberClient): tls_settings = None auth = ("sasl:DIGEST-MD5", "digest") - #: setup client with provided connection information - #: and identity data + #: Setup client with provided connection information + #: And identity data JabberClient.__init__(self, self.jid, password, disco_name="pyLoad XMPP Client", disco_type="bot", tls_settings=tls_settings, auth_methods=auth) @@ -83,7 +83,7 @@ class XMPPInterface(IRCInterface, JabberClient): def run(self): - #: connect to IRC etc. + #: Connect to IRC etc. self.connect() try: self.loop() -- cgit v1.2.3