Skip to content

Commit

Permalink
Flake8 pass of entire codebase
Browse files Browse the repository at this point in the history
 * Use the inline '# NOQA' to supress N802 lower-case warnings
  • Loading branch information
cas-- committed Sep 19, 2014
1 parent d0b8e17 commit 30a0f3c
Show file tree
Hide file tree
Showing 103 changed files with 1,048 additions and 2,068 deletions.
2 changes: 1 addition & 1 deletion deluge/configmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def get_config(self, config_file, defaults=None):
_configmanager = _ConfigManager()


def ConfigManager(config, defaults=None):
def ConfigManager(config, defaults=None): # NOQA
return _configmanager.get_config(config, defaults)


Expand Down
9 changes: 4 additions & 5 deletions deluge/core/rpcserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def format_request(call):


class ServerContextFactory(object):
def getContext(self):
def getContext(self): # NOQA
"""
Create an SSL context.
Expand All @@ -130,7 +130,6 @@ def getContext(self):


class DelugeRPCProtocol(DelugeTransferProtocol):

def message_received(self, request):
"""
This method is called whenever a message is received from a client. The
Expand Down Expand Up @@ -158,7 +157,7 @@ def message_received(self, request):
#log.debug("RPCRequest: %s", format_request(call))
reactor.callLater(0, self.dispatch, *call)

def sendData(self, data):
def sendData(self, data): # NOQA
"""
Sends the data to the client.
Expand All @@ -169,7 +168,7 @@ def sendData(self, data):
"""
self.transfer_message(data)

def connectionMade(self):
def connectionMade(self): # NOQA
"""
This method is called when a new client connects.
"""
Expand All @@ -179,7 +178,7 @@ def connectionMade(self):
# Set the initial auth level of this session to AUTH_LEVEL_NONE
self.factory.authorized_sessions[self.transport.sessionno] = AUTH_LEVEL_NONE

def connectionLost(self, reason):
def connectionLost(self, reason): # NOQA
"""
This method is called when the client is disconnected.
Expand Down
8 changes: 4 additions & 4 deletions deluge/httpdownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def __init__(self, url, filename, part_callback=None, headers=None,
agent = "Deluge/%s (http://deluge-torrent.org)" % get_version()
client.HTTPDownloader.__init__(self, url, filename, headers=headers, agent=agent)

def gotStatus(self, version, status, message):
def gotStatus(self, version, status, message): # NOQA
self.code = int(status)
client.HTTPDownloader.gotStatus(self, version, status, message)

def gotHeaders(self, headers):
def gotHeaders(self, headers): # NOQA
if self.code == http.OK:
if "content-length" in headers:
self.total_length = int(headers["content-length"][0])
Expand Down Expand Up @@ -89,7 +89,7 @@ def gotHeaders(self, headers):

return client.HTTPDownloader.gotHeaders(self, headers)

def pagePart(self, data):
def pagePart(self, data): # NOQA
if self.code == http.OK:
self.current_length += len(data)
if self.decoder:
Expand All @@ -99,7 +99,7 @@ def pagePart(self, data):

return client.HTTPDownloader.pagePart(self, data)

def pageEnd(self):
def pageEnd(self): # NOQA
if self.decoder:
data = self.decoder.flush()
self.current_length -= len(data)
Expand Down
16 changes: 8 additions & 8 deletions deluge/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from deluge import common

__all__ = ["setupLogger", "setLoggerLevel", "getPluginLogger", "LOG"]
__all__ = ["setup_logger", "set_logger_level", "get_plugin_logger", "LOG"]

LoggingLoggerClass = logging.getLoggerClass()

Expand Down Expand Up @@ -79,7 +79,7 @@ def critical(self, msg, *args, **kwargs):
def exception(self, msg, *args, **kwargs):
yield LoggingLoggerClass.exception(self, msg, *args, **kwargs)

def findCaller(self):
def find_caller(self):
f = logging.currentframe().f_back
rv = "(unknown file)", 0, "(unknown function)"
while hasattr(f, "f_code"):
Expand All @@ -106,7 +106,7 @@ def findCaller(self):
}


def setupLogger(level="error", filename=None, filemode="w"):
def setup_logger(level="error", filename=None, filemode="w"):
"""
Sets up the basic logger and if `:param:filename` is set, then it will log
to that file instead of stdout.
Expand Down Expand Up @@ -192,10 +192,10 @@ def tweak_logging_levels():
continue

log.warn("Setting logger \"%s\" to logging level \"%s\"", name, level)
setLoggerLevel(level, name)
set_logger_level(level, name)


def setLoggerLevel(level, logger_name=None):
def set_logger_level(level, logger_name=None):
"""
Sets the logger level.
Expand All @@ -208,7 +208,7 @@ def setLoggerLevel(level, logger_name=None):
logging.getLogger(logger_name).setLevel(levels.get(level, "error"))


def getPluginLogger(logger_name):
def get_plugin_logger(logger_name):
import warnings
stack = inspect.stack()
stack.pop(0) # The logging call from this module
Expand All @@ -229,10 +229,10 @@ def getPluginLogger(logger_name):
from deluge.log import LOG as log
or:
from deluge.log import getPluginLogger
from deluge.log import get_plugin_logger
This has been deprecated in favour of an enhanced logging system and both "LOG"
and "getPluginLogger" will be removed on the next major version release of Deluge,
and "get_plugin_logger" will be removed on the next major version release of Deluge,
meaning, code will break, specially plugins.
If you're seeing this message and you're not the developer of the plugin which
triggered this warning, please report to it's author.
Expand Down
6 changes: 3 additions & 3 deletions deluge/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import deluge.common
import deluge.configmanager
import deluge.error
from deluge.log import setupLogger
from deluge.log import setup_logger


def version_callback(option, opt_str, value, parser):
Expand Down Expand Up @@ -74,7 +74,7 @@ def start_ui():
logfile_mode = 'w'
if options.rotate_logs:
logfile_mode = 'a'
setupLogger(level=options.loglevel, filename=options.logfile, filemode=logfile_mode)
setup_logger(level=options.loglevel, filename=options.logfile, filemode=logfile_mode)
log = getLogger(__name__)

if options.config:
Expand Down Expand Up @@ -181,7 +181,7 @@ def start_daemon():
logfile_mode = 'w'
if options.rotate_logs:
logfile_mode = 'a'
setupLogger(level=options.loglevel, filename=options.logfile, filemode=logfile_mode)
setup_logger(level=options.loglevel, filename=options.logfile, filemode=logfile_mode)
log = getLogger(__name__)

# If no logfile specified add logging to default location (as well as stdout)
Expand Down
12 changes: 6 additions & 6 deletions deluge/plugins/AutoAdd/deluge/plugins/autoadd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@

class CorePlugin(PluginInitBase):
def __init__(self, plugin_name):
from .core import Core as _plugin_cls
self._plugin_cls = _plugin_cls
from .core import Core as _pluginCls
self._plugin_cls = _pluginCls
super(CorePlugin, self).__init__(plugin_name)


class GtkUIPlugin(PluginInitBase):
def __init__(self, plugin_name):
from .gtkui import GtkUI as _plugin_cls
self._plugin_cls = _plugin_cls
from .gtkui import GtkUI as _pluginCls
self._plugin_cls = _pluginCls
super(GtkUIPlugin, self).__init__(plugin_name)


class WebUIPlugin(PluginInitBase):
def __init__(self, plugin_name):
from .webui import WebUI as _plugin_cls
self._plugin_cls = _plugin_cls
from .webui import WebUI as _pluginCls
self._plugin_cls = _pluginCls
super(WebUIPlugin, self).__init__(plugin_name)
Loading

0 comments on commit 30a0f3c

Please sign in to comment.