[Lint] Cleanup code to pass PyLint Convention category
Disabled Conventions messages: * missing-docstring: Not likely all methods/funcs will ever have docstrings. * invalid-name: Far too many too fix so will simply have to ensure submitted or altered code keeps to the convention. * old-style-class: Not a priority but would be nice to eventually fix this. * bad-continuation: Occasionally conflicts with pep8, not worth enabling if using pyflakes and pep8 as these will catch most continuation issues.
This commit is contained in:
parent
3288353be0
commit
ad3cba929e
|
@ -278,13 +278,13 @@ def fsize(fsize_b):
|
|||
|
||||
"""
|
||||
# Bigger than 1 GiB
|
||||
if (fsize_b >= 1073741824):
|
||||
if fsize_b >= 1073741824:
|
||||
return "%.1f %s" % (fsize_b / 1073741824.0, gib_txt)
|
||||
# Bigger than 1 MiB
|
||||
elif (fsize_b >= 1048576):
|
||||
elif fsize_b >= 1048576:
|
||||
return "%.1f %s" % (fsize_b / 1048576.0, mib_txt)
|
||||
# Bigger than 1 KiB
|
||||
elif (fsize_b >= 1024):
|
||||
elif fsize_b >= 1024:
|
||||
return "%.1f %s" % (fsize_b / 1024.0, kib_txt)
|
||||
else:
|
||||
return "%d %s" % (fsize_b, byte_txt)
|
||||
|
@ -744,7 +744,7 @@ class VersionSplit(object):
|
|||
|
||||
"""
|
||||
# PEP 386 versions with .devN precede release version
|
||||
if (bool(self.dev) != bool(ver.dev)):
|
||||
if bool(self.dev) != bool(ver.dev):
|
||||
if self.dev != 'dev':
|
||||
self.dev = not self.dev
|
||||
if ver.dev != 'dev':
|
||||
|
|
|
@ -257,13 +257,12 @@ class FilterManager(component.Component):
|
|||
return torrent_ids
|
||||
|
||||
def _hide_state_items(self, state_items):
|
||||
"for hide(show)-zero hits"
|
||||
"""For hide(show)-zero hits"""
|
||||
for (value, count) in state_items.items():
|
||||
if value != "All" and count == 0:
|
||||
del state_items[value]
|
||||
|
||||
def _sort_state_items(self, x, y):
|
||||
""
|
||||
if x[0] in STATE_SORT:
|
||||
ix = STATE_SORT.index(x[0])
|
||||
else:
|
||||
|
|
|
@ -840,7 +840,7 @@ class Torrent(object):
|
|||
|
||||
parts = host.split(".")
|
||||
if len(parts) > 2:
|
||||
if parts[-2] in ("co", "com", "net", "org") or parts[-1] in ("uk"):
|
||||
if parts[-2] in ("co", "com", "net", "org") or parts[-1] == "uk":
|
||||
host = ".".join(parts[-3:])
|
||||
else:
|
||||
host = ".".join(parts[-2:])
|
||||
|
|
|
@ -516,7 +516,7 @@ class TorrentManager(component.Component):
|
|||
t_state_tmp = TorrentState()
|
||||
if dir(state.torrents[0]) != dir(t_state_tmp):
|
||||
try:
|
||||
for attr in (set(dir(t_state_tmp)) - set(dir(state.torrents[0]))):
|
||||
for attr in set(dir(t_state_tmp)) - set(dir(state.torrents[0])):
|
||||
for t_state in state.torrents:
|
||||
if attr == "storage_mode" and getattr(t_state, "compact", None):
|
||||
setattr(t_state, attr, "compact")
|
||||
|
|
|
@ -22,7 +22,7 @@ class DelugeEventMetaClass(type):
|
|||
"""
|
||||
This metaclass simply keeps a list of all events classes created.
|
||||
"""
|
||||
def __init__(self, name, bases, dct):
|
||||
def __init__(self, name, bases, dct): # pylint: disable=bad-mcs-method-argument
|
||||
super(DelugeEventMetaClass, self).__init__(name, bases, dct)
|
||||
if name != "DelugeEvent":
|
||||
known_events[name] = self
|
||||
|
|
|
@ -49,10 +49,10 @@ deluge.main.start_daemon()
|
|||
core = Popen([sys.executable], cwd=cwd, stdin=fp, stdout=PIPE, stderr=PIPE)
|
||||
while True:
|
||||
line = core.stderr.readline()
|
||||
if ("starting on %d" % listen_port) in line:
|
||||
if "starting on %d" % listen_port in line:
|
||||
time.sleep(0.3) # Slight pause just incase
|
||||
break
|
||||
elif ("Couldn't listen on localhost:%d" % listen_port) in line:
|
||||
elif "Couldn't listen on localhost:%d" % listen_port in line:
|
||||
raise CannotListenError("localhost", listen_port, "Could not start deluge test client: %s" % line)
|
||||
elif 'Traceback' in line:
|
||||
raise SystemExit(
|
||||
|
|
|
@ -212,7 +212,7 @@ class Win32IcoFile(object):
|
|||
# end Win32IcoFile
|
||||
|
||||
|
||||
class Win32IconImageFile (PIL.ImageFile.ImageFile):
|
||||
class Win32IconImageFile(PIL.ImageFile.ImageFile):
|
||||
"""
|
||||
PIL read-only image support for Microsoft .ico files.
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ def start():
|
|||
Console().start()
|
||||
|
||||
|
||||
class DelugeHelpFormatter (optparse.IndentedHelpFormatter):
|
||||
class DelugeHelpFormatter(optparse.IndentedHelpFormatter):
|
||||
"""
|
||||
Format help in a way suited to deluge Legacy mode - colors, format, indentation...
|
||||
"""
|
||||
|
|
|
@ -22,10 +22,10 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def _bracket_fixup(path):
|
||||
if (path.find("[") == -1 and path.find("]") == -1):
|
||||
if path.find("[") == -1 and path.find("]") == -1:
|
||||
return path
|
||||
sentinal = 256
|
||||
while (path.find(unichr(sentinal)) != -1):
|
||||
while path.find(unichr(sentinal)) != -1:
|
||||
sentinal += 1
|
||||
if sentinal > 65535:
|
||||
log.error("Can't fix brackets in path, path contains all possible sentinal characters")
|
||||
|
@ -42,8 +42,8 @@ def add_torrent(t_file, options, success_cb, fail_cb, ress):
|
|||
t_options["download_location"] = os.path.expanduser(options["path"])
|
||||
t_options["add_paused"] = options["add_paused"]
|
||||
|
||||
is_url = (not (options["path_type"] == 1)) and (deluge.common.is_url(t_file) or options["path_type"] == 2)
|
||||
is_magnet = not(is_url) and (not (options["path_type"] == 1)) and deluge.common.is_magnet(t_file)
|
||||
is_url = (not options["path_type"] == 1) and (deluge.common.is_url(t_file) or options["path_type"] == 2)
|
||||
is_magnet = not(is_url) and (not options["path_type"] == 1) and deluge.common.is_magnet(t_file)
|
||||
|
||||
if is_url or is_magnet:
|
||||
files = [t_file]
|
||||
|
|
|
@ -387,17 +387,17 @@ class AllTorrents(BaseMode, component.Component):
|
|||
def __update_columns(self):
|
||||
self.column_widths = [self.config["%s_width" % c] for c in self.__cols_to_show]
|
||||
req = sum(filter(lambda x: x >= 0, self.column_widths))
|
||||
if (req > self.cols): # can't satisfy requests, just spread out evenly
|
||||
if req > self.cols: # can't satisfy requests, just spread out evenly
|
||||
cw = int(self.cols / len(self.__columns))
|
||||
for i in range(0, len(self.column_widths)):
|
||||
self.column_widths[i] = cw
|
||||
else:
|
||||
rem = self.cols - req
|
||||
var_cols = len(filter(lambda x: x < 0, self.column_widths))
|
||||
if (var_cols > 0):
|
||||
if var_cols > 0:
|
||||
vw = int(rem / var_cols)
|
||||
for i in range(0, len(self.column_widths)):
|
||||
if (self.column_widths[i] < 0):
|
||||
if self.column_widths[i] < 0:
|
||||
self.column_widths[i] = vw
|
||||
|
||||
self.column_string = "{!header!}"
|
||||
|
@ -450,14 +450,14 @@ class AllTorrents(BaseMode, component.Component):
|
|||
def _scroll_up(self, by):
|
||||
prevoff = self.curoff
|
||||
self.cursel = max(self.cursel - by, 1)
|
||||
if ((self.cursel - 1) < self.curoff):
|
||||
if (self.cursel - 1) < self.curoff:
|
||||
self.curoff = max(self.cursel - 1, 1)
|
||||
return prevoff != self.curoff
|
||||
|
||||
def _scroll_down(self, by):
|
||||
prevoff = self.curoff
|
||||
self.cursel = min(self.cursel + by, self.numtorrents)
|
||||
if ((self.curoff + self.rows - 5) < self.cursel):
|
||||
if (self.curoff + self.rows - 5) < self.cursel:
|
||||
self.curoff = self.cursel - self.rows + 5
|
||||
return prevoff != self.curoff
|
||||
|
||||
|
@ -474,7 +474,7 @@ class AllTorrents(BaseMode, component.Component):
|
|||
return ret
|
||||
|
||||
def _on_torrent_status(self, state):
|
||||
if (self.popup):
|
||||
if self.popup:
|
||||
self.popup.clear()
|
||||
name = state["name"]
|
||||
self.popup.set_title(name)
|
||||
|
@ -589,7 +589,7 @@ class AllTorrents(BaseMode, component.Component):
|
|||
return result
|
||||
|
||||
def _format_queue(self, qnum):
|
||||
if (qnum >= 0):
|
||||
if qnum >= 0:
|
||||
return "%d" % (qnum + 1)
|
||||
else:
|
||||
return ""
|
||||
|
@ -963,7 +963,7 @@ class AllTorrents(BaseMode, component.Component):
|
|||
pass
|
||||
tidx += 1
|
||||
currow += 1
|
||||
if (currow > (self.rows - 2)):
|
||||
if currow > (self.rows - 2):
|
||||
break
|
||||
else:
|
||||
self.add_string(1, "Waiting for torrents from core...")
|
||||
|
@ -1037,9 +1037,9 @@ class AllTorrents(BaseMode, component.Component):
|
|||
skip -= 1
|
||||
continue
|
||||
self.cursel = (i + 1)
|
||||
if ((self.curoff + self.rows - 5) < self.cursel):
|
||||
if (self.curoff + self.rows - 5) < self.cursel:
|
||||
self.curoff = self.cursel - self.rows + 5
|
||||
elif ((self.curoff + 1) > self.cursel):
|
||||
elif (self.curoff + 1) > self.cursel:
|
||||
self.curoff = max(1, self.cursel - 1)
|
||||
self.search_state = SEARCH_SUCCESS
|
||||
return
|
||||
|
|
|
@ -16,7 +16,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def format_queue(qnum):
|
||||
if (qnum >= 0):
|
||||
if qnum >= 0:
|
||||
return "%d" % (qnum + 1)
|
||||
else:
|
||||
return ""
|
||||
|
|
|
@ -16,28 +16,28 @@ import deluge.common
|
|||
|
||||
|
||||
def format_speed(speed):
|
||||
if (speed > 0):
|
||||
if speed > 0:
|
||||
return deluge.common.fspeed(speed)
|
||||
else:
|
||||
return "-"
|
||||
|
||||
|
||||
def format_time(time):
|
||||
if (time > 0):
|
||||
if time > 0:
|
||||
return deluge.common.ftime(time)
|
||||
else:
|
||||
return "-"
|
||||
|
||||
|
||||
def format_date(time):
|
||||
if (time > 0):
|
||||
if time > 0:
|
||||
return deluge.common.fdate(time)
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
def format_date_never(time):
|
||||
if (time > 0):
|
||||
if time > 0:
|
||||
return deluge.common.fdate(time)
|
||||
else:
|
||||
return "Never"
|
||||
|
@ -112,7 +112,7 @@ def format_column(col, lim):
|
|||
col = ud_normalize("NFC", col)
|
||||
dbls = sum(east_asian_width(c) in "WF" for c in col)
|
||||
size = len(col) + dbls
|
||||
if (size >= lim - 1):
|
||||
if size >= lim - 1:
|
||||
return trim_string(col, lim, dbls > 0)
|
||||
else:
|
||||
return "%s%s" % (col, " " * (lim - size))
|
||||
|
|
|
@ -503,7 +503,7 @@ class FloatSpinInput(InputField):
|
|||
self.need_update = True
|
||||
# Move the cursor forward
|
||||
self.cursor += 1
|
||||
elif (c > 47 and c < 58):
|
||||
elif c > 47 and c < 58:
|
||||
if (not self.real_value) and self.valstr:
|
||||
self.valstr = ""
|
||||
self.cursor = 0
|
||||
|
@ -875,7 +875,7 @@ class InputPopup(Popup):
|
|||
crow += 1
|
||||
crow += ipt.render(self.screen, crow, self.width, i == self.current_input)
|
||||
|
||||
if (self.content_height > (self.height - 2)):
|
||||
if self.content_height > (self.height - 2):
|
||||
lts = self.content_height - (self.height - 3)
|
||||
perc_sc = float(self.lineoff) / lts
|
||||
sb_pos = int((self.height - 2) * perc_sc) + 1
|
||||
|
|
|
@ -77,7 +77,7 @@ class Popup:
|
|||
def _refresh_lines(self):
|
||||
crow = 1
|
||||
for line in self._lines[self.lineoff:]:
|
||||
if (crow >= self.height - 1):
|
||||
if crow >= self.height - 1:
|
||||
break
|
||||
self.parent.add_string(crow, line, self.screen, 1, False, True)
|
||||
crow += 1
|
||||
|
@ -137,7 +137,7 @@ class Popup:
|
|||
self.parent.add_string(0, "{!white,black,bold!}%s" % self.title, self.screen, toff, False, True)
|
||||
|
||||
self._refresh_lines()
|
||||
if (len(self._lines) > (self.height - 2)):
|
||||
if len(self._lines) > (self.height - 2):
|
||||
lts = len(self._lines) - (self.height - 3)
|
||||
perc_sc = float(self.lineoff) / lts
|
||||
sb_pos = int((self.height - 2) * perc_sc) + 1
|
||||
|
@ -232,9 +232,9 @@ class SelectablePopup(Popup):
|
|||
def _refresh_lines(self):
|
||||
crow = 1
|
||||
for row, line in enumerate(self._lines):
|
||||
if (crow >= self.height - 1):
|
||||
if crow >= self.height - 1:
|
||||
break
|
||||
if (row < self.lineoff):
|
||||
if row < self.lineoff:
|
||||
continue
|
||||
fg = self._line_foregrounds[row]
|
||||
udx = self._udxs.get(crow)
|
||||
|
@ -284,7 +284,7 @@ class SelectablePopup(Popup):
|
|||
|
||||
def _move_cursor_down(self, amount):
|
||||
idx = self._selectable_lines.index(self._selected)
|
||||
if (idx < len(self._selectable_lines) - amount):
|
||||
if idx < len(self._selectable_lines) - amount:
|
||||
self._selected = self._selectable_lines[idx + amount]
|
||||
else:
|
||||
self._selected = self._selectable_lines[-1]
|
||||
|
|
|
@ -225,7 +225,7 @@ class TorrentDetail(BaseMode, component.Component):
|
|||
def __update_columns(self):
|
||||
self.column_widths = [-1, 15, 15, 20]
|
||||
req = sum(filter(lambda x: x >= 0, self.column_widths))
|
||||
if (req > self.cols): # can't satisfy requests, just spread out evenly
|
||||
if req > self.cols: # can't satisfy requests, just spread out evenly
|
||||
cw = int(self.cols / len(self.column_names))
|
||||
for i in range(0, len(self.column_widths)):
|
||||
self.column_widths[i] = cw
|
||||
|
@ -234,7 +234,7 @@ class TorrentDetail(BaseMode, component.Component):
|
|||
var_cols = len(filter(lambda x: x < 0, self.column_widths))
|
||||
vw = int(rem / var_cols)
|
||||
for i in range(0, len(self.column_widths)):
|
||||
if (self.column_widths[i] < 0):
|
||||
if self.column_widths[i] < 0:
|
||||
self.column_widths[i] = vw
|
||||
|
||||
self.column_string = "{!green,black,bold!}%s" % ("".join(["%s%s" % (self.column_names[i], " " * (
|
||||
|
@ -287,7 +287,7 @@ class TorrentDetail(BaseMode, component.Component):
|
|||
# from sys import stderr
|
||||
# print >> stderr, fl[6]
|
||||
# kick out if we're going to draw too low on the screen
|
||||
if (off >= self.rows - 1):
|
||||
if off >= self.rows - 1:
|
||||
self.more_to_draw = True
|
||||
return -1, -1
|
||||
|
||||
|
|
|
@ -524,14 +524,14 @@ class PathChooserPopup(object):
|
|||
|
||||
"""
|
||||
# Entry is not yet visible
|
||||
if not (self.path_entry.flags() & gtk.REALIZED):
|
||||
if not self.path_entry.flags() & gtk.REALIZED:
|
||||
return
|
||||
self.set_window_position_and_size()
|
||||
|
||||
def popdown(self):
|
||||
if not self.is_popped_up():
|
||||
return
|
||||
if not (self.path_entry.flags() & gtk.REALIZED):
|
||||
if not self.path_entry.flags() & gtk.REALIZED:
|
||||
return
|
||||
self.popup_window.grab_remove()
|
||||
self.popup_window.hide_all()
|
||||
|
@ -751,7 +751,7 @@ class StoredValuesPopup(StoredValuesList, PathChooserPopup):
|
|||
PathChooserPopup.popup(self)
|
||||
self.popup_window.grab_focus()
|
||||
|
||||
if not (self.treeview.flags() & gtk.HAS_FOCUS):
|
||||
if not self.treeview.flags() & gtk.HAS_FOCUS:
|
||||
self.treeview.grab_focus()
|
||||
if not self.popup_grab_window():
|
||||
self.popup_window.hide()
|
||||
|
@ -874,7 +874,7 @@ class PathCompletionPopup(CompletionList, PathChooserPopup):
|
|||
PathChooserPopup.popup(self)
|
||||
self.popup_window.grab_focus()
|
||||
|
||||
if not (self.treeview.flags() & gtk.HAS_FOCUS):
|
||||
if not self.treeview.flags() & gtk.HAS_FOCUS:
|
||||
self.treeview.grab_focus()
|
||||
|
||||
if not self.popup_grab_window():
|
||||
|
@ -931,7 +931,7 @@ class PathAutoCompleter(object):
|
|||
self.accelerator_string = gtk.accelerator_name(keysyms.Tab, 0)
|
||||
|
||||
def on_entry_text_insert_text(self, entry, new_text, new_text_length, position):
|
||||
if (self.path_entry.flags() & gtk.REALIZED):
|
||||
if self.path_entry.flags() & gtk.REALIZED:
|
||||
cur_text = self.path_entry.get_text()
|
||||
pos = entry.get_position()
|
||||
new_complete_text = cur_text[:pos] + new_text + cur_text[pos:]
|
||||
|
|
|
@ -364,11 +364,9 @@ class StatusBar(component.Component):
|
|||
self.traffic_item.set_text(label_string)
|
||||
|
||||
def update(self):
|
||||
# Send status request
|
||||
self.send_status_request()
|
||||
|
||||
def set_limit_value(self, widget, core_key):
|
||||
""" """
|
||||
log.debug("_on_set_unlimit_other %s", core_key)
|
||||
other_dialog_info = {
|
||||
"max_download_speed": (_("Download Speed Limit"), _("Set the maximum download speed"),
|
||||
|
|
20
pylintrc
20
pylintrc
|
@ -22,7 +22,7 @@ persistent=yes
|
|||
load-plugins=
|
||||
|
||||
# Use multiple processes to speed up Pylint.
|
||||
jobs=1
|
||||
jobs=2
|
||||
|
||||
# Allow loading of arbitrary C extensions. Extensions are imported into the
|
||||
# active Python interpreter and may run arbitrary code.
|
||||
|
@ -62,16 +62,14 @@ confidence=
|
|||
# --enable=similarities". If you want to run only the classes checker, but have
|
||||
# no Warning level messages displayed, use"--disable=all --enable=classes
|
||||
# --disable=W"
|
||||
#disable=E1608,W1627,E1601,E1603,E1602,E1605,E1604,E1607,E1606,W1621,W1620,W1623,W1622,W1625,
|
||||
# W1624,W1609,W1608,W1607,W1606,W1605,W1604,W1603,W1602,W1601,W1639,W1640,I0021,W1638,I0020,
|
||||
# W1618,W1619,W1630,W1626,W1637,W1634,W1635,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617,
|
||||
# W1632,W1633,W0704,W1628,W1629,W1636
|
||||
disable=C,
|
||||
#
|
||||
# Arranged by category (convention, error, information, refactor, warning).
|
||||
# One category per line using symbolic names instead of ids.
|
||||
disable=missing-docstring, invalid-name, old-style-class, bad-continuation,
|
||||
no-member, not-callable, no-name-in-module,
|
||||
W,
|
||||
locally-disabled,
|
||||
R,
|
||||
locally-disabled
|
||||
|
||||
W
|
||||
|
||||
[REPORTS]
|
||||
|
||||
|
@ -130,7 +128,7 @@ required-attributes=
|
|||
bad-functions=map,filter,input
|
||||
|
||||
# Good variable names which should always be accepted, separated by a comma
|
||||
good-names=i,j,k,ex,Run,_
|
||||
good-names=d,i,j,k,ex,Run,_,log
|
||||
|
||||
# Bad variable names which should always be refused, separated by a comma
|
||||
bad-names=foo,bar,baz,toto,tutu,tata
|
||||
|
@ -234,7 +232,7 @@ single-line-if-stmt=no
|
|||
no-space-check=trailing-comma,dict-separator
|
||||
|
||||
# Maximum number of lines in a module
|
||||
max-module-lines=1500
|
||||
max-module-lines=1550
|
||||
|
||||
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
||||
# tab).
|
||||
|
|
Loading…
Reference in New Issue