[Lint] Add flake8-quotes to tox and fix bad quotes

This commit is contained in:
Calum Lind 2016-11-03 22:37:00 +00:00
commit af6b277d28
21 changed files with 36 additions and 35 deletions

View file

@ -716,7 +716,7 @@ class Core(component.Component):
:raises DelugeError: if the username is not known :raises DelugeError: if the username is not known
""" """
if not self.authmanager.has_account(username): if not self.authmanager.has_account(username):
raise DelugeError("Username \"%s\" is not known." % username) raise DelugeError('Username "%s" is not known.' % username)
if isinstance(torrent_ids, basestring): if isinstance(torrent_ids, basestring):
torrent_ids = [torrent_ids] torrent_ids = [torrent_ids]
for torrent_id in torrent_ids: for torrent_id in torrent_ids:

View file

@ -518,16 +518,16 @@ class RPCServer(component.Component):
:type event: :class:`deluge.event.DelugeEvent` :type event: :class:`deluge.event.DelugeEvent`
""" """
if not self.is_session_valid(session_id): if not self.is_session_valid(session_id):
log.debug("Session ID %s is not valid. Not sending event \"%s\".", session_id, event.name) log.debug('Session ID %s is not valid. Not sending event "%s".', session_id, event.name)
return return
if session_id not in self.factory.interested_events: if session_id not in self.factory.interested_events:
log.debug("Session ID %s is not interested in any events. Not sending event \"%s\".", log.debug('Session ID %s is not interested in any events. Not sending event "%s".',
session_id, event.name) session_id, event.name)
return return
if event.name not in self.factory.interested_events[session_id]: if event.name not in self.factory.interested_events[session_id]:
log.debug("Session ID %s is not interested in event \"%s\". Not sending it.", session_id, event.name) log.debug('Session ID %s is not interested in event "%s". Not sending it.', session_id, event.name)
return return
log.debug("Sending event \"%s\" with args \"%s\" to session id \"%s\".", log.debug('Sending event "%s" with args "%s" to session id "%s".',
event.name, event.args, session_id) event.name, event.args, session_id)
self.factory.session_protocols[session_id].sendData((RPC_EVENT, event.name, event.args)) self.factory.session_protocols[session_id].sendData((RPC_EVENT, event.name, event.args))

View file

@ -446,7 +446,7 @@ class TorrentManager(component.Component):
log.debug('Torrent added: %s', str(alert.handle.info_hash())) log.debug('Torrent added: %s', str(alert.handle.info_hash()))
if log.isEnabledFor(logging.INFO): if log.isEnabledFor(logging.INFO):
name_and_owner = torrent.get_status(['name', 'owner']) name_and_owner = torrent.get_status(['name', 'owner'])
log.info("Torrent %s from user \"%s\" %s", log.info('Torrent %s from user "%s" %s',
name_and_owner['name'], name_and_owner['name'],
name_and_owner['owner'], name_and_owner['owner'],
from_state and 'loaded' or 'added') from_state and 'loaded' or 'added')

View file

@ -222,7 +222,7 @@ def tweak_logging_levels():
if level not in levels: if level not in levels:
continue continue
log.warn("Setting logger \"%s\" to logging level \"%s\"", name, level) log.warn('Setting logger "%s" to logging level "%s"', name, level)
set_logger_level(level, name) set_logger_level(level, name)

View file

@ -314,7 +314,7 @@ class Core(CorePluginBase):
elif watchdir.get('copy_torrent_toggle'): elif watchdir.get('copy_torrent_toggle'):
copy_torrent_path = watchdir['copy_torrent'] copy_torrent_path = watchdir['copy_torrent']
copy_torrent_file = os.path.join(copy_torrent_path, filename) copy_torrent_file = os.path.join(copy_torrent_path, filename)
log.debug("Moving added torrent file \"%s\" to \"%s\"", log.debug('Moving added torrent file "%s" to "%s"',
os.path.basename(filepath), copy_torrent_path) os.path.basename(filepath), copy_torrent_path)
shutil.move(filepath, copy_torrent_file) shutil.move(filepath, copy_torrent_file)
@ -324,7 +324,7 @@ class Core(CorePluginBase):
def on_update_watchdir_error(self, failure, watchdir_id): def on_update_watchdir_error(self, failure, watchdir_id):
"""Disables any watch folders with un-handled exceptions.""" """Disables any watch folders with un-handled exceptions."""
self.disable_watchdir(watchdir_id) self.disable_watchdir(watchdir_id)
log.error("Disabling '%s', error during update: %s", log.error('Disabling "%s", error during update: %s',
self.watchdirs[watchdir_id]['path'], failure) self.watchdirs[watchdir_id]['path'], failure)
@export @export
@ -459,9 +459,9 @@ class Core(CorePluginBase):
if os.path.isfile(torrent_fname_path): if os.path.isfile(torrent_fname_path):
try: try:
os.remove(torrent_fname_path) os.remove(torrent_fname_path)
log.info("Removed torrent file \"%s\" from \"%s\"", log.info('Removed torrent file "%s" from "%s"',
torrent_fname, copy_torrent_path) torrent_fname, copy_torrent_path)
break break
except OSError as ex: except OSError as ex:
log.info("Failed to removed torrent file \"%s\" from " log.info('Failed to removed torrent file "%s" from "%s": %s',
"\"%s\": %s", torrent_fname, copy_torrent_path, ex) torrent_fname, copy_torrent_path, ex)

View file

@ -341,8 +341,8 @@ class OptionsDialog(object):
options[chk_id + '_toggle'] = self.glade.get_widget(chk_id + '_toggle').get_active() options[chk_id + '_toggle'] = self.glade.get_widget(chk_id + '_toggle').get_active()
if options['copy_torrent_toggle'] and options['path'] == options['copy_torrent']: if options['copy_torrent_toggle'] and options['path'] == options['copy_torrent']:
raise IncompatibleOption(_("\"Watch Folder\" directory and \"Copy of .torrent" raise IncompatibleOption(_('"Watch Folder" directory and "Copy of .torrent'
" files to\" directory cannot be the same!")) ' files to" directory cannot be the same!'))
return options return options

View file

@ -100,11 +100,11 @@ class IP(object):
try: try:
q1, q2, q3, q4 = [int(q) for q in ip.split('.')] q1, q2, q3, q4 = [int(q) for q in ip.split('.')]
except ValueError: except ValueError:
raise BadIP(_("The IP address \"%s\" is badly formed" % ip)) raise BadIP(_('The IP address "%s" is badly formed' % ip))
if q1 < 0 or q2 < 0 or q3 < 0 or q4 < 0: if q1 < 0 or q2 < 0 or q3 < 0 or q4 < 0:
raise BadIP(_("The IP address \"%s\" is badly formed" % ip)) raise BadIP(_('The IP address "%s" is badly formed' % ip))
elif q1 > 255 or q2 > 255 or q3 > 255 or q4 > 255: elif q1 > 255 or q2 > 255 or q3 > 255 or q4 > 255:
raise BadIP(_("The IP address \"%s\" is badly formed" % ip)) raise BadIP(_('The IP address "%s" is badly formed' % ip))
return cls(q1, q2, q3, q4) return cls(q1, q2, q3, q4)
def quadrants(self): def quadrants(self):

View file

@ -99,7 +99,7 @@ class CustomNotifications(object):
def _handled_eventtype(self, eventtype, handler): def _handled_eventtype(self, eventtype, handler):
if eventtype not in known_events: if eventtype not in known_events:
log.error("The event \"%s\" is not known", eventtype) log.error('The event "%s" is not known', eventtype)
return False return False
if known_events[eventtype].__module__.startswith('deluge.event'): if known_events[eventtype].__module__.startswith('deluge.event'):
if handler.__self__ is self: if handler.__self__ is self:

View file

@ -171,10 +171,10 @@ Date: %(date)s
torrent = component.get('TorrentManager')[torrent_id] torrent = component.get('TorrentManager')[torrent_id]
torrent_status = torrent.get_status({}) torrent_status = torrent.get_status({})
# Email # Email
subject = _("Finished Torrent \"%(name)s\"") % torrent_status subject = _('Finished Torrent "%(name)s"') % torrent_status
message = _( message = _(
'This email is to inform you that Deluge has finished ' 'This email is to inform you that Deluge has finished '
"downloading \"%(name)s\", which includes %(num_files)i files." 'downloading \"%(name)s\", which includes %(num_files)i files.'
'\nTo stop receiving these alerts, simply turn off email ' '\nTo stop receiving these alerts, simply turn off email '
"notification in Deluge's preferences.\n\n" "notification in Deluge's preferences.\n\n"
'Thank you,\nDeluge.' 'Thank you,\nDeluge.'

View file

@ -222,7 +222,7 @@ class GtkUiNotifications(CustomNotifications):
'Got Torrent Status') 'Got Torrent Status')
title = _('Finished Torrent') title = _('Finished Torrent')
torrent_status['num_files'] = torrent_status['file_progress'].count(1.0) torrent_status['num_files'] = torrent_status['file_progress'].count(1.0)
message = _("The torrent \"%(name)s\" including %(num_files)i file(s) " message = _('The torrent \"%(name)s\" including %(num_files)i file(s) '
'has finished downloading.') % torrent_status 'has finished downloading.') % torrent_status
return title, message return title, message
@ -472,7 +472,7 @@ class GtkUI(GtkPluginBase, GtkUiNotifications):
old_sound_file, new_sound_file) old_sound_file, new_sound_file)
custom_sounds = {} custom_sounds = {}
for event_name, event_doc, filename, filepath in self.sounds_model: for event_name, event_doc, filename, filepath in self.sounds_model:
log.debug("Custom sound for event \"%s\": %s", event_name, filename) log.debug('Custom sound for event "%s": %s', event_name, filename)
if filepath == old_sound_file: if filepath == old_sound_file:
continue continue
custom_sounds[event_name] = filepath custom_sounds[event_name] = filepath

View file

@ -193,16 +193,16 @@ class DelugeRPCClientFactory(ClientFactory):
self.event_handlers = event_handlers self.event_handlers = event_handlers
def startedConnecting(self, connector): # NOQA def startedConnecting(self, connector): # NOQA
log.debug("Connecting to daemon at \"%s:%s\"...", log.debug('Connecting to daemon at "%s:%s"...',
connector.host, connector.port) connector.host, connector.port)
def clientConnectionFailed(self, connector, reason): # NOQA def clientConnectionFailed(self, connector, reason): # NOQA
log.debug("Connection to daemon at \"%s:%s\" failed: %s", log.debug('Connection to daemon at "%s:%s" failed: %s',
connector.host, connector.port, reason.value) connector.host, connector.port, reason.value)
self.daemon.connect_deferred.errback(reason) self.daemon.connect_deferred.errback(reason)
def clientConnectionLost(self, connector, reason): # NOQA def clientConnectionLost(self, connector, reason): # NOQA
log.debug("Connection lost to daemon at \"%s:%s\" reason: %s", log.debug('Connection lost to daemon at "%s:%s" reason: %s',
connector.host, connector.port, reason.value) connector.host, connector.port, reason.value)
self.daemon.host = None self.daemon.host = None
self.daemon.port = None self.daemon.port = None

View file

@ -40,7 +40,7 @@ class Command(BaseCommand):
names.append(self.console.get_torrent_name(tid)) names.append(self.console.get_torrent_name(tid))
def on_move(res): def on_move(res):
msg = "Moved \"%s\" to %s" % (', '.join(names), options.path) msg = 'Moved "%s" to %s' % (', '.join(names), options.path)
self.console.write(msg) self.console.write(msg)
log.info(msg) log.info(msg)

View file

@ -454,7 +454,7 @@ class TorrentDetail(BaseMode, PopupsHandler):
# Tracker # Tracker
tracker_color = '{!green!}' if status['message'] == 'OK' else '{!red!}' tracker_color = '{!green!}' if status['message'] == 'OK' else '{!red!}'
s = "{!info!}%s: {!magenta!}%s{!input!} says \"%s%s{!input!}\"" % ( s = '{!info!}%s: {!magenta!}%s{!input!} says "%s%s{!input!}"' % (
torrent_data_fields['tracker']['name'], status['tracker_host'], tracker_color, status['message']) torrent_data_fields['tracker']['name'], status['tracker_host'], tracker_color, status['message'])
row = self.add_string(row, s) row = self.add_string(row, s)

View file

@ -167,7 +167,7 @@ class AboutDialog(object):
'Pål-Eivind Johnsen', 'pano', 'Paolo Naldini', 'Paracelsus', 'Pål-Eivind Johnsen', 'pano', 'Paolo Naldini', 'Paracelsus',
'Patryk13_03', 'Patryk Skorupa', 'PattogoTehen', 'Paul Lange', 'Patryk13_03', 'Patryk Skorupa', 'PattogoTehen', 'Paul Lange',
'Pavcio', 'Paweł Wysocki', 'Pedro Brites Moita', 'Pavcio', 'Paweł Wysocki', 'Pedro Brites Moita',
'Pedro Clemente Pereira Neto', "Pekka \"PEXI\" Niemistö", 'Penegal', 'Pedro Clemente Pereira Neto', 'Pekka \"PEXI\" Niemistö', 'Penegal',
'Penzo', 'perdido', 'Peter Kotrcka', 'Peter Skov', 'Penzo', 'perdido', 'Peter Kotrcka', 'Peter Skov',
'Peter Van den Bosch', 'Petter Eklund', 'Petter Viklund', 'Peter Van den Bosch', 'Petter Eklund', 'Petter Viklund',
'phatsphere', 'Phenomen', 'Philipi', 'Philippides Homer', 'phoenix', 'phatsphere', 'Phenomen', 'Philipi', 'Philippides Homer', 'phoenix',

View file

@ -530,7 +530,7 @@ class ConnectionManager(component.Component):
msg = str(reason.value) msg = str(reason.value)
if not self.builder.get_object('chk_autostart').get_active(): if not self.builder.get_object('chk_autostart').get_active():
msg += '\n' + _('Auto-starting the daemon locally is not enabled. ' msg += '\n' + _('Auto-starting the daemon locally is not enabled. '
"See \"Options\" on the \"Connection Manager\".") 'See "Options" on the "Connection Manager".')
ErrorDialog(_('Failed To Connect'), msg).run() ErrorDialog(_('Failed To Connect'), msg).run()
def on_button_connect_clicked(self, widget=None): def on_button_connect_clicked(self, widget=None):

View file

@ -665,7 +665,7 @@ class ListView(object):
continue continue
column = find_column(col_state.name) column = find_column(col_state.name)
if not column: if not column:
log.debug("Could not find column matching \"%s\" on state.", col_state.name) log.debug('Could not find column matching "%s" on state.', col_state.name)
# The cases where I've found that the column could not be found # The cases where I've found that the column could not be found
# is when not using the english locale, ie, the default one, or # is when not using the english locale, ie, the default one, or
# when changing locales between runs. # when changing locales between runs.

View file

@ -552,7 +552,7 @@ class MenuBar(component.Component):
update_torrents.append(torrent_id) update_torrents.append(torrent_id)
if update_torrents: if update_torrents:
log.debug("Setting torrent owner \"%s\" on %s", username, update_torrents) log.debug('Setting torrent owner "%s" on %s', username, update_torrents)
def failed_change_owner(failure): def failed_change_owner(failure):
ErrorDialog( ErrorDialog(

View file

@ -1105,8 +1105,8 @@ class Preferences(component.Component):
username = model[itr][0] username = model[itr][0]
header = _('Remove Account') header = _('Remove Account')
text = _("Are you sure you wan't do remove the account with the " text = _('Are you sure you want to remove the account with the '
"username \"%(username)s\"?" % dict(username=username)) 'username "%(username)s"?' % dict(username=username))
dialog = YesNoDialog(header, text, parent=self.pref_dialog) dialog = YesNoDialog(header, text, parent=self.pref_dialog)
def dialog_finished(response_id): def dialog_finished(response_id):

View file

@ -328,7 +328,7 @@ class StatusBar(component.Component):
if space >= 0: if space >= 0:
self.diskspace_item.set_markup('<small>%s</small>' % fsize(space, shortform=True)) self.diskspace_item.set_markup('<small>%s</small>' % fsize(space, shortform=True))
else: else:
self.diskspace_item.set_markup("<span foreground=\"red\">" + _('Error') + '</span>') self.diskspace_item.set_markup('<span foreground="red">' + _('Error') + '</span>')
def _on_max_download_speed(self, max_download_speed): def _on_max_download_speed(self, max_download_speed):
self.max_download_speed = max_download_speed self.max_download_speed = max_download_speed

View file

@ -184,7 +184,7 @@ for script in script_list:
# Copy version info to file for nsis script. # Copy version info to file for nsis script.
with open('VERSION.tmp', 'w') as ver_file: with open('VERSION.tmp', 'w') as ver_file:
ver_file.write("build_version = \"%s\"" % build_version) ver_file.write('build_version = "%s"' % build_version)
# Create the install and uninstall file list for NSIS. # Create the install and uninstall file list for NSIS.
filedir_list = [] filedir_list = []

View file

@ -108,6 +108,7 @@ sitepackages = False
deps = deps =
{[testenv]deps} {[testenv]deps}
flake8 flake8
flake8-quotes
pep8-naming pep8-naming
commands = commands =
flake8 --version flake8 --version