[Lint] Code cleanup for PyLint run by prospector tool
* Fix for pluginmanager multiple inheritance which in this case is using super incorrectly. * Explicitly disable pylint 'pointless-except' and 'super-on-old-class' that prospector tool somehow runs. * Make __all__ a tuple to supress pep257 warning. * Add a noqa for older versions of pyflakes.
This commit is contained in:
parent
d280fa9fbd
commit
2583e9d888
|
@ -53,13 +53,13 @@ class PluginManager(deluge.pluginmanagerbase.PluginManagerBase, component.Compon
|
||||||
|
|
||||||
def enable_plugin(self, name):
|
def enable_plugin(self, name):
|
||||||
if name not in self.plugins:
|
if name not in self.plugins:
|
||||||
super(PluginManager, self).enable_plugin(name)
|
deluge.pluginmanagerbase.PluginManagerBase.enable_plugin(self, name)
|
||||||
if name in self.plugins:
|
if name in self.plugins:
|
||||||
component.get("EventManager").emit(PluginEnabledEvent(name))
|
component.get("EventManager").emit(PluginEnabledEvent(name))
|
||||||
|
|
||||||
def disable_plugin(self, name):
|
def disable_plugin(self, name):
|
||||||
if name in self.plugins:
|
if name in self.plugins:
|
||||||
super(PluginManager, self).disable_plugin(name)
|
deluge.pluginmanagerbase.PluginManagerBase.disable_plugin(self, name)
|
||||||
if name not in self.plugins:
|
if name not in self.plugins:
|
||||||
component.get("EventManager").emit(PluginDisabledEvent(name))
|
component.get("EventManager").emit(PluginDisabledEvent(name))
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ from twisted.python.log import PythonLoggingObserver
|
||||||
|
|
||||||
from deluge import common
|
from deluge import common
|
||||||
|
|
||||||
__all__ = ["setup_logger", "set_logger_level", "get_plugin_logger", "LOG"]
|
__all__ = ("setup_logger", "set_logger_level", "get_plugin_logger", "LOG")
|
||||||
|
|
||||||
LoggingLoggerClass = logging.getLoggerClass()
|
LoggingLoggerClass = logging.getLoggerClass()
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ git repository to have an idea of what needs to be changed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class PluginManagerBase:
|
class PluginManagerBase(object):
|
||||||
"""PluginManagerBase is a base class for PluginManagers to inherit"""
|
"""PluginManagerBase is a base class for PluginManagers to inherit"""
|
||||||
|
|
||||||
def __init__(self, config_file, entry_name):
|
def __init__(self, config_file, entry_name):
|
||||||
|
|
|
@ -63,7 +63,7 @@ from threading import Lock
|
||||||
from types import DictType, FloatType, IntType, ListType, LongType, NoneType, StringType, TupleType, UnicodeType
|
from types import DictType, FloatType, IntType, ListType, LongType, NoneType, StringType, TupleType, UnicodeType
|
||||||
|
|
||||||
__version__ = '1.0.2'
|
__version__ = '1.0.2'
|
||||||
__all__ = ['dumps', 'loads']
|
__all__ = ('dumps', 'loads')
|
||||||
|
|
||||||
# Default number of bits for serialized floats, either 32 or 64 (also a parameter for dumps()).
|
# Default number of bits for serialized floats, either 32 or 64 (also a parameter for dumps()).
|
||||||
DEFAULT_FLOAT_BITS = 32
|
DEFAULT_FLOAT_BITS = 32
|
||||||
|
|
|
@ -71,7 +71,7 @@ def create_plugin():
|
||||||
return
|
return
|
||||||
|
|
||||||
def write_file(path, filename, template, include_gpl=True):
|
def write_file(path, filename, template, include_gpl=True):
|
||||||
args = {
|
plugin_args = {
|
||||||
"author_name": options.author_name,
|
"author_name": options.author_name,
|
||||||
"author_email": options.author_email,
|
"author_email": options.author_email,
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -87,8 +87,8 @@ def create_plugin():
|
||||||
filename = os.path.join(path, filename)
|
filename = os.path.join(path, filename)
|
||||||
f = open(filename, "w")
|
f = open(filename, "w")
|
||||||
if filename.endswith(".py") and include_gpl:
|
if filename.endswith(".py") and include_gpl:
|
||||||
f.write(GPL % args)
|
f.write(GPL % plugin_args)
|
||||||
f.write(template % args)
|
f.write(template % plugin_args)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
print("creating folders..")
|
print("creating folders..")
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
# Authour: Garett Harnish
|
# Authour: Garett Harnish
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from sys import exit, stderr
|
|
||||||
|
|
||||||
|
|
||||||
def is_float_digit(string):
|
def is_float_digit(string):
|
||||||
|
@ -23,7 +23,7 @@ def is_float_digit(string):
|
||||||
try:
|
try:
|
||||||
float(string)
|
float(string)
|
||||||
return True
|
return True
|
||||||
except:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# set up command-line options
|
# set up command-line options
|
||||||
|
@ -57,38 +57,38 @@ if options.max_active_limit:
|
||||||
if options.max_active_limit.isdigit() and int(options.max_active_limit) >= 0:
|
if options.max_active_limit.isdigit() and int(options.max_active_limit) >= 0:
|
||||||
settings['max_active_limit'] = int(options.max_active_limit)
|
settings['max_active_limit'] = int(options.max_active_limit)
|
||||||
else:
|
else:
|
||||||
stderr.write("ERROR: Invalid max_active_limit parameter!\n")
|
sys.stderr.write("ERROR: Invalid max_active_limit parameter!\n")
|
||||||
exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
if options.max_active_downloading:
|
if options.max_active_downloading:
|
||||||
if options.max_active_downloading.isdigit() and int(options.max_active_downloading) >= 0:
|
if options.max_active_downloading.isdigit() and int(options.max_active_downloading) >= 0:
|
||||||
settings['max_active_downloading'] = int(options.max_active_downloading)
|
settings['max_active_downloading'] = int(options.max_active_downloading)
|
||||||
else:
|
else:
|
||||||
stderr.write("ERROR: Invalid max_active_downloading parameter!\n")
|
sys.stderr.write("ERROR: Invalid max_active_downloading parameter!\n")
|
||||||
exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
if options.max_active_seeding:
|
if options.max_active_seeding:
|
||||||
if options.max_active_seeding.isdigit() and int(options.max_active_seeding) >= 0:
|
if options.max_active_seeding.isdigit() and int(options.max_active_seeding) >= 0:
|
||||||
settings['max_active_seeding'] = int(options.max_active_seeding)
|
settings['max_active_seeding'] = int(options.max_active_seeding)
|
||||||
else:
|
else:
|
||||||
stderr.write("ERROR: Invalid max_active_seeding parameter!\n")
|
sys.stderr.write("ERROR: Invalid max_active_seeding parameter!\n")
|
||||||
exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
if options.max_download_speed:
|
if options.max_download_speed:
|
||||||
if is_float_digit(options.max_download_speed) and (
|
if is_float_digit(options.max_download_speed) and (
|
||||||
float(options.max_download_speed) >= 0.0 or float(options.max_download_speed) == -1.0):
|
float(options.max_download_speed) >= 0.0 or float(options.max_download_speed) == -1.0):
|
||||||
settings['max_download_speed'] = float(options.max_download_speed)
|
settings['max_download_speed'] = float(options.max_download_speed)
|
||||||
else:
|
else:
|
||||||
stderr.write("ERROR: Invalid max_download_speed parameter!\n")
|
sys.stderr.write("ERROR: Invalid max_download_speed parameter!\n")
|
||||||
exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
if options.max_upload_speed:
|
if options.max_upload_speed:
|
||||||
if is_float_digit(options.max_upload_speed) and (
|
if is_float_digit(options.max_upload_speed) and (
|
||||||
float(options.max_upload_speed) >= 0.0 or float(options.max_upload_speed) == -1.0):
|
float(options.max_upload_speed) >= 0.0 or float(options.max_upload_speed) == -1.0):
|
||||||
settings['max_upload_speed'] = float(options.max_upload_speed)
|
settings['max_upload_speed'] = float(options.max_upload_speed)
|
||||||
else:
|
else:
|
||||||
stderr.write("ERROR: Invalid max_upload_speed parameter!\n")
|
sys.stderr.write("ERROR: Invalid max_upload_speed parameter!\n")
|
||||||
exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# If there is something to do ...
|
# If there is something to do ...
|
||||||
if settings:
|
if settings:
|
||||||
|
|
|
@ -38,7 +38,7 @@ if 0: # aclient non-core
|
||||||
func = getattr(aclient, method_name)
|
func = getattr(aclient, method_name)
|
||||||
try:
|
try:
|
||||||
params = inspect.getargspec(func)[0][1:]
|
params = inspect.getargspec(func)[0][1:]
|
||||||
except:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print("\n'''%s(%s): '''\n" % (method_name, ", ".join(params)))
|
print("\n'''%s(%s): '''\n" % (method_name, ", ".join(params)))
|
||||||
|
@ -57,7 +57,7 @@ if 1: # baseclient/core
|
||||||
func = getattr(Core, m)
|
func = getattr(Core, m)
|
||||||
|
|
||||||
params = inspect.getargspec(func)[0][1:]
|
params = inspect.getargspec(func)[0][1:]
|
||||||
if (aclient.has_callback(method_name) and method_name not in ['add_torrent_file_binary']):
|
if aclient.has_callback(method_name) and method_name not in ['add_torrent_file_binary']:
|
||||||
params = ["[callback]"] + params
|
params = ["[callback]"] + params
|
||||||
|
|
||||||
print("\n'''%s(%s): '''\n" % (method_name, ", ".join(params)))
|
print("\n'''%s(%s): '''\n" % (method_name, ", ".join(params)))
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import rencode # pylint: disable=relative-import
|
import rencode # pylint: disable=useless-suppression,relative-import
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import deluge.rencode as rencode
|
import deluge.rencode as rencode
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
# the additional special exception to link portions of this program with the OpenSSL library.
|
# the additional special exception to link portions of this program with the OpenSSL library.
|
||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
# pylint: disable=super-on-old-class
|
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
|
@ -60,7 +60,7 @@ def export(auth_level=AUTH_LEVEL_DEFAULT):
|
||||||
"""
|
"""
|
||||||
global AUTH_LEVEL_DEFAULT, AuthError
|
global AUTH_LEVEL_DEFAULT, AuthError
|
||||||
if AUTH_LEVEL_DEFAULT is None:
|
if AUTH_LEVEL_DEFAULT is None:
|
||||||
from deluge.ui.web.auth import AUTH_LEVEL_DEFAULT, AuthError # pylint: disable=redefined-outer-name
|
from deluge.ui.web.auth import AUTH_LEVEL_DEFAULT, AuthError # NOQA pylint: disable=redefined-outer-name
|
||||||
|
|
||||||
def wrap(func, *args, **kwargs):
|
def wrap(func, *args, **kwargs):
|
||||||
func._json_export = True
|
func._json_export = True
|
||||||
|
|
7
pylintrc
7
pylintrc
|
@ -66,12 +66,13 @@ confidence=
|
||||||
# Arranged by category: Convention, Error, Information, Refactor, Warning.
|
# Arranged by category: Convention, Error, Information, Refactor, Warning.
|
||||||
# Category per line (wrapped categories are indented) using symbolic names instead of ids.
|
# Category per line (wrapped categories are indented) using symbolic names instead of ids.
|
||||||
disable=missing-docstring, invalid-name, old-style-class, bad-continuation,
|
disable=missing-docstring, invalid-name, old-style-class, bad-continuation,
|
||||||
no-member, not-callable, no-name-in-module,
|
no-member, not-callable, no-name-in-module, super-on-old-class,
|
||||||
locally-disabled,
|
locally-disabled,
|
||||||
R,
|
R,
|
||||||
unused-argument, broad-except, fixme, protected-access, import-error, unidiomatic-typecheck,
|
unused-argument, fixme, protected-access, import-error, unidiomatic-typecheck,
|
||||||
unused-variable, global-statement, attribute-defined-outside-init, arguments-differ,
|
unused-variable, global-statement, attribute-defined-outside-init, arguments-differ,
|
||||||
no-init, non-parent-init-called, super-init-not-called, signature-differs
|
no-init, non-parent-init-called, super-init-not-called, signature-differs,
|
||||||
|
broad-except, pointless-except
|
||||||
|
|
||||||
[REPORTS]
|
[REPORTS]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue