Skip to content

Commit

Permalink
flake8 + isort
Browse files Browse the repository at this point in the history
  • Loading branch information
vuolter committed Jun 3, 2017
1 parent e60c901 commit f980d59
Show file tree
Hide file tree
Showing 82 changed files with 872 additions and 629 deletions.
17 changes: 9 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals

from future import standard_library
standard_library.install_aliases()
import os
import sys
from os.path import abspath, dirname, exists, join

from future import standard_library

standard_library.install_aliases()

dir_name = join(dirname(abspath("")))
sys.path.append(dir_name)
sys.path.append(join(dir_name, "pyload", "lib"))
Expand All @@ -39,8 +38,10 @@

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx',
'sphinx.ext.pngmath', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary',
'sphinx.ext.doctest', 'sphinx.ext.intersphinx',
'sphinx.ext.pngmath', 'sphinx.ext.ifconfig',
'sphinx.ext.viewcode']

autosummary_generate = True
autodoc_default_flags = ['members']
Expand Down
2 changes: 0 additions & 2 deletions src/pyload/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
from future import standard_library
standard_library.install_aliases()
import builtins
import codecs
import locale
import os
import sys
import tempfile

builtins.USERDIR = os.path.expanduser('~')
Expand Down
4 changes: 0 additions & 4 deletions src/pyload/core/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# -*- coding: utf-8 -*-
# @author: vuolter

from __future__ import unicode_literals
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from .init import Api, requireperm, statestring
from .base import AbstractApi, BaseApi
from .account import AccountApi
Expand Down
2 changes: 1 addition & 1 deletion src/pyload/core/api/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ..datatype.init import Permission
from .base import BaseApi
from .init import Api, requireperm
from .init import requireperm

standard_library.install_aliases()

Expand Down
2 changes: 1 addition & 1 deletion src/pyload/core/api/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ..datatype.init import Permission
from .base import BaseApi
from .init import Api, requireperm
from .init import requireperm

standard_library.install_aliases()

Expand Down
52 changes: 24 additions & 28 deletions src/pyload/core/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@
from __future__ import absolute_import, unicode_literals

from future import standard_library
from pyload.utils.convert import to_str

from ..datatype.init import ConfigHolder, ConfigInfo, ConfigItem, Permission
from .base import BaseApi
from .init import Api, requireperm

standard_library.install_aliases()


# @TODO: Recheck...
# TODO: Recheck...
# helper function to create a ConfigHolder
# def to_config_holder(section, config, values):
# holder = ConfigHolder(section, config.label,
# config.description, config.explanation)
# holder.items = [ConfigItem(option, x.label, x.description, x.input,
# to_str(values.get(option, x.input.default), values.get(option, x.input.default))) for option, x in
# config.config.items()]
# return holder
# holder = ConfigHolder(section, config.label,
# config.description, config.explanation)
# holder.items = [ConfigItem(option, x.label, x.description, x.input,
# to_str(values.get(option, x.input.default), values.get(option, x.input.default))) for option, x in
# config.config.items()]
# return holder


class ConfigApi(BaseApi):
"""
Everything related to configuration.
"""

def get_config_value(self, section, option):
"""
Retrieve config value.
Expand Down Expand Up @@ -57,7 +53,7 @@ def set_config_value(self, section, option, value):
# """
# data = {}
# for section, config, values in self.pyload.config.iter_core_sections():
# data[section] = to_config_holder(section, config, values)
# data[section] = to_config_holder(section, config, values)
# return data

# def get_core_config(self):
Expand All @@ -67,7 +63,7 @@ def set_config_value(self, section, option, value):
# :rtype: list of PluginInfo
# """
# return [ConfigInfo(section, config.label, config.description, False, False)
# for section, config, values in self.pyload.config.iter_core_sections()]
# for section, config, values in self.pyload.config.iter_core_sections()]

# @requireperm(Permission.Plugins)
# def get_plugin_config(self):
Expand All @@ -82,17 +78,17 @@ def set_config_value(self, section, option, value):
# data = []
# active = [x.get_name() for x in self.pyload.adm.active_plugins()]
# for name, config, values in self.pyload.config.iter_sections():
# # skip unmodified and inactive addons
# if not values and name not in active:
# continue

# item = ConfigInfo(name, config.label, config.description,
# self.pyload.pgm.get_category(name),
# self.pyload.pgm.is_user_plugin(name),
# # TODO: won't work probably
# values.get("activated",
# None if "activated" not in config.config else config.config['activated'].input.default))
# data.append(item)
# # skip unmodified and inactive addons
# if not values and name not in active:
# continue

# item = ConfigInfo(name, config.label, config.description,
# self.pyload.pgm.get_category(name),
# self.pyload.pgm.is_user_plugin(name),
# # TODO: won't work probably
# values.get("activated",
# None if "activated" not in config.config else config.config['activated'].input.default))
# data.append(item)

# return data

Expand All @@ -105,9 +101,9 @@ def set_config_value(self, section, option, value):
# """
# # TODO: filter user_context / addons when not allowed
# plugins = [ConfigInfo(name, config.label, config.description,
# self.pyload.pgm.get_category(name),
# self.pyload.pgm.is_user_plugin(name))
# for name, config, values in self.pyload.config.iter_sections()]
# self.pyload.pgm.get_category(name),
# self.pyload.pgm.is_user_plugin(name))
# for name, config, values in self.pyload.config.iter_sections()]

# return plugins

Expand All @@ -132,7 +128,7 @@ def set_config_value(self, section, option, value):
# :param config: :class:`ConfigHolder`
# """
# for item in config.items:
# self.pyload.config.set(config.name, item.name, item.value, store=False)
# self.pyload.config.set(config.name, item.name, item.value, store=False)
# # save the changes
# self.pyload.config.store()

Expand Down
12 changes: 6 additions & 6 deletions src/pyload/core/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import os

from future import standard_library

from pyload.utils.fs import availspace, lopen
from semver import format_version

from ..datatype.init import Permission, StatusInfo
from ..datatype.task import Interaction
from .base import BaseApi
from .init import Api, requireperm
from .init import requireperm

standard_library.install_aliases()

Expand Down Expand Up @@ -48,9 +48,9 @@ def is_ws_secure(self):
# Gets and address for the websocket based on configuration.
# """
# if self.is_ws_secure():
# ws = "wss"
# ws = "wss"
# else:
# ws = "ws"
# ws = "ws"

# return "{0}://{{0}}:{1:d}".format(ws, self.pyload.config.get('rpc', 'port'))

Expand All @@ -69,15 +69,15 @@ def get_status_info(self):
total[1], queue[1],
self.is_interaction_waiting(
Interaction.All),
not self.pyload.tsm.pause, #: and self.is_time_download(),
not self.pyload.tsm.pause, # and self.is_time_download(),
self.pyload.tsm.pause,
# and self.is_time_reconnect(),
self.pyload.config.get(
'reconnect', 'activated'),
self.get_quota())

for file in self.pyload.tsm.active_downloads():
server_status.speed += file.get_speed() #: bytes/s
server_status.speed += file.get_speed() # bytes/s

return server_status

Expand Down
7 changes: 4 additions & 3 deletions src/pyload/core/api/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
from builtins import str

from future import standard_library

from pyload.utils.fs import lopen

from ..datatype.init import Permission
from ..datatype.user import Role
from .base import BaseApi
from .init import Api, requireperm
from .init import requireperm

standard_library.install_aliases()

Expand Down Expand Up @@ -105,8 +106,8 @@ def add_links(self, pid, links):
if hoster:
self.pyload.iom.create_info_thread(hoster, pid)

self.pyload.log.info(
(self._("Added {0:d} links to package") + " #{0:d}".format(pid)).format(len(hoster + crypter)))
self.pyload.log.info((self._(
"Added {0:d} links to package") + " #{0:d}".format(pid)).format(len(hoster + crypter)))
self.pyload.files.save()

@requireperm(Permission.Add)
Expand Down
2 changes: 1 addition & 1 deletion src/pyload/core/api/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ..datatype.init import Permission
from ..datatype.task import Interaction
from .base import BaseApi
from .init import Api, requireperm
from .init import requireperm

standard_library.install_aliases()

Expand Down
15 changes: 8 additions & 7 deletions src/pyload/core/api/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from __future__ import absolute_import, unicode_literals

from future import standard_library

from pyload.utils.purge import uniqify

from ..datatype.file import FileDoesNotExist
from ..datatype.init import DownloadState, Permission
from ..datatype.package import PackageDoesNotExist, PackageStatus
from .base import BaseApi
from .init import Api, requireperm
from .init import requireperm

standard_library.install_aliases()

Expand All @@ -21,12 +22,12 @@ class FileApi(BaseApi):
"""

# def check_result(self, info):
# """
# Internal method to verify result and owner.
# """
# TODO: shared?
# return info and (not self.primary_uid or info.owner ==
# self.primary_uid)
# """
# Internal method to verify result and owner.
# """
# TODO: shared?
# return info and (not self.primary_uid or info.owner ==
# self.primary_uid)

@requireperm(Permission.All)
def get_all_files(self):
Expand Down
14 changes: 7 additions & 7 deletions src/pyload/core/api/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from __future__ import absolute_import, unicode_literals

from builtins import object, str
from types import MethodType

from future import standard_library
from types import MethodType

from ..datatype.init import DownloadState, DownloadStatus, Permission
from ..datatype.user import User
Expand Down Expand Up @@ -34,7 +34,7 @@ def __new__(cls, func, *args, **kwargs):
statemap = {
DownloadState.All: frozenset(getattr(DownloadStatus, x) for x in dir(DownloadStatus) if not x.startswith("_")),
DownloadState.Finished: frozenset((DownloadStatus.Finished, DownloadStatus.Skipped)),
DownloadState.Unfinished: None, #: set below
DownloadState.Unfinished: None, # set below
DownloadState.Failed: frozenset((DownloadStatus.Failed, DownloadStatus.TempOffline, DownloadStatus.Aborted,
DownloadStatus.NotPossible, DownloadStatus.FileMismatch)),
DownloadState.Unmanaged: None,
Expand All @@ -60,8 +60,8 @@ class Api(AbstractApi):
These can be configured via web interface.
Admin user have all permissions, and are the only ones who can access the methods with no specific permission
"""
EXTERNAL = AbstractApi #: let the json api know which methods are external
EXTEND = False #: only extendable when set too true
EXTERNAL = AbstractApi # let the json api know which methods are external
EXTEND = False # only extendable when set too true

def __init__(self, core):
self.pyload = core
Expand Down Expand Up @@ -144,7 +144,8 @@ def check_auth(self, username, password, remoteip=None):
:param remoteip:
:return: dict with info, empty when login is incorrect
"""
self.pyload.log.info(self._("User '{0}' tries to log in").format(username))
self.pyload.log.info(
self._("User '{0}' tries to log in").format(username))

return self.pyload.db.check_auth(username, password)

Expand All @@ -169,9 +170,8 @@ class UserApi(Api):
"""
Proxy object for api that provides all methods in user context.
"""

def __init__(self, core, user):
#: No need to init super class
# No need to init super class
self.pyload = core
self._user = user

Expand Down
3 changes: 2 additions & 1 deletion src/pyload/core/api/predownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
from itertools import chain

from future import standard_library

from pyload.utils import parse
from pyload.utils.fs import lopen
from pyload.utils.purge import uniqify

from ..datatype.check import OnlineCheck
from ..datatype.init import DownloadStatus, LinkStatus, Permission
from .base import BaseApi
from .init import Api, requireperm
from .init import requireperm

standard_library.install_aliases()

Expand Down
2 changes: 0 additions & 2 deletions src/pyload/core/api/stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from future import standard_library

from .base import BaseApi
from .init import Api

standard_library.install_aliases()

Expand All @@ -18,7 +17,6 @@ class StatisticsApi(BaseApi):
"""
Retrieve download statistics and quota.
"""

def record_download(self, file):
"""
Add download record to the statistics.
Expand Down
2 changes: 1 addition & 1 deletion src/pyload/core/api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ..datatype.init import Permission
from .base import BaseApi
from .init import Api, requireperm
from .init import requireperm

standard_library.install_aliases()

Expand Down
Loading

0 comments on commit f980d59

Please sign in to comment.