mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 06:58:42 +00:00
Flake8 codebase
Fixes error E265 and E714 that have been added to newest version of pep8
This commit is contained in:
parent
142e96b246
commit
83262afda1
40 changed files with 214 additions and 200 deletions
|
@ -720,7 +720,7 @@ def decode_string(s, encoding="utf8"):
|
|||
lambda: (chardet.detect(s)["encoding"], 'strict'),
|
||||
lambda: (encoding, 'ignore')]
|
||||
|
||||
if not encoding is "utf8":
|
||||
if encoding is not "utf8":
|
||||
encodings.insert(0, lambda: (encoding, 'strict'))
|
||||
|
||||
for l in encodings:
|
||||
|
|
|
@ -59,7 +59,7 @@ class Core(component.Component):
|
|||
# Load the session state if available
|
||||
self.__load_session_state()
|
||||
|
||||
## Set session settings ##
|
||||
# --- Set session settings ---
|
||||
settings = self.session.get_settings()
|
||||
settings["user_agent"] = "Deluge/%(deluge_version)s libtorrent/%(lt_version)s" % {
|
||||
'deluge_version': deluge.common.get_version(),
|
||||
|
@ -73,7 +73,7 @@ class Core(component.Component):
|
|||
settings["disk_io_read_mode"] = lt.io_buffer_mode_t.disable_os_cache
|
||||
self.session.set_settings(settings)
|
||||
|
||||
## libtorrent plugins ##
|
||||
# --- libtorrent plugins ---
|
||||
# Allows peers to download the metadata from the swarm directly
|
||||
self.session.add_extension("metadata_transfer")
|
||||
self.session.add_extension("ut_metadata")
|
||||
|
|
|
@ -167,7 +167,7 @@ class Daemon(object):
|
|||
Returns:
|
||||
bool: True if authorized to call RPC, otherwise False.
|
||||
"""
|
||||
if not rpc in self.get_method_list():
|
||||
if rpc not in self.get_method_list():
|
||||
return False
|
||||
|
||||
return self.rpcserver.get_session_auth_level() >= self.rpcserver.get_rpc_auth_level(rpc)
|
||||
|
|
|
@ -277,7 +277,7 @@ class Torrent(object):
|
|||
self.set_prioritize_first_last_pieces(True)
|
||||
self.write_torrentfile()
|
||||
|
||||
## Options methods ##
|
||||
# --- Options methods ---
|
||||
def set_options(self, options):
|
||||
"""Set the torrent options.
|
||||
|
||||
|
@ -551,7 +551,7 @@ class Torrent(object):
|
|||
if self.rpcserver.get_session_auth_level() == AUTH_LEVEL_ADMIN:
|
||||
self.options["owner"] = account
|
||||
|
||||
### End Options methods ###
|
||||
# End Options methods #
|
||||
|
||||
def set_trackers(self, trackers):
|
||||
"""Sets the trackers for this torrent.
|
||||
|
|
|
@ -886,7 +886,7 @@ class TorrentManager(component.Component):
|
|||
for key in self.torrents.keys():
|
||||
self.torrents[key].set_max_download_speed(value)
|
||||
|
||||
## Alert handlers ##
|
||||
# --- Alert handlers ---
|
||||
def on_alert_torrent_finished(self, alert):
|
||||
"""Alert handler for libtorrent torrent_finished_alert"""
|
||||
log.debug("on_alert_torrent_finished")
|
||||
|
@ -1244,7 +1244,7 @@ class TorrentManager(component.Component):
|
|||
|
||||
# Get the torrent status for each torrent_id
|
||||
for torrent_id in torrent_ids:
|
||||
if not torrent_id in self.torrents:
|
||||
if torrent_id not in self.torrents:
|
||||
# The torrent_id does not exist in the dict.
|
||||
# Could be the clients cache (sessionproxy) isn't up to speed.
|
||||
del status_dict[torrent_id]
|
||||
|
|
|
@ -111,7 +111,7 @@ class Core(CorePluginBase):
|
|||
def update(self):
|
||||
pass
|
||||
|
||||
## Exported RPC methods ###
|
||||
# Exported RPC methods #
|
||||
@export
|
||||
def check_import(self, force=False):
|
||||
"""Imports latest blocklist specified by blocklist url.
|
||||
|
@ -375,7 +375,7 @@ class Core(CorePluginBase):
|
|||
|
||||
def on_read_ip_range(start, end):
|
||||
"""Add ip range to blocklist"""
|
||||
#~ log.trace("Adding ip range %s - %s to ipfilter as blocked", start, end)
|
||||
# log.trace("Adding ip range %s - %s to ipfilter as blocked", start, end)
|
||||
self.blocklist.add_rule(start.address, end.address, BLOCK_RANGE)
|
||||
self.num_blocked += 1
|
||||
|
||||
|
@ -417,7 +417,7 @@ class Core(CorePluginBase):
|
|||
log.debug("Importing using reader: %s", self.reader)
|
||||
log.debug("Reader type: %s compression: %s", self.config["list_type"], self.config["list_compression"])
|
||||
log.debug("Clearing current ip filtering")
|
||||
#~ self.blocklist.add_rule("0.0.0.0", "255.255.255.255", ALLOW_RANGE)
|
||||
# self.blocklist.add_rule("0.0.0.0", "255.255.255.255", ALLOW_RANGE)
|
||||
d = threads.deferToThread(self.reader(blocklist).read, on_read_ip_range)
|
||||
d.addCallback(on_finish_read).addErrback(on_reader_failure)
|
||||
|
||||
|
|
|
@ -195,8 +195,8 @@ class GtkUI(GtkPluginBase):
|
|||
self.whitelist_treeview.set_model(self.whitelist_model)
|
||||
|
||||
def on_cell_edited(self, cell, path_string, new_text, model):
|
||||
#~ iter = model.get_iter_from_string(path_string)
|
||||
#~ path = model.get_path(iter)[0]
|
||||
# iter = model.get_iter_from_string(path_string)
|
||||
# path = model.get_path(iter)[0]
|
||||
try:
|
||||
ip = common.IP.parse(new_text)
|
||||
model.set(model.get_iter_from_string(path_string), 0, ip.address)
|
||||
|
@ -223,7 +223,7 @@ class GtkUI(GtkPluginBase):
|
|||
selection = treeview.get_selection()
|
||||
model, iter = selection.get_selected()
|
||||
if iter:
|
||||
#~ path = model.get_path(iter)[0]
|
||||
# path = model.get_path(iter)[0]
|
||||
model.remove(iter)
|
||||
|
||||
def populate_whitelist(self, whitelist):
|
||||
|
|
|
@ -131,7 +131,7 @@ class Core(CorePluginBase):
|
|||
event_manager.deregister_event_handler(event, handler)
|
||||
log.debug("Execute core plugin disabled!")
|
||||
|
||||
### Exported RPC methods ###
|
||||
# Exported RPC methods #
|
||||
@export
|
||||
def add_command(self, event, command):
|
||||
command_id = hashlib.sha1(str(time.time())).hexdigest()
|
||||
|
|
|
@ -111,7 +111,7 @@ class Core(CorePluginBase):
|
|||
filter_dict['All'] = len(self.torrents.keys())
|
||||
return filter_dict
|
||||
|
||||
## Plugin hooks ##
|
||||
# Plugin hooks #
|
||||
def post_torrent_add(self, torrent_id, from_state):
|
||||
if from_state:
|
||||
return
|
||||
|
@ -129,11 +129,11 @@ class Core(CorePluginBase):
|
|||
if torrent_id in self.torrent_labels:
|
||||
del self.torrent_labels[torrent_id]
|
||||
|
||||
## Utils ##
|
||||
# Utils #
|
||||
def clean_config(self):
|
||||
"""remove invalid data from config-file"""
|
||||
for torrent_id, label_id in list(self.torrent_labels.iteritems()):
|
||||
if (not label_id in self.labels) or (not torrent_id in self.torrents):
|
||||
if (label_id not in self.labels) or (torrent_id not in self.torrents):
|
||||
log.debug("label: rm %s:%s" % (torrent_id, label_id))
|
||||
del self.torrent_labels[torrent_id]
|
||||
|
||||
|
@ -260,7 +260,7 @@ class Core(CorePluginBase):
|
|||
"""
|
||||
check_input(label_id in self.labels, _("Unknown Label"))
|
||||
for key in options_dict.keys():
|
||||
if not key in OPTIONS_DEFAULTS:
|
||||
if key not in OPTIONS_DEFAULTS:
|
||||
raise Exception("label: Invalid options_dict key:%s" % key)
|
||||
|
||||
self.labels[label_id].update(options_dict)
|
||||
|
|
|
@ -19,7 +19,7 @@ sclient.set_core_uri()
|
|||
print(sclient.get_enabled_plugins())
|
||||
|
||||
# enable plugin.
|
||||
if not "label" in sclient.get_enabled_plugins():
|
||||
if "label" not in sclient.get_enabled_plugins():
|
||||
sclient.enable_plugin("label")
|
||||
|
||||
|
||||
|
|
|
@ -274,10 +274,8 @@ class GtkUI(GtkPluginBase, GtkUiNotifications):
|
|||
self.glade.get_widget("popup_enabled").set_property('sensitive',
|
||||
False)
|
||||
if not SOUND_AVAILABLE:
|
||||
# for widget_name in ('sound_enabled', 'sound_path', 'sounds_page',
|
||||
# 'sounds_page_label'):
|
||||
# self.glade.get_widget(widget_name).set_property('sensitive',
|
||||
# False)
|
||||
# for widget_name in ('sound_enabled', 'sound_path', 'sounds_page', 'sounds_page_label'):
|
||||
# self.glade.get_widget(widget_name).set_property('sensitive', False)
|
||||
self.glade.get_widget("sound_enabled").set_property('sensitive',
|
||||
False)
|
||||
self.glade.get_widget('sound_path').set_property('sensitive', False)
|
||||
|
|
|
@ -127,7 +127,7 @@ class Graph:
|
|||
x_step = step
|
||||
break
|
||||
else:
|
||||
# if there wasnt anything useful find a nice fitting hourly divisor
|
||||
# If there wasnt anything useful find a nice fitting hourly divisor
|
||||
x_step = ((duration / 5) / 3600) * 3600
|
||||
|
||||
# this doesnt allow for dst and timezones...
|
||||
|
|
|
@ -28,7 +28,7 @@ print("\n\n")
|
|||
|
||||
if 0: # aclient non-core
|
||||
methods = sorted([m for m in dir(aclient) if not m.startswith('_')
|
||||
if not m in ['add_torrent_file', 'has_callback', 'get_method', 'methodHelp',
|
||||
if m not in ['add_torrent_file', 'has_callback', 'get_method', 'methodHelp',
|
||||
'methodSignature', 'list_methods', 'add_torrent_file_binary']])
|
||||
|
||||
for m in methods:
|
||||
|
@ -57,8 +57,7 @@ if 1: # baseclient/core
|
|||
func = getattr(Core, m)
|
||||
|
||||
params = inspect.getargspec(func)[0][1:]
|
||||
if (aclient.has_callback(method_name)
|
||||
and not method_name in ['add_torrent_file_binary']):
|
||||
if (aclient.has_callback(method_name) and method_name not in ['add_torrent_file_binary']):
|
||||
params = ["[callback]"] + params
|
||||
|
||||
print("\n'''%s(%s): '''\n" % (method_name, ", ".join(params)))
|
||||
|
|
|
@ -374,7 +374,6 @@ class FilesTab(Tab):
|
|||
value[1]["size"], "", 0, 0, value[0], gtk.STOCK_FILE])
|
||||
ret += value[1]["size"]
|
||||
return ret
|
||||
###
|
||||
|
||||
def update_files(self):
|
||||
self.treestore.clear()
|
||||
|
|
|
@ -151,7 +151,7 @@ class FilterTreeView(component.Component):
|
|||
def cb_update_filter_tree(self, filter_items):
|
||||
# create missing cat_nodes
|
||||
for cat in filter_items:
|
||||
if not cat in self.cat_nodes:
|
||||
if cat not in self.cat_nodes:
|
||||
label = _(cat)
|
||||
if cat == "label":
|
||||
label = _("Labels")
|
||||
|
@ -170,7 +170,7 @@ class FilterTreeView(component.Component):
|
|||
|
||||
# hide items not returned by core-plugin.
|
||||
for f in self.filters:
|
||||
if not f in visible_filters:
|
||||
if f not in visible_filters:
|
||||
self.treestore.set_value(self.filters[f], FILTER_COLUMN, False)
|
||||
|
||||
if self.expand_rows:
|
||||
|
@ -300,7 +300,7 @@ class FilterTreeView(component.Component):
|
|||
except Exception as ex:
|
||||
log.debug(ex)
|
||||
|
||||
### Callbacks ###
|
||||
# Callbacks #
|
||||
def on_button_press_event(self, widget, event):
|
||||
"""This is a callback for showing the right-click context menu."""
|
||||
x, y = event.get_coords()
|
||||
|
|
|
@ -109,7 +109,7 @@ class MenuBar(component.Component):
|
|||
self.main_builder.get_object("sidebar_show_zero").set_active(self.config["sidebar_show_zero"])
|
||||
self.main_builder.get_object("sidebar_show_trackers").set_active(self.config["sidebar_show_trackers"])
|
||||
|
||||
### Connect main window Signals ###
|
||||
# Connect main window Signals #
|
||||
component.get("MainWindow").connect_signals({
|
||||
# File Menu
|
||||
"on_menuitem_addtorrent_activate": self.on_menuitem_addtorrent_activate,
|
||||
|
@ -220,7 +220,7 @@ class MenuBar(component.Component):
|
|||
sep.show()
|
||||
return sep
|
||||
|
||||
### Callbacks ###
|
||||
# Callbacks #
|
||||
def on_torrentstatechanged_event(self, torrent_id, state):
|
||||
if state == "Paused":
|
||||
self.update_menu()
|
||||
|
@ -234,7 +234,7 @@ class MenuBar(component.Component):
|
|||
def on_sessionresumed_event(self):
|
||||
self.update_menu()
|
||||
|
||||
## File Menu ##
|
||||
# File Menu #
|
||||
def on_menuitem_addtorrent_activate(self, data=None):
|
||||
log.debug("on_menuitem_addtorrent_activate")
|
||||
component.get("AddTorrentDialog").show()
|
||||
|
@ -252,7 +252,7 @@ class MenuBar(component.Component):
|
|||
log.debug("on_menuitem_quit_activate")
|
||||
self.window.quit()
|
||||
|
||||
## Edit Menu ##
|
||||
# Edit Menu #
|
||||
def on_menuitem_preferences_activate(self, data=None):
|
||||
log.debug("on_menuitem_preferences_activate")
|
||||
component.get("Preferences").show()
|
||||
|
@ -261,7 +261,7 @@ class MenuBar(component.Component):
|
|||
log.debug("on_menuitem_connectionmanager_activate")
|
||||
component.get("ConnectionManager").show()
|
||||
|
||||
## Torrent Menu ##
|
||||
# Torrent Menu #
|
||||
def on_menuitem_pause_activate(self, data=None):
|
||||
log.debug("on_menuitem_pause_activate")
|
||||
client.core.pause_torrent(
|
||||
|
@ -364,7 +364,7 @@ class MenuBar(component.Component):
|
|||
log.debug("on_menuitem_queue_bottom_activate")
|
||||
client.core.queue_bottom(component.get("TorrentView").get_selected_torrents())
|
||||
|
||||
## View Menu ##
|
||||
# View Menu #
|
||||
def on_menuitem_toolbar_toggled(self, value):
|
||||
log.debug("on_menuitem_toolbar_toggled")
|
||||
component.get("ToolBar").visible(value.get_active())
|
||||
|
@ -377,7 +377,7 @@ class MenuBar(component.Component):
|
|||
log.debug("on_menuitem_statusbar_toggled")
|
||||
component.get("StatusBar").visible(value.get_active())
|
||||
|
||||
## Help Menu ##
|
||||
# Help Menu #
|
||||
def on_menuitem_homepage_activate(self, data=None):
|
||||
log.debug("on_menuitem_homepage_activate")
|
||||
deluge.common.open_url_in_browser("http://deluge-torrent.org")
|
||||
|
|
|
@ -70,7 +70,7 @@ class PathChoosersHandler(component.Component):
|
|||
chooser.config_key_funcs[key][1] = getattr(chooser, "set_%s" % self.config_keys_to_funcs_mapping[key])
|
||||
|
||||
self.path_choosers.append(chooser)
|
||||
if not chooser.paths_config_key in self.paths_list_keys:
|
||||
if chooser.paths_config_key not in self.paths_list_keys:
|
||||
self.paths_list_keys.append(chooser.paths_config_key)
|
||||
if self.started:
|
||||
self.update_config_from_core()
|
||||
|
@ -82,7 +82,7 @@ class PathChoosersHandler(component.Component):
|
|||
chooser.config_key_funcs[key][1](value)
|
||||
|
||||
# Save to core
|
||||
if not key is "path_chooser_max_popup_rows":
|
||||
if key is not "path_chooser_max_popup_rows":
|
||||
client.core.set_config({key: value})
|
||||
else:
|
||||
# Since the max rows value can be changed fast with a spinbutton, we
|
||||
|
|
|
@ -283,7 +283,7 @@ class ValueList(object):
|
|||
next = None
|
||||
|
||||
# If next is None, we won't change the selection
|
||||
if not next is None:
|
||||
if next is not None:
|
||||
# We move the selection either one up or down.
|
||||
# If we reach end of list, we wrap
|
||||
index = path[0] if path else 0
|
||||
|
@ -674,9 +674,9 @@ class PathChooserPopup(object):
|
|||
def get_max_popup_rows(self):
|
||||
return self.max_visible_rows
|
||||
|
||||
###################################################
|
||||
#################
|
||||
# Callbacks
|
||||
###################################################
|
||||
#################
|
||||
|
||||
def on_popup_window_button_press_event(self, window, event):
|
||||
# If we're clicking outside of the window close the popup
|
||||
|
@ -760,9 +760,9 @@ class StoredValuesPopup(StoredValuesList, PathChooserPopup):
|
|||
# Set value selected if it exists
|
||||
self.set_selected_value(path_without_trailing_path_sep(self.path_entry.get_text()))
|
||||
|
||||
###################################################
|
||||
#################
|
||||
# Callbacks
|
||||
###################################################
|
||||
#################
|
||||
|
||||
def on_stored_values_popup_window_focus_out_event(self, entry, event):
|
||||
"""
|
||||
|
@ -885,9 +885,9 @@ class PathCompletionPopup(CompletionList, PathChooserPopup):
|
|||
self.text_entry.set_position(len(self.path_entry.text_entry.get_text()))
|
||||
self.set_selected_value(path_without_trailing_path_sep(self.path_entry.get_text()), select_first=True)
|
||||
|
||||
###################################################
|
||||
#################
|
||||
# Callbacks
|
||||
###################################################
|
||||
#################
|
||||
|
||||
def on_completion_popup_window_focus_out_event(self, entry, event):
|
||||
"""
|
||||
|
@ -1104,7 +1104,7 @@ class PathChooserComboBox(gtk.HBox, StoredValuesPopup, gobject.GObject):
|
|||
folder_name = ""
|
||||
if self.show_folder_name_on_button or not self.path_entry_visible:
|
||||
folder_name = path_without_trailing_path_sep(text)
|
||||
if not folder_name is "/" and os.path.basename(folder_name):
|
||||
if folder_name is not "/" and os.path.basename(folder_name):
|
||||
folder_name = os.path.basename(folder_name)
|
||||
self.folder_name_label.set_text(folder_name)
|
||||
# Only trigger event if text has changed
|
||||
|
@ -1248,9 +1248,9 @@ class PathChooserComboBox(gtk.HBox, StoredValuesPopup, gobject.GObject):
|
|||
"""
|
||||
self.auto_completer._end_completion(args)
|
||||
|
||||
######################################
|
||||
##############
|
||||
# Callbacks and internal functions
|
||||
######################################
|
||||
##############
|
||||
|
||||
def on_entry_text_changed(self, entry):
|
||||
self.emit("text-changed", self.get_text())
|
||||
|
@ -1348,9 +1348,9 @@ class PathChooserComboBox(gtk.HBox, StoredValuesPopup, gobject.GObject):
|
|||
self.button_toggle.set_active(False)
|
||||
self._stored_values_popping_down = False
|
||||
|
||||
######################################
|
||||
##############
|
||||
# Config dialog
|
||||
######################################
|
||||
##############
|
||||
|
||||
def _on_button_toggle_dropdown_button_press_event(self, widget, event):
|
||||
"""Show config when right clicking dropdown toggle button"""
|
||||
|
|
|
@ -462,13 +462,13 @@ class Preferences(component.Component):
|
|||
# Update the toggle status if necessary
|
||||
self.on_toggle(widget)
|
||||
|
||||
## Downloads tab ##
|
||||
# Downloads tab #
|
||||
self.builder.get_object("chk_show_dialog").set_active(
|
||||
self.gtkui_config["interactive_add"])
|
||||
self.builder.get_object("chk_focus_dialog").set_active(
|
||||
self.gtkui_config["focus_add_dialog"])
|
||||
|
||||
## Interface tab ##
|
||||
# Interface tab #
|
||||
self.builder.get_object("chk_use_tray").set_active(
|
||||
self.gtkui_config["enable_system_tray"])
|
||||
self.builder.get_object("chk_min_on_close").set_active(
|
||||
|
@ -495,15 +495,15 @@ class Preferences(component.Component):
|
|||
self.__set_color("waiting", from_config=True)
|
||||
self.__set_color("missing", from_config=True)
|
||||
|
||||
## Other tab ##
|
||||
# Other tab #
|
||||
self.builder.get_object("chk_show_new_releases").set_active(
|
||||
self.gtkui_config["show_new_releases"])
|
||||
|
||||
## Cache tab ##
|
||||
# Cache tab #
|
||||
if client.connected():
|
||||
self.__update_cache_status()
|
||||
|
||||
## Plugins tab ##
|
||||
# Plugins tab #
|
||||
all_plugins = self.all_plugins
|
||||
enabled_plugins = self.enabled_plugins
|
||||
# Clear the existing list so we don't duplicate entries.
|
||||
|
@ -534,7 +534,7 @@ class Preferences(component.Component):
|
|||
new_core_config = {}
|
||||
new_gtkui_config = {}
|
||||
|
||||
## Downloads tab ##
|
||||
# Downloads tab #
|
||||
new_gtkui_config["interactive_add"] = \
|
||||
self.builder.get_object("chk_show_dialog").get_active()
|
||||
new_gtkui_config["focus_add_dialog"] = \
|
||||
|
@ -563,7 +563,7 @@ class Preferences(component.Component):
|
|||
new_core_config["add_paused"] = self.builder.get_object("chk_add_paused").get_active()
|
||||
new_core_config["pre_allocate_storage"] = self.builder.get_object("chk_pre_allocation").get_active()
|
||||
|
||||
## Network tab ##
|
||||
# Network tab #
|
||||
listen_ports = (
|
||||
self.builder.get_object("spin_port_min").get_value_as_int(),
|
||||
self.builder.get_object("spin_port_max").get_value_as_int()
|
||||
|
@ -599,7 +599,7 @@ class Preferences(component.Component):
|
|||
new_core_config["enc_level"] = \
|
||||
self.builder.get_object("combo_enclevel").get_active()
|
||||
|
||||
## Bandwidth tab ##
|
||||
# Bandwidth tab #
|
||||
new_core_config["max_connections_global"] = \
|
||||
self.builder.get_object(
|
||||
"spin_max_connections_global").get_value_as_int()
|
||||
|
@ -632,7 +632,7 @@ class Preferences(component.Component):
|
|||
new_core_config["rate_limit_ip_overhead"] = \
|
||||
self.builder.get_object("chk_rate_limit_ip_overhead").get_active()
|
||||
|
||||
## Interface tab ##
|
||||
# Interface tab #
|
||||
new_gtkui_config["enable_system_tray"] = \
|
||||
self.builder.get_object("chk_use_tray").get_active()
|
||||
new_gtkui_config["close_to_tray"] = \
|
||||
|
@ -655,7 +655,7 @@ class Preferences(component.Component):
|
|||
new_gtkui_config["focus_main_window_on_add"] = \
|
||||
self.builder.get_object("chk_focus_main_window_on_add").get_active()
|
||||
|
||||
## Other tab ##
|
||||
# Other tab #
|
||||
new_gtkui_config["show_new_releases"] = \
|
||||
self.builder.get_object("chk_show_new_releases").get_active()
|
||||
new_core_config["send_info"] = \
|
||||
|
@ -663,7 +663,7 @@ class Preferences(component.Component):
|
|||
new_core_config["geoip_db_location"] = \
|
||||
self.builder.get_object("entry_geoip").get_text()
|
||||
|
||||
## Daemon tab ##
|
||||
# Daemon tab #
|
||||
new_core_config["daemon_port"] = \
|
||||
self.builder.get_object("spin_daemon_port").get_value_as_int()
|
||||
new_core_config["allow_remote"] = \
|
||||
|
@ -671,7 +671,7 @@ class Preferences(component.Component):
|
|||
new_core_config["new_release_check"] = \
|
||||
self.builder.get_object("chk_new_releases").get_active()
|
||||
|
||||
## Proxy tab ##
|
||||
# Proxy tab #
|
||||
new_core_config["proxy"] = {}
|
||||
new_core_config["proxy"]["type"] = self.builder.get_object("combo_proxy_type").get_active()
|
||||
new_core_config["proxy"]["username"] = self.builder.get_object("entry_proxy_user").get_text()
|
||||
|
@ -686,7 +686,7 @@ class Preferences(component.Component):
|
|||
new_core_config["i2p_proxy"]["port"] = self.builder.get_object("spin_i2p_port").get_value_as_int()
|
||||
new_core_config["anonymous_mode"] = self.builder.get_object("chk_anonymous_mode").get_active()
|
||||
|
||||
## Queue tab ##
|
||||
# Queue tab #
|
||||
new_core_config["queue_new_to_top"] = \
|
||||
self.builder.get_object("chk_queue_new_top").get_active()
|
||||
new_core_config["max_active_seeding"] = \
|
||||
|
@ -712,7 +712,7 @@ class Preferences(component.Component):
|
|||
new_core_config["seed_time_limit"] = \
|
||||
self.builder.get_object("spin_seed_time_limit").get_value()
|
||||
|
||||
## Cache tab ##
|
||||
# Cache tab #
|
||||
new_core_config["cache_size"] = \
|
||||
self.builder.get_object("spin_cache_size").get_value_as_int()
|
||||
new_core_config["cache_expiry"] = \
|
||||
|
|
|
@ -28,7 +28,7 @@ class ToolBar(component.Component):
|
|||
self.window = component.get("MainWindow")
|
||||
self.toolbar = self.window.get_builder().get_object("toolbar")
|
||||
self.config = ConfigManager("gtkui.conf")
|
||||
### Connect main window Signals ###
|
||||
# Connect main window Signals #
|
||||
self.window.connect_signals({
|
||||
"on_toolbutton_add_clicked": self.on_toolbutton_add_clicked,
|
||||
"on_toolbutton_remove_clicked": self.on_toolbutton_remove_clicked,
|
||||
|
@ -106,7 +106,7 @@ class ToolBar(component.Component):
|
|||
"""Removes a widget from the toolbar"""
|
||||
self.toolbar.remove(widget)
|
||||
|
||||
### Callbacks (Uses the menubar's callback) ###
|
||||
# Callbacks (Uses the menubar's callback) #
|
||||
|
||||
def on_toolbutton_add_clicked(self, data):
|
||||
log.debug("on_toolbutton_add_clicked")
|
||||
|
|
|
@ -284,7 +284,7 @@ class TorrentView(ListView, component.Component):
|
|||
# Set filter to None for now
|
||||
self.filter = None
|
||||
|
||||
### Connect Signals ###
|
||||
# Connect Signals #
|
||||
# Connect to the 'button-press-event' to know when to bring up the
|
||||
# torrent menu popup.
|
||||
self.treeview.connect("button-press-event", self.on_button_press_event)
|
||||
|
@ -592,7 +592,7 @@ class TorrentView(ListView, component.Component):
|
|||
def get_visible_torrents(self):
|
||||
return self.status.keys()
|
||||
|
||||
### Callbacks ###
|
||||
# Callbacks #
|
||||
def on_button_press_event(self, widget, event):
|
||||
"""This is a callback for showing the right-click context menu."""
|
||||
log.debug("on_button_press_event")
|
||||
|
|
|
@ -480,7 +480,7 @@ class TrackerIcons(Component):
|
|||
host = self.redirects[host]
|
||||
return "http://%s/" % host
|
||||
|
||||
################################ HELPER CLASSES ###############################
|
||||
# ------- HELPER CLASSES ------
|
||||
|
||||
|
||||
class FaviconParser(HTMLParser):
|
||||
|
@ -525,7 +525,7 @@ class FaviconParser(HTMLParser):
|
|||
return self.icons
|
||||
|
||||
|
||||
############################### HELPER FUNCTIONS ##############################
|
||||
# ------ HELPER FUNCTIONS ------
|
||||
|
||||
def url_to_host(url):
|
||||
"""
|
||||
|
@ -604,7 +604,7 @@ def extension_to_mimetype(extension):
|
|||
"""
|
||||
return MIME_MAP[extension.lower()]
|
||||
|
||||
################################## EXCEPTIONS #################################
|
||||
# ------ EXCEPTIONS ------
|
||||
|
||||
|
||||
class NoIconsError(Exception):
|
||||
|
|
|
@ -21,6 +21,8 @@ try:
|
|||
except ImportError:
|
||||
get_version = None
|
||||
|
||||
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||
|
||||
# If your extensions are in another directory, add it here. If the directory
|
||||
# is relative to the documentation root, use os.path.abspath to make it
|
||||
# absolute, like shown here.
|
||||
|
@ -52,6 +54,9 @@ MOCK_MODULES = ['deluge.ui.languages', 'deluge.ui.countries', 'deluge.ui.gtkui.g
|
|||
'deluge.libtorrent', 'psyco', 'rencode', 'win32file', 'win32event',
|
||||
'win32gui', 'win32api', 'win32con', '_winreg']
|
||||
|
||||
if on_rtd:
|
||||
MOCK_MODULES += ['libtorrent', 'pytgtk']
|
||||
|
||||
for mod_name in MOCK_MODULES:
|
||||
sys.modules[mod_name] = Mock()
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ try:
|
|||
except AttributeError:
|
||||
StringTypes = [type("")]
|
||||
|
||||
|
||||
class Structure:
|
||||
def __init__(self):
|
||||
size = self._sizeInBytes = struct.calcsize(self._format_)
|
||||
|
@ -37,12 +38,14 @@ class Structure:
|
|||
indexes = self._indexes_ = {}
|
||||
for i in range(len(self._names_)):
|
||||
indexes[self._names_[i]] = i
|
||||
|
||||
def dump(self):
|
||||
# print "I: DUMP of", self
|
||||
for name in self._names_:
|
||||
if name[0] != '_':
|
||||
# print "I: %20s = %s" % (name, getattr(self, name))
|
||||
pass
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name in self._names_:
|
||||
index = self._indexes_[name]
|
||||
|
@ -50,35 +53,43 @@ class Structure:
|
|||
try:
|
||||
return self.__dict__[name]
|
||||
except KeyError:
|
||||
raise AttributeError, name
|
||||
raise AttributeError(name)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name in self._names_:
|
||||
index = self._indexes_[name]
|
||||
self._fields_[index] = value
|
||||
else:
|
||||
self.__dict__[name] = value
|
||||
|
||||
def tostring(self):
|
||||
return apply(struct.pack, [self._format_, ] + self._fields_)
|
||||
|
||||
def fromfile(self, file):
|
||||
data = file.read(self._sizeInBytes)
|
||||
self._fields_ = list(struct.unpack(self._format_, data))
|
||||
|
||||
|
||||
class ICONDIRHEADER(Structure):
|
||||
_names_ = "idReserved", "idType", "idCount"
|
||||
_format_ = "hhh"
|
||||
|
||||
|
||||
class ICONDIRENTRY(Structure):
|
||||
_names_ = "bWidth", "bHeight", "bColorCount", "bReserved", "wPlanes", "wBitCount", "dwBytesInRes", "dwImageOffset"
|
||||
_format_ = "bbbbhhii"
|
||||
|
||||
|
||||
class GRPICONDIR(Structure):
|
||||
_names_ = "idReserved", "idType", "idCount"
|
||||
_format_ = "hhh"
|
||||
|
||||
|
||||
class GRPICONDIRENTRY(Structure):
|
||||
_names_ = "bWidth", "bHeight", "bColorCount", "bReserved", "wPlanes", "wBitCount", "dwBytesInRes", "nID"
|
||||
_format_ = "bbbbhhih"
|
||||
|
||||
|
||||
class IconFile:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
@ -110,8 +121,8 @@ class IconFile:
|
|||
return data
|
||||
|
||||
|
||||
def CopyIcons_FromIco (dstpath, srcpath, id=1):
|
||||
import win32api #, win32con
|
||||
def CopyIcons_FromIco(dstpath, srcpath, id=1): # NOQA
|
||||
import win32api
|
||||
icons = map(IconFile, srcpath)
|
||||
print "I: Updating icons from", srcpath, "to", dstpath
|
||||
|
||||
|
@ -131,8 +142,10 @@ def CopyIcons_FromIco (dstpath, srcpath, id=1):
|
|||
|
||||
win32api.EndUpdateResource(hdst, 0)
|
||||
|
||||
def CopyIcons (dstpath, srcpath):
|
||||
import os.path, string
|
||||
|
||||
def CopyIcons(dstpath, srcpath): # NOQA
|
||||
import os.path
|
||||
import string
|
||||
|
||||
if type(srcpath) in StringTypes:
|
||||
srcpath = [srcpath]
|
||||
|
@ -153,9 +166,9 @@ def CopyIcons (dstpath, srcpath):
|
|||
for s in srcpath:
|
||||
e = os.path.splitext(s[0])[1]
|
||||
if string.lower(e) != '.ico':
|
||||
raise ValueError, "multiple icons supported only from .ico files"
|
||||
raise ValueError("multiple icons supported only from .ico files")
|
||||
if s[1] is not None:
|
||||
raise ValueError, "index not allowed for .ico files"
|
||||
raise ValueError("index not allowed for .ico files")
|
||||
srcs.append(s[0])
|
||||
return CopyIcons_FromIco(dstpath, srcs)
|
||||
|
||||
|
@ -167,7 +180,7 @@ def CopyIcons (dstpath, srcpath):
|
|||
print "I: Updating icons from", srcpath, ", %d to" % index, dstpath
|
||||
else:
|
||||
print "I: Updating icons from", srcpath, "to", dstpath
|
||||
import win32api #, win32con
|
||||
import win32api
|
||||
hdst = win32api.BeginUpdateResource(dstpath, 0)
|
||||
hsrc = win32api.LoadLibraryEx(srcpath, 0, LOAD_LIBRARY_AS_DATAFILE)
|
||||
if index is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue