diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-17 17:28:58 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-17 17:28:58 +0200 |
commit | 938b7e6141e2895c7d41b0e8ef4b9416912e2e9e (patch) | |
tree | 6ceef0718139a13ced3fb607634fa60fc81212c4 | |
parent | Spare code cosmetics (3) (diff) | |
download | pyload-938b7e6141e2895c7d41b0e8ef4b9416912e2e9e.tar.xz |
Spare code cosmetics (4)
28 files changed, 76 insertions, 3 deletions
diff --git a/docs/write_addons.rst b/docs/write_addons.rst index 9f4436cc5..cc39ab259 100644 --- a/docs/write_addons.rst +++ b/docs/write_addons.rst @@ -18,6 +18,7 @@ All addons should start with something like this: :: from pyload.plugin.Addon import Addon + class YourAddon(Addon): __name = "YourAddon" __version = "0.1" @@ -53,6 +54,7 @@ A basic excerpt would look like: :: from pyload.plugin.Addon import Addon + class YourAddon(Addon): """ Your Addon code here. @@ -73,6 +75,7 @@ It requires a `dict` that maps event names to function names or a `list` of func from pyload.plugin.Addon import Addon + class YourAddon(Addon): """ Your Addon code here. @@ -109,6 +112,7 @@ Sounds complicated but is very easy to do. Just use the ``Expose`` decorator: :: from pyload.plugin.Addon import Addon, Expose + class YourAddon(Addon): """ Your Addon code here. @@ -134,6 +138,7 @@ Just store everything in ``self.info``. :: from pyload.plugin.Addon import Addon + class YourAddon(Addon): """ Your Addon code here. diff --git a/docs/write_plugins.rst b/docs/write_plugins.rst index 64868d638..af35a8d55 100644 --- a/docs/write_plugins.rst +++ b/docs/write_plugins.rst @@ -21,6 +21,7 @@ How basic hoster plugin header could look like: :: from pyload.plugin.Hoster import Hoster + class MyFileHoster(Hoster): __name = "MyFileHoster" __version = "0.1" @@ -43,6 +44,7 @@ An example ``process`` function could look like this :: from pyload.plugin.Hoster import Hoster + class MyFileHoster(Hoster): """ plugin code @@ -83,6 +85,7 @@ Example: :: from pyload.plugin.Crypter import Crypter + class MyFileCrypter(Crypter): """ plugin code diff --git a/pyload/Core.py b/pyload/Core.py index dd31b95e4..cd210344d 100755 --- a/pyload/Core.py +++ b/pyload/Core.py @@ -45,6 +45,7 @@ sys.stdout = getwriter(enc)(sys.stdout, errors="replace") # - configurable auth system ldap/mysql # - cron job like sheduler + class Core(object): """pyLoad Core, one tool to rule them all... (the filehosters) :D""" diff --git a/pyload/api/__init__.py b/pyload/api/__init__.py index 62af70cf8..676e76d7b 100644 --- a/pyload/api/__init__.py +++ b/pyload/api/__init__.py @@ -38,7 +38,6 @@ permMap = {} # decorator only called on init, never initialized, so has no effect on runtime def permission(bits): class _Dec(object): - def __new__(cls, func, *args, **kwargs): permMap[func.__name__] = bits return func diff --git a/pyload/api/types.py b/pyload/api/types.py index 10a64a813..2fd089333 100644 --- a/pyload/api/types.py +++ b/pyload/api/types.py @@ -2,13 +2,16 @@ # Autogenerated by pyload # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + class BaseObject(object): __slots__ = [] + class Destination(object): Collector = 0 Queue = 1 + class DownloadStatus(object): Aborted = 9 Custom = 11 @@ -26,10 +29,12 @@ class DownloadStatus(object): Unknown = 14 Waiting = 5 + class ElementType(object): File = 1 Package = 0 + class Input(object): BOOL = 4 CHOICE = 6 @@ -42,11 +47,13 @@ class Input(object): TEXT = 1 TEXTBOX = 2 + class Output(object): CAPTCHA = 1 NOTIFICATION = 4 QUESTION = 2 + class AccountInfo(BaseObject): __slots__ = ['validuntil', 'login', 'options', 'valid', 'trafficleft', 'maxtraffic', 'premium', 'type'] @@ -61,6 +68,7 @@ class AccountInfo(BaseObject): self.premium = premium self.type = type + class CaptchaTask(BaseObject): __slots__ = ['tid', 'data', 'type', 'resultType'] @@ -71,6 +79,7 @@ class CaptchaTask(BaseObject): self.type = type self.resultType = resultType + class ConfigItem(BaseObject): __slots__ = ['name', 'description', 'value', 'type'] @@ -81,6 +90,7 @@ class ConfigItem(BaseObject): self.value = value self.type = type + class ConfigSection(BaseObject): __slots__ = ['name', 'description', 'items', 'outline'] @@ -91,6 +101,7 @@ class ConfigSection(BaseObject): self.items = items self.outline = outline + class DownloadInfo(BaseObject): __slots__ = ['fid', 'name', 'speed', 'eta', 'format_eta', 'bleft', 'size', 'format_size', 'percent', 'status', 'statusmsg', 'format_wait', 'wait_until', 'packageID', 'packageName', 'plugin'] @@ -113,6 +124,7 @@ class DownloadInfo(BaseObject): self.packageName = packageName self.plugin = plugin + class EventInfo(BaseObject): __slots__ = ['eventname', 'id', 'type', 'destination'] @@ -123,6 +135,7 @@ class EventInfo(BaseObject): self.type = type self.destination = destination + class FileData(BaseObject): __slots__ = ['fid', 'url', 'name', 'plugin', 'size', 'format_size', 'status', 'statusmsg', 'packageID', 'error', 'order'] @@ -140,6 +153,7 @@ class FileData(BaseObject): self.error = error self.order = order + class FileDoesNotExists(Exception): __slots__ = ['fid'] @@ -147,6 +161,7 @@ class FileDoesNotExists(Exception): def __init__(self, fid=None): self.fid = fid + class InteractionTask(BaseObject): __slots__ = ['iid', 'input', 'structure', 'preset', 'output', 'data', 'title', 'description', 'plugin'] @@ -162,6 +177,7 @@ class InteractionTask(BaseObject): self.description = description self.plugin = plugin + class OnlineCheck(BaseObject): __slots__ = ['rid', 'data'] @@ -170,6 +186,7 @@ class OnlineCheck(BaseObject): self.rid = rid self.data = data + class OnlineStatus(BaseObject): __slots__ = ['name', 'plugin', 'packagename', 'status', 'size'] @@ -181,6 +198,7 @@ class OnlineStatus(BaseObject): self.status = status self.size = size + class PackageData(BaseObject): __slots__ = ['pid', 'name', 'folder', 'site', 'password', 'dest', 'order', 'linksdone', 'sizedone', 'sizetotal', 'linkstotal', 'links', 'fids'] @@ -200,6 +218,7 @@ class PackageData(BaseObject): self.links = links self.fids = fids + class PackageDoesNotExists(Exception): __slots__ = ['pid'] @@ -207,6 +226,7 @@ class PackageDoesNotExists(Exception): def __init__(self, pid=None): self.pid = pid + class ServerStatus(BaseObject): __slots__ = ['pause', 'active', 'queue', 'total', 'speed', 'download', 'reconnect'] @@ -220,6 +240,7 @@ class ServerStatus(BaseObject): self.download = download self.reconnect = reconnect + class ServiceCall(BaseObject): __slots__ = ['plugin', 'func', 'arguments', 'parseArguments'] @@ -230,6 +251,7 @@ class ServiceCall(BaseObject): self.arguments = arguments self.parseArguments = parseArguments + class ServiceDoesNotExists(Exception): __slots__ = ['plugin', 'func'] @@ -238,6 +260,7 @@ class ServiceDoesNotExists(Exception): self.plugin = plugin self.func = func + class ServiceException(Exception): __slots__ = ['msg'] @@ -245,6 +268,7 @@ class ServiceException(Exception): def __init__(self, msg=None): self.msg = msg + class UserData(BaseObject): __slots__ = ['name', 'email', 'role', 'permission', 'templateName'] @@ -256,6 +280,7 @@ class UserData(BaseObject): self.permission = permission self.templateName = templateName + class Iface(object): def addFiles(self, pid, links): diff --git a/pyload/cli/Cli.py b/pyload/cli/Cli.py index fba6dc3da..7b30d5f44 100644 --- a/pyload/cli/Cli.py +++ b/pyload/cli/Cli.py @@ -35,6 +35,7 @@ from pyload.remote.thriftbackend.ThriftClient import ThriftClient, NoConnection, from Getch import Getch from rename_process import renameProcess + class Cli(object): def __init__(self, client, command): diff --git a/pyload/cli/Handler.py b/pyload/cli/Handler.py index 33e5dd8e6..444d7f6d0 100644 --- a/pyload/cli/Handler.py +++ b/pyload/cli/Handler.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # @author: RaNaN + class Handler(object): def __init__(self, cli): diff --git a/pyload/database/Backend.py b/pyload/database/Backend.py index 45a5c7361..cfdee058e 100644 --- a/pyload/database/Backend.py +++ b/pyload/database/Backend.py @@ -18,6 +18,7 @@ except Exception: DB_VERSION = 4 + class style(object): db = None @@ -59,6 +60,7 @@ class style(object): return cls.db.async(f, *args, **kwargs) return x + class DatabaseJob(object): def __init__(self, f, *args, **kwargs): @@ -106,6 +108,7 @@ class DatabaseJob(object): def wait(self): self.done.wait() + class DatabaseBackend(Thread): subs = [] diff --git a/pyload/database/Storage.py b/pyload/database/Storage.py index a1dfb7e9f..45ad18b2d 100644 --- a/pyload/database/Storage.py +++ b/pyload/database/Storage.py @@ -4,6 +4,7 @@ from pyload.database import style from pyload.database import DatabaseBackend + class StorageMethods(object): diff --git a/pyload/database/User.py b/pyload/database/User.py index 94f70d499..374570fb7 100644 --- a/pyload/database/User.py +++ b/pyload/database/User.py @@ -6,6 +6,7 @@ import random from pyload.database import DatabaseBackend, style + class UserMethods(object): diff --git a/pyload/datatype/Package.py b/pyload/datatype/Package.py index 7a36a1323..5ba42f596 100644 --- a/pyload/datatype/Package.py +++ b/pyload/datatype/Package.py @@ -4,6 +4,7 @@ from pyload.manager.Event import UpdateEvent from pyload.utils import safe_filename + class PyPackage(object): """ Represents a package object at runtime diff --git a/pyload/manager/Event.py b/pyload/manager/Event.py index 90aaaca30..b3d22619f 100644 --- a/pyload/manager/Event.py +++ b/pyload/manager/Event.py @@ -4,6 +4,7 @@ from time import time from pyload.utils import uniqify + class PullManager(object): def __init__(self, core): @@ -41,6 +42,7 @@ class PullManager(object): for client in self.clients: client.addEvent(event) + class Client(object): def __init__(self, uuid): @@ -62,6 +64,7 @@ class Client(object): def addEvent(self, event): self.events.append(event) + class UpdateEvent(object): def __init__(self, itype, iid, destination): @@ -75,6 +78,7 @@ class UpdateEvent(object): def toList(self): return ["update", self.destination, self.type, self.id] + class RemoveEvent(object): def __init__(self, itype, iid, destination): @@ -88,6 +92,7 @@ class RemoveEvent(object): def toList(self): return ["remove", self.destination, self.type, self.id] + class InsertEvent(object): def __init__(self, itype, iid, after, destination): @@ -102,6 +107,7 @@ class InsertEvent(object): def toList(self): return ["insert", self.destination, self.type, self.id, self.after] + class ReloadAllEvent(object): def __init__(self, destination): @@ -112,11 +118,13 @@ class ReloadAllEvent(object): def toList(self): return ["reload", self.destination] + class AccountUpdateEvent(object): def toList(self): return ["account"] + class ConfigUpdateEvent(object): def toList(self): diff --git a/pyload/network/HTTPChunk.py b/pyload/network/HTTPChunk.py index 82e1ca76e..8a9c4803f 100644 --- a/pyload/network/HTTPChunk.py +++ b/pyload/network/HTTPChunk.py @@ -12,6 +12,7 @@ import urllib from pyload.network.HTTPRequest import HTTPRequest + class WrongFormat(Exception): pass diff --git a/pyload/network/RequestFactory.py b/pyload/network/RequestFactory.py index a80882088..49cfedce6 100644 --- a/pyload/network/RequestFactory.py +++ b/pyload/network/RequestFactory.py @@ -10,6 +10,7 @@ from pyload.network.CookieJar import CookieJar from pyload.network.XDCCRequest import XDCCRequest + class RequestFactory(object): def __init__(self, core): diff --git a/pyload/plugin/account/OboomCom.py b/pyload/plugin/account/OboomCom.py index 68e083d75..8b33d0612 100644 --- a/pyload/plugin/account/OboomCom.py +++ b/pyload/plugin/account/OboomCom.py @@ -8,6 +8,7 @@ try: except ImportError: from beaker.crypto.pbkdf2 import pbkdf2 from binascii import b2a_hex + class PBKDF2(object): def __init__(self, passphrase, salt, iterations=1000): diff --git a/pyload/plugin/account/SmoozedCom.py b/pyload/plugin/account/SmoozedCom.py index ae247b2b0..f24799caf 100644 --- a/pyload/plugin/account/SmoozedCom.py +++ b/pyload/plugin/account/SmoozedCom.py @@ -9,6 +9,7 @@ try: except ImportError: from beaker.crypto.pbkdf2 import pbkdf2 from binascii import b2a_hex + class PBKDF2(object): def __init__(self, passphrase, salt, iterations=1000): diff --git a/pyload/plugin/addon/XMPPInterface.py b/pyload/plugin/addon/XMPPInterface.py index 2733cfde0..c977042e6 100644 --- a/pyload/plugin/addon/XMPPInterface.py +++ b/pyload/plugin/addon/XMPPInterface.py @@ -210,7 +210,6 @@ class XMPPInterface(IRCInterface, JabberClient): class VersionHandler(object): """Provides handler for a version query. - This class will answer version query and announce 'jabber:iq:version' namespace in the client's disco#info results.""" diff --git a/pyload/plugin/internal/SimpleHoster.py b/pyload/plugin/internal/SimpleHoster.py index add54786f..642ec2df7 100644 --- a/pyload/plugin/internal/SimpleHoster.py +++ b/pyload/plugin/internal/SimpleHoster.py @@ -418,7 +418,7 @@ class SimpleHoster(Hoster): self.info = {} self.html = "" - self.link = "" #@TODO: Move to hoster class in 0.4.10 + self.link = "" #@TODO: Move to hoster class in 0.4.10 self.directDL = False #@TODO: Move to hoster class in 0.4.10 self.multihost = False #@TODO: Move to hoster class in 0.4.10 diff --git a/pyload/remote/ClickNLoadBackend.py b/pyload/remote/ClickNLoadBackend.py index 31678ab8b..5c08986a7 100644 --- a/pyload/remote/ClickNLoadBackend.py +++ b/pyload/remote/ClickNLoadBackend.py @@ -18,6 +18,7 @@ from pyload.manager.Remote import BackendBase core = None js = None + class ClickNLoadBackend(BackendBase): def setup(self, host, port): @@ -31,6 +32,7 @@ class ClickNLoadBackend(BackendBase): while self.enabled: self.httpd.handle_request() + class CNLHandler(BaseHTTPRequestHandler): def add_package(self, name, urls, queue=0): diff --git a/pyload/remote/ThriftBackend.py b/pyload/remote/ThriftBackend.py index 0ac7f1bb5..a6f1841e2 100644 --- a/pyload/remote/ThriftBackend.py +++ b/pyload/remote/ThriftBackend.py @@ -13,6 +13,7 @@ from pyload.remote.thriftbackend.Transport import TransportFactory from thrift.server import TServer + class ThriftBackend(BackendBase): def setup(self, host, port): diff --git a/pyload/remote/socketbackend/create_ttypes.py b/pyload/remote/socketbackend/create_ttypes.py index 72bc4c231..722da8d56 100644 --- a/pyload/remote/socketbackend/create_ttypes.py +++ b/pyload/remote/socketbackend/create_ttypes.py @@ -37,6 +37,7 @@ def main(): # Autogenerated by pyload # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + class BaseObject(object): \t__slots__ = [] diff --git a/pyload/remote/thriftbackend/Socket.py b/pyload/remote/thriftbackend/Socket.py index 4dd66e368..3d2435a92 100644 --- a/pyload/remote/thriftbackend/Socket.py +++ b/pyload/remote/thriftbackend/Socket.py @@ -10,6 +10,7 @@ from thrift.transport.TSocket import TSocket, TServerSocket, TTransportException WantReadError = Exception #: overwritten when ssl is used + class SecureSocketConnection(object): def __init__(self, connection): @@ -48,6 +49,7 @@ class SecureSocketConnection(object): sleep(0.1) return self.recv(buff) + class Socket(TSocket): def __init__(self, host='localhost', port=7228, ssl=False): diff --git a/pyload/remote/thriftbackend/ThriftClient.py b/pyload/remote/thriftbackend/ThriftClient.py index 60a4e9ca9..4f1c8dcc2 100644 --- a/pyload/remote/thriftbackend/ThriftClient.py +++ b/pyload/remote/thriftbackend/ThriftClient.py @@ -18,15 +18,19 @@ from pyload.remote.thriftbackend.thriftgen.pyload.ttypes import * ConnectionClosed = TTransport.TTransportException + class WrongLogin(Exception): pass + class NoConnection(Exception): pass + class NoSSL(Exception): pass + class ThriftClient(object): def __init__(self, host="localhost", port=7227, user="", password=""): diff --git a/pyload/remote/thriftbackend/Transport.py b/pyload/remote/thriftbackend/Transport.py index 7ecb16746..1d3d81718 100644 --- a/pyload/remote/thriftbackend/Transport.py +++ b/pyload/remote/thriftbackend/Transport.py @@ -3,6 +3,7 @@ from thrift.transport.TTransport import TBufferedTransport from thrift.transport.TZlibTransport import TZlibTransport + class Transport(TBufferedTransport): DEFAULT_BUFFER = 4096 @@ -12,6 +13,7 @@ class Transport(TBufferedTransport): self.handle = trans.handle self.remoteaddr = trans.handle.getpeername() + class TransportCompressed(TZlibTransport): DEFAULT_BUFFER = 4096 @@ -21,12 +23,14 @@ class TransportCompressed(TZlibTransport): self.handle = trans.handle self.remoteaddr = trans.handle.getpeername() + class TransportFactory(object): def getTransport(self, trans): buffered = Transport(trans) return buffered + class TransportFactoryCompressed(object): _last_trans = None _last_z = None diff --git a/pyload/remote/thriftbackend/thriftgen/pyload/Pyload.py b/pyload/remote/thriftbackend/thriftgen/pyload/Pyload.py index 350fe4bc7..1ba11dbb6 100644 --- a/pyload/remote/thriftbackend/thriftgen/pyload/Pyload.py +++ b/pyload/remote/thriftbackend/thriftgen/pyload/Pyload.py @@ -3652,6 +3652,7 @@ class Processor(Iface, TProcessor): # HELPER FUNCTIONS AND STRUCTURES + class getConfigValue_args(TBase): """ Attributes: diff --git a/pyload/remote/thriftbackend/thriftgen/pyload/ttypes.py b/pyload/remote/thriftbackend/thriftgen/pyload/ttypes.py index 1c18f6421..8abd775a9 100644 --- a/pyload/remote/thriftbackend/thriftgen/pyload/ttypes.py +++ b/pyload/remote/thriftbackend/thriftgen/pyload/ttypes.py @@ -64,6 +64,7 @@ class DownloadStatus(TBase): "Unknown": 14, } + class Destination(TBase): Collector = 0 Queue = 1 @@ -78,6 +79,7 @@ class Destination(TBase): "Queue": 1, } + class ElementType(TBase): Package = 0 File = 1 @@ -92,6 +94,7 @@ class ElementType(TBase): "File": 1, } + class Input(TBase): NONE = 0 TEXT = 1 @@ -130,6 +133,7 @@ class Input(TBase): "TABLE": 9, } + class Output(TBase): CAPTCHA = 1 QUESTION = 2 diff --git a/pyload/webui/app/api.py b/pyload/webui/app/api.py index 2ec342fe2..267b9b37c 100644 --- a/pyload/webui/app/api.py +++ b/pyload/webui/app/api.py @@ -13,6 +13,7 @@ from pyload.utils import json from SafeEval import const_eval as literal_eval from pyload.api import BaseObject + # json encoder that accepts TBase objects class TBaseEncoder(json.JSONEncoder): diff --git a/tests/APIExerciser.py b/tests/APIExerciser.py index 38dd9fceb..7eec6f828 100644 --- a/tests/APIExerciser.py +++ b/tests/APIExerciser.py @@ -34,6 +34,7 @@ def startApiExerciser(core, n): for i in range(n): APIExerciser(core).start() + class APIExerciser(Thread): def __init__(self, core, thrift=False, user=None, pw=None): |