summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-17 18:29:50 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-24 22:42:29 +0200
commit164512b6a74c94a731fcee7435dce1ccfa2f71e7 (patch)
tree3f61d3b83f641070145b478f54522c4fe2e63691 /module/plugins/internal
parentSpare fixes (diff)
downloadpyload-164512b6a74c94a731fcee7435dce1ccfa2f71e7.tar.xz
Spare code cosmetics
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/Account.py17
-rw-r--r--module/plugins/internal/Container.py12
-rw-r--r--module/plugins/internal/Crypter.py17
-rw-r--r--module/plugins/internal/Extractor.py12
-rw-r--r--module/plugins/internal/Hook.py29
-rw-r--r--module/plugins/internal/Hoster.py1
-rw-r--r--module/plugins/internal/MultiHook.py8
-rw-r--r--module/plugins/internal/OCR.py14
-rw-r--r--module/plugins/internal/Plugin.py32
-rw-r--r--module/plugins/internal/SimpleCrypter.py1
-rw-r--r--module/plugins/internal/SimpleHoster.py1
-rw-r--r--module/plugins/internal/XFSHoster.py4
12 files changed, 101 insertions, 47 deletions
diff --git a/module/plugins/internal/Account.py b/module/plugins/internal/Account.py
index 0e2996aaa..0595da20b 100644
--- a/module/plugins/internal/Account.py
+++ b/module/plugins/internal/Account.py
@@ -106,8 +106,9 @@ class Account(Plugin):
def updateAccounts(self, user, password=None, options={}):
- """Updates account and return true if anything changed"""
-
+ """
+ Updates account and return true if anything changed
+ """
if user in self.accounts:
self.accounts[user]['valid'] = True #: do not remove or accounts will not login
if password:
@@ -227,7 +228,9 @@ class Account(Plugin):
def selectAccount(self):
- """Returns an valid account name and data"""
+ """
+ Returns an valid account name and data
+ """
usable = []
for user, data in self.accounts.iteritems():
if not data['valid']:
@@ -290,14 +293,18 @@ class Account(Plugin):
def scheduleRefresh(self, user, time=0, force=True):
- """Add task to refresh account info to sheduler"""
+ """
+ Add task to refresh account info to sheduler
+ """
self.logDebug("Scheduled Account refresh for %s in %s seconds." % (user, time))
self.core.scheduler.addJob(time, self.getAccountInfo, [user, force])
@lock
def checkLogin(self, user):
- """Checks if user is still logged in"""
+ """
+ Checks if user is still logged in
+ """
if user in self.timestamps:
if self.login_timeout > 0 and self.timestamps[user] + self.login_timeout * 60 < time.time():
self.logDebug("Reached login timeout for %s" % user)
diff --git a/module/plugins/internal/Container.py b/module/plugins/internal/Container.py
index 097b04ac7..fc1a93606 100644
--- a/module/plugins/internal/Container.py
+++ b/module/plugins/internal/Container.py
@@ -23,8 +23,9 @@ class Container(Crypter):
def preprocessing(self, thread):
- """Prepare"""
-
+ """
+ Prepare
+ """
self.setup()
self.thread = thread
@@ -37,9 +38,10 @@ class Container(Crypter):
def _load2disk(self):
- """Loads container to disk if its stored remotely and overwrite url,
- or check existent on several places at disk"""
-
+ """
+ Loads container to disk if its stored remotely and overwrite url,
+ or check existent on several places at disk
+ """
if self.pyfile.url.startswith("http"):
self.pyfile.name = re.findall("([^\/=]+)", self.pyfile.url)[-1]
content = self.load(self.pyfile.url)
diff --git a/module/plugins/internal/Crypter.py b/module/plugins/internal/Crypter.py
index a713c7da6..e97f22316 100644
--- a/module/plugins/internal/Crypter.py
+++ b/module/plugins/internal/Crypter.py
@@ -34,8 +34,9 @@ class Crypter(Hoster):
def process(self, pyfile):
- """Main method"""
-
+ """
+ Main method
+ """
self.decrypt(pyfile)
if self.urls:
@@ -52,20 +53,22 @@ class Crypter(Hoster):
def _generate_packages(self):
- """Generate new packages from self.urls"""
-
+ """
+ Generate new packages from self.urls
+ """
packages = [(name, links, None) for name, links in self.core.api.generatePackages(self.urls).iteritems()]
self.packages.extend(packages)
def _create_packages(self):
- """Create new packages from self.packages"""
-
+ """
+ Create new packages from self.packages
+ """
package_folder = self.pyfile.package().folder
package_password = self.pyfile.package().password
package_queue = self.pyfile.package().queue
- folder_per_package = self.core.config.get('general', 'folder_per_package')
+ folder_per_package = self.core.config.get("general", "folder_per_package")
use_subfolder = self.getConfig('use_subfolder', folder_per_package)
subfolder_per_package = self.getConfig('subfolder_per_package', True)
diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py
index 2aa26e64a..f73388d8c 100644
--- a/module/plugins/internal/Extractor.py
+++ b/module/plugins/internal/Extractor.py
@@ -82,7 +82,9 @@ class Extractor(Plugin):
delete='No',
keepbroken=False,
fid=None):
- """Initialize extractor for specific file"""
+ """
+ Initialize extractor for specific file
+ """
self.manager = manager
self.filename = filename
self.out = out
@@ -99,7 +101,9 @@ class Extractor(Plugin):
def init(self):
- """Initialize additional data structures"""
+ """
+ Initialize additional data structures
+ """
pass
@@ -155,5 +159,7 @@ class Extractor(Plugin):
def list(self, password=None):
- """Populate self.files at some point while extracting"""
+ """
+ Populate self.files at some point while extracting
+ """
return self.files
diff --git a/module/plugins/internal/Hook.py b/module/plugins/internal/Hook.py
index 01ffbc5f2..3a0431feb 100644
--- a/module/plugins/internal/Hook.py
+++ b/module/plugins/internal/Hook.py
@@ -6,8 +6,9 @@ from module.plugins.internal.Plugin import Plugin
class Expose(object):
- """Used for decoration to declare rpc services"""
-
+ """
+ Used for decoration to declare rpc services
+ """
def __new__(cls, f, *args, **kwargs):
hookManager.addRPC(f.__module__, f.func_name, f.func_doc)
return f
@@ -113,12 +114,16 @@ class Hook(Plugin):
def setup(self):
- """More init stuff if needed"""
+ """
+ More init stuff if needed
+ """
pass
def is_activated(self):
- """Checks if hook is activated"""
+ """
+ Checks if hook is activated
+ """
return self.getConfig("activated")
@@ -128,7 +133,9 @@ class Hook(Plugin):
def deactivate(self):
- """Called when hook was deactivated"""
+ """
+ Called when hook was deactivated
+ """
pass
@@ -138,7 +145,9 @@ class Hook(Plugin):
def activate(self):
- """Called when hook was activated"""
+ """
+ Called when hook was activated
+ """
pass
@@ -148,7 +157,9 @@ class Hook(Plugin):
def exit(self):
- """Called by core.shutdown just before pyLoad exit"""
+ """
+ Called by core.shutdown just before pyLoad exit
+ """
pass
@@ -212,7 +223,9 @@ class Hook(Plugin):
def captcha_task(self, task):
- """New captcha task for the plugin, it MUST set the handler and timeout or will be ignored"""
+ """
+ New captcha task for the plugin, it MUST set the handler and timeout or will be ignored
+ """
pass
diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py
index 40430c38d..32c3312d0 100644
--- a/module/plugins/internal/Hoster.py
+++ b/module/plugins/internal/Hoster.py
@@ -321,7 +321,6 @@ class Hoster(Plugin):
:return: result of decrypting
"""
-
img = self.load(url, get=get, post=post, cookies=cookies)
id = ("%.2f" % time.time())[-6:].replace(".", "")
diff --git a/module/plugins/internal/MultiHook.py b/module/plugins/internal/MultiHook.py
index 0bcab5915..739b225b4 100644
--- a/module/plugins/internal/MultiHook.py
+++ b/module/plugins/internal/MultiHook.py
@@ -153,7 +153,9 @@ class MultiHook(Hook):
def periodical(self):
- """Reload plugin list periodically"""
+ """
+ Reload plugin list periodically
+ """
self.loadAccount()
if self.getConfig('reload', True):
@@ -244,7 +246,9 @@ class MultiHook(Hook):
def deactivate(self):
- """Remove override for all plugins. Scheduler job is removed by hookmanager"""
+ """
+ Remove override for all plugins. Scheduler job is removed by hookmanager
+ """
for plugin in self.supported:
self.unloadPlugin(plugin)
diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py
index 2d41ab39e..5fe6f2532 100644
--- a/module/plugins/internal/OCR.py
+++ b/module/plugins/internal/OCR.py
@@ -38,7 +38,9 @@ class OCR(Plugin):
def deactivate(self):
- """Delete all tmp images"""
+ """
+ Delete all tmp images
+ """
pass
@@ -47,8 +49,9 @@ class OCR(Plugin):
def run(self, command):
- """Run a command"""
-
+ """
+ Run a command
+ """
popen = subprocess.Popen(command, bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
popen.wait()
output = popen.stdout.read() + " | " + popen.stderr.read()
@@ -189,8 +192,9 @@ class OCR(Plugin):
def derotate_by_average(self):
- """Rotate by checking each angle and guess most suitable"""
-
+ """
+ Rotate by checking each angle and guess most suitable
+ """
w, h = self.image.size
pixels = self.pixels
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index 0d4c3b165..68169e077 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -139,7 +139,9 @@ class Plugin(object):
#: Deprecated method
def setConf(self, *args, **kwargs):
- """See `setConfig`"""
+ """
+ See `setConfig`
+ """
return self.setConfig(*args, **kwargs)
@@ -160,39 +162,53 @@ class Plugin(object):
#: Deprecated method
def getConf(self, *args, **kwargs):
- """See `getConfig`"""
+ """
+ See `getConfig`
+ """
return self.getConfig(*args, **kwargs)
def store(self, key, value):
- """Saves a value persistently to the database"""
+ """
+ Saves a value persistently to the database
+ """
self.core.db.setStorage(self.__name__, key, value)
#: Deprecated method
def setStorage(self, *args, **kwargs):
- """Same as `setStorage`"""
+ """
+ Same as `setStorage`
+ """
return self.store(*args, **kwargs)
def retrieve(self, key, default=None):
- """Retrieves saved value or dict of all saved entries if key is None"""
+ """
+ Retrieves saved value or dict of all saved entries if key is None
+ """
return self.core.db.getStorage(self.__name__, key) or default
#: Deprecated method
def getStorage(self, *args, **kwargs):
- """Same as `getStorage`"""
+ """
+ Same as `getStorage`
+ """
return self.retrieve(*args, **kwargs)
def delStorage(self, key):
- """Delete entry in db"""
+ """
+ Delete entry in db
+ """
self.core.db.delStorage(self.__name__, key)
def fail(self, reason):
- """Fail and give reason"""
+ """
+ Fail and give reason
+ """
raise Fail(fs_encode(reason))
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index db253d950..7685be55a 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -50,7 +50,6 @@ class SimpleCrypter(Crypter, SimpleHoster):
def loadPage(self, page_n):
return the html of the page number page_n
"""
-
#@TODO: Remove in 0.4.10
def init(self):
account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "")
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 979da24a9..067b97747 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -143,7 +143,6 @@ class SimpleHoster(Hoster):
LINK_PREMIUM_PATTERN: (optional) group(1) should be the direct link for premium download
example: LINK_PREMIUM_PATTERN = r'<div class="link"><a href="(.+?)"'
"""
-
NAME_REPLACEMENTS = [("&#?\w+;", fixup)]
SIZE_REPLACEMENTS = []
URL_REPLACEMENTS = []
diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py
index fbce5e2fb..0f4f90128 100644
--- a/module/plugins/internal/XFSHoster.py
+++ b/module/plugins/internal/XFSHoster.py
@@ -56,7 +56,9 @@ class XFSHoster(SimpleHoster):
def prepare(self):
- """ Initialize important variables """
+ """
+ Initialize important variables
+ """
if not self.HOSTER_DOMAIN:
if self.account:
account = self.account