[Flake8] Fix import and docstrings issues

This commit is contained in:
Calum Lind 2018-05-19 23:39:02 +01:00
parent ff85c334c7
commit ee196f5035
18 changed files with 37 additions and 33 deletions

View file

@ -210,15 +210,15 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
"""
Sends an error response with the contents of the exception that was raised.
"""
exceptionType, exceptionValue, dummy_exceptionTraceback = sys.exc_info()
exc_type, exc_value, dummy_exc_trace = sys.exc_info()
formated_tb = traceback.format_exc()
try:
self.sendData((
RPC_ERROR,
request_id,
exceptionType.__name__,
exceptionValue._args,
exceptionValue._kwargs,
exc_type.__name__,
exc_value._args,
exc_value._kwargs,
formated_tb
))
except AttributeError:
@ -227,7 +227,8 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
'client. Wrapping it and resending. Error to '
'send(causing exception goes next):\n%s', formated_tb)
try:
raise WrappedException(str(exceptionValue), exceptionType.__name__, formated_tb)
raise WrappedException(
str(exc_value), exc_type.__name__, formated_tb)
except WrappedException:
send_error()
except Exception as ex:

View file

@ -23,10 +23,10 @@ class DelugeEventMetaClass(type):
"""
This metaclass simply keeps a list of all events classes created.
"""
def __init__(self, name, bases, dct): # pylint: disable=bad-mcs-method-argument
super(DelugeEventMetaClass, self).__init__(name, bases, dct)
def __init__(cls, name, bases, dct): # pylint: disable=bad-mcs-method-argument
super(DelugeEventMetaClass, cls).__init__(name, bases, dct)
if name != 'DelugeEvent':
known_events[name] = self
known_events[name] = cls
class DelugeEvent(object):

View file

@ -162,12 +162,12 @@ class Core(CorePluginBase):
@export
def set_config(self, config):
'sets the config dictionary'
"""Sets the config dictionary."""
for key in config:
self.config[key] = config[key]
self.config.save()
@export
def get_config(self):
'returns the config dictionary'
"""Returns the config dictionary."""
return self.config.config

View file

@ -70,7 +70,7 @@ class LabelSidebarMenu(object):
self.options_dialog.show(self.treeview.value)
def on_show(self, widget=None, data=None):
'No Label:disable options/del'
"""No Label:disable options/del."""
log.debug('label-sidebar-popup:on-show')
cat = self.treeview.cat
@ -182,7 +182,7 @@ class OptionsDialog(object):
self.apply_sensitivity()
def on_options_ok(self, event=None):
'save options..'
"""Save options."""
options = {}
for spin_id in self.spin_ids:

View file

@ -205,14 +205,14 @@ class Core(CorePluginBase, CoreNotifications):
@export
def set_config(self, config):
'sets the config dictionary'
"""Sets the config dictionary."""
for key in config:
self.config[key] = config[key]
self.config.save()
@export
def get_config(self):
'returns the config dictionary'
"""Returns the config dictionary."""
return self.config.config
@export

View file

@ -508,7 +508,7 @@ class GtkUI(GtkPluginBase, GtkUiNotifications):
client.notifications.get_config().addCallback(self.cb_get_config)
def cb_get_config(self, core_config):
'callback for on show_prefs'
"""Callback for on show_prefs."""
self.builder.get_object('smtp_host').set_text(core_config['smtp_host'])
self.builder.get_object('smtp_port').set_value(core_config['smtp_port'])
self.builder.get_object('smtp_user').set_text(core_config['smtp_user'])

View file

@ -147,7 +147,7 @@ class Core(CorePluginBase):
@export()
def set_config(self, config):
'sets the config dictionary'
"""Sets the config dictionary."""
for key in config:
self.config[key] = config[key]
self.config.save()
@ -155,7 +155,7 @@ class Core(CorePluginBase):
@export()
def get_config(self):
'returns the config dictionary'
"""Returns the config dictionary."""
return self.config.config
@export()

View file

@ -197,17 +197,17 @@ class Core(CorePluginBase):
@export
def set_config(self, config):
'sets the config dictionary'
"""Sets the config dictionary."""
for key in config:
self.config[key] = config[key]
self.config.save()
@export
def get_config(self):
'returns the config dictionary'
"""Returns the config dictionary."""
return self.config.config
@export
def get_intervals(self):
'Returns the available resolutions'
"""Returns the available resolutions."""
return self.intervals

View file

@ -272,5 +272,5 @@ class GtkUI(GtkPluginBase):
client.stats.get_config().addCallback(self.cb_get_config)
def cb_get_config(self, config):
'callback for on show_prefs'
"""Callback for on show_prefs."""
pass

View file

@ -96,7 +96,7 @@ class Core(CorePluginBase):
@export
def set_config(self, config):
'sets the config dictionary'
"""Sets the config dictionary."""
action = None
if 'enabled' in config:
@ -120,5 +120,5 @@ class Core(CorePluginBase):
@export
def get_config(self):
'returns the config dictionary'
"""Returns the config dictionary."""
return self.config.config

View file

@ -57,7 +57,7 @@ class GtkUI(GtkPluginBase):
client.webui.get_config().addCallback(self.cb_get_config)
def cb_get_config(self, config):
'callback for on show_prefs'
"""Callback for on show_prefs."""
self.builder.get_object('enabled_checkbutton').set_active(config['enabled'])
self.builder.get_object('ssl_checkbutton').set_active(config['ssl'])
self.builder.get_object('port_spinbutton').set_value(config['port'])

View file

@ -17,7 +17,7 @@ from . import BaseCommand
class Command(BaseCommand):
'Shutdown the deluge server'
"""Shutdown the deluge server."""
def handle(self, options):
self.console = component.get('ConsoleUI')

View file

@ -20,8 +20,8 @@ import deluge.configmanager
from deluge.decorators import overrides
from deluge.ui.console.cmdline.command import Commander
from deluge.ui.console.modes.basemode import BaseMode, move_cursor
from deluge.ui.console.utils import curses_util as util
from deluge.ui.console.utils import colors
from deluge.ui.console.utils import curses_util as util
from deluge.ui.console.utils.format_utils import delete_alt_backspace, remove_formatting, strwidth
try:
@ -36,7 +36,10 @@ MAX_HISTFILE_SIZE = 2000
def complete_line(line, possible_matches):
'Find the common prefix of possible matches, proritizing matching-case elements'
"""Find the common prefix of possible matches.
Proritizing matching-case elements.
"""
if not possible_matches:
return line
@ -80,7 +83,7 @@ def complete_line(line, possible_matches):
def commonprefix(m):
'Given a list of pathnames, returns the longest common leading component'
"""Returns the longest common leading component from list of pathnames."""
if not m:
return ''
s1 = min(m)

View file

@ -18,8 +18,8 @@ from deluge.ui.client import client
from deluge.ui.common import FILE_PRIORITY
from deluge.ui.console.modes.basemode import BaseMode
from deluge.ui.console.modes.torrentlist.torrentactions import ACTION, torrent_actions_popup
from deluge.ui.console.utils import curses_util as util
from deluge.ui.console.utils import colors
from deluge.ui.console.utils import curses_util as util
from deluge.ui.console.utils.column import get_column_value, torrent_data_fields
from deluge.ui.console.utils.format_utils import format_priority, format_progress, format_row
from deluge.ui.console.widgets.popup import InputPopup, MessagePopup, PopupsHandler, SelectablePopup

View file

@ -216,7 +216,7 @@ class TorrentView(InputKeyHandler):
return False
def _sort_torrents(self, state):
'sorts by primary and secondary sort fields'
"""Sorts by primary and secondary sort fields."""
if not state:
return {}

View file

@ -16,8 +16,8 @@ import os
from deluge.decorators import overrides
from deluge.ui.console.modes.basemode import InputKeyHandler
from deluge.ui.console.utils import curses_util as util
from deluge.ui.console.utils import colors
from deluge.ui.console.utils import curses_util as util
from deluge.ui.console.utils.format_utils import delete_alt_backspace, remove_formatting, wrap_string
try:

View file

@ -228,7 +228,7 @@ class SelectablePopup(BaseInputPane, Popup):
return Popup.visible_content_pane_height.fget(self)
def current_selection(self):
'Returns a tuple of (selected index, selected data)'
"""Returns a tuple of (selected index, selected data)."""
return self.active_input
def set_selection(self, index):

View file

@ -335,7 +335,7 @@ class FilterTreeView(component.Component):
item.set_sensitive(sensitive)
def select_all(self):
'for use in popup menu'
"""For use in popup menu."""
component.get('TorrentView').treeview.get_selection().select_all()
def on_select_all(self, event):