mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 03:24:54 +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)
|
||||
|
|
|
@ -30,7 +30,7 @@ class EventManager(component.Component):
|
|||
# Call any handlers for the event
|
||||
if event.name in self.handlers:
|
||||
for handler in self.handlers[event.name]:
|
||||
#log.debug("Running handler %s for event %s with args: %s", event.name, handler, event.args)
|
||||
# log.debug("Running handler %s for event %s with args: %s", event.name, handler, event.args)
|
||||
try:
|
||||
handler(*event.args)
|
||||
except Exception as ex:
|
||||
|
|
|
@ -128,7 +128,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
|||
log.debug("Received invalid rpc request: number of items "
|
||||
"in request is %s", len(call))
|
||||
continue
|
||||
#log.debug("RPCRequest: %s", format_request(call))
|
||||
# log.debug("RPCRequest: %s", format_request(call))
|
||||
reactor.callLater(0, self.dispatch, *call)
|
||||
|
||||
def sendData(self, data): # NOQA
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -77,7 +77,7 @@ class Core(CorePluginBase):
|
|||
self.plugin = component.get("CorePluginManager")
|
||||
self.plugin.register_status_field("label", self._status_get_label)
|
||||
|
||||
#__init__
|
||||
# __init__
|
||||
core = component.get("Core")
|
||||
self.config = ConfigManager("label.conf", defaults=CONFIG_DEFAULTS)
|
||||
self.core_cfg = ConfigManager("core.conf")
|
||||
|
@ -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)
|
||||
|
|
|
@ -40,7 +40,7 @@ class TestEmailNotifications(component.Component):
|
|||
log.debug("\n\nEnabling %s", self.__class__.__name__)
|
||||
for event in self.events:
|
||||
if self.__imp == 'core':
|
||||
# component.get("CorePlugin.Notifications").register_custom_email_notification(
|
||||
# component.get("CorePlugin.Notifications").register_custom_email_notification(
|
||||
component.get("Notifications").register_custom_email_notification(
|
||||
event.__class__.__name__,
|
||||
self.custom_email_message_provider
|
||||
|
|
|
@ -75,7 +75,7 @@ class Core(CorePluginBase):
|
|||
|
||||
self.length = self.config["length"]
|
||||
|
||||
#self.stats = get_key(self.saved_stats, "stats") or {}
|
||||
# self.stats = get_key(self.saved_stats, "stats") or {}
|
||||
self.stats_keys = []
|
||||
self.add_stats(
|
||||
'upload_rate',
|
||||
|
@ -126,10 +126,10 @@ class Core(CorePluginBase):
|
|||
stats.update(self.core.get_config_values(["max_download",
|
||||
"max_upload",
|
||||
"max_num_connections"]))
|
||||
# status = self.core.session.status()
|
||||
# for stat in dir(status):
|
||||
# if not stat.startswith('_') and stat not in stats:
|
||||
# stats[stat] = getattr(status, stat, None)
|
||||
# status = self.core.session.status()
|
||||
# for stat in dir(status):
|
||||
# if not stat.startswith('_') and stat not in stats:
|
||||
# stats[stat] = getattr(status, stat, None)
|
||||
|
||||
update_time = time.time()
|
||||
self.last_update[1] = update_time
|
||||
|
|
|
@ -94,9 +94,9 @@ class Graph:
|
|||
self.stats = stats
|
||||
return
|
||||
|
||||
# def set_config(self, config):
|
||||
# self.length = config["length"]
|
||||
# self.interval = config["update_interval"]
|
||||
# def set_config(self, config):
|
||||
# self.length = config["length"]
|
||||
# self.interval = config["update_interval"]
|
||||
|
||||
def set_interval(self, interval):
|
||||
self.interval = interval
|
||||
|
@ -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...
|
||||
|
@ -172,7 +172,7 @@ class Graph:
|
|||
y_tick_width = max((space_required(text) for text in y_tick_text))
|
||||
|
||||
top = font_extents[2] / 2.0
|
||||
#bounds(left, top, right, bottom)
|
||||
# bounds(left, top, right, bottom)
|
||||
bounds = (y_tick_width + 4, top + 2, self.width, self.height - x_axis_space)
|
||||
|
||||
self.draw_x_axis(bounds)
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -91,7 +91,7 @@ class TransferTestClass(DelugeTransferProtocol):
|
|||
(len(data), len(data) - len(dobj.unused_data), len(dobj.unused_data)))
|
||||
print("Packet count:", self.packet_count)
|
||||
except Exception as ex:
|
||||
#log.debug("Received possible invalid message (%r): %s", data, e)
|
||||
# log.debug("Received possible invalid message (%r): %s", data, e)
|
||||
# This could be cut-off data, so we'll save this in the buffer
|
||||
# and try to prepend it on the next dataReceived()
|
||||
self._buffer = data
|
||||
|
|
|
@ -199,11 +199,11 @@ class Win32IcoFile(object):
|
|||
im = im.convert('RGBA')
|
||||
im.putalpha(mask)
|
||||
log.debug("image mode: %s", im.mode)
|
||||
# end if !'RGBA'
|
||||
# end if !'RGBA'
|
||||
# end if (png)/else(bmp)
|
||||
|
||||
return im
|
||||
# end frame
|
||||
# end frame
|
||||
|
||||
def __repr__(self):
|
||||
s = 'Microsoft Icon: %d images (max %dx%d %dbpp)' % (
|
||||
|
|
|
@ -104,7 +104,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
|||
|
||||
if message_type == RPC_EVENT:
|
||||
event = request[1]
|
||||
#log.debug("Received RPCEvent: %s", event)
|
||||
# log.debug("Received RPCEvent: %s", event)
|
||||
# A RPCEvent was received from the daemon so run any handlers
|
||||
# associated with it.
|
||||
if event in self.factory.event_handlers:
|
||||
|
@ -178,7 +178,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
|||
# response to this request. We use the extra information when printing
|
||||
# out the error for debugging purposes.
|
||||
self.__rpc_requests[request.request_id] = request
|
||||
#log.debug("Sending RPCRequest %s: %s", request.request_id, request)
|
||||
# log.debug("Sending RPCRequest %s: %s", request.request_id, request)
|
||||
# Send the request in a tuple because multiple requests can be sent at once
|
||||
self.transfer_message((request.format_message(),))
|
||||
except Exception as ex:
|
||||
|
@ -450,7 +450,7 @@ class DaemonClassicProxy(DaemonProxy):
|
|||
self.__daemon = None
|
||||
|
||||
def call(self, method, *args, **kwargs):
|
||||
#log.debug("call: %s %s %s", method, args, kwargs)
|
||||
# log.debug("call: %s %s %s", method, args, kwargs)
|
||||
|
||||
import copy
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ class DelugeHelpFormatter (optparse.IndentedHelpFormatter):
|
|||
"\.\.\.": "{!yellow!}%s{!input!}",
|
||||
"\s\*\s": "{!blue!}%s{!input!}",
|
||||
"(?<![\-a-z])(-[a-zA-Z0-9])": "{!red!}%s{!input!}",
|
||||
#"(\-[a-zA-Z0-9])": "{!red!}%s{!input!}",
|
||||
# "(\-[a-zA-Z0-9])": "{!red!}%s{!input!}",
|
||||
"--[_\-a-zA-Z0-9]+": "{!green!}%s{!input!}",
|
||||
"(\[|\])": "{!info!}%s{!input!}",
|
||||
|
||||
|
|
|
@ -810,7 +810,7 @@ class AllTorrents(BaseMode, component.Component):
|
|||
|
||||
def refresh(self, lines=None):
|
||||
# log.error("ref")
|
||||
#import traceback
|
||||
# import traceback
|
||||
# traceback.print_stack()
|
||||
# Something has requested we scroll to the top of the list
|
||||
if self._go_top:
|
||||
|
|
|
@ -166,8 +166,8 @@ class Legacy(BaseMode, component.Component):
|
|||
# simply scan for lines beginning with ">>> "
|
||||
for i, line in enumerate(self.lines):
|
||||
# if not isinstance(line, unicode):
|
||||
#line = line.encode(self.encoding)
|
||||
#self.lines[i] = line
|
||||
# line = line.encode(self.encoding)
|
||||
# self.lines[i] = line
|
||||
line = format_utils.remove_formatting(line)
|
||||
if line.startswith(">>> "):
|
||||
input = line[4:]
|
||||
|
|
|
@ -334,7 +334,7 @@ class MessagePopup(Popup):
|
|||
"""
|
||||
def __init__(self, parent_mode, title, message, align=ALIGN.DEFAULT, width_req=0.5):
|
||||
self.message = message
|
||||
#self.width= int(parent_mode.cols/2)
|
||||
# self.width= int(parent_mode.cols/2)
|
||||
Popup.__init__(self, parent_mode, title, align=align, width_req=width_req)
|
||||
lns = format_utils.wrap_string(self.message, self.width - 2, 3, True)
|
||||
self.height_req = min(len(lns) + 2, int(parent_mode.rows * 2 / 3))
|
||||
|
|
|
@ -274,7 +274,7 @@ class TorrentDetail(BaseMode, component.Component):
|
|||
fl = s[3]
|
||||
fe[0] = new_folder.strip("/").rpartition("/")[-1]
|
||||
|
||||
#self.__get_file_by_name(old_folder, self.file_list)[0] = new_folder.strip("/")
|
||||
# self.__get_file_by_name(old_folder, self.file_list)[0] = new_folder.strip("/")
|
||||
component.get("SessionProxy").get_torrent_status(
|
||||
self.torrentid, self._status_keys).addCallback(self.set_state)
|
||||
|
||||
|
@ -284,8 +284,8 @@ class TorrentDetail(BaseMode, component.Component):
|
|||
color_partially_selected = "magenta"
|
||||
color_highlighted = "white"
|
||||
for fl in files:
|
||||
#from sys import stderr
|
||||
#print >> stderr, fl[6]
|
||||
# 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):
|
||||
self.more_to_draw = True
|
||||
|
@ -469,7 +469,7 @@ class TorrentDetail(BaseMode, component.Component):
|
|||
self.add_string(off, s)
|
||||
off += 1
|
||||
|
||||
#Pieces and availability
|
||||
# Pieces and availability
|
||||
s = "{!info!}Pieces: {!yellow!}%s {!input!}x {!yellow!}%s" % (
|
||||
status["num_pieces"], fsize(status["piece_length"]))
|
||||
if status["distributed_copies"]:
|
||||
|
|
|
@ -137,7 +137,7 @@ class AddTorrentDialog(component.Component):
|
|||
"move_completed_path",
|
||||
"move_completed_paths_list",
|
||||
]
|
||||
#self.core_keys += self.move_completed_path_chooser.get_config_keys()
|
||||
# self.core_keys += self.move_completed_path_chooser.get_config_keys()
|
||||
self.builder.get_object("notebook1").connect("switch-page", self._on_switch_page)
|
||||
|
||||
def start(self):
|
||||
|
|
|
@ -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()
|
||||
|
@ -839,7 +838,7 @@ class FilesTab(Tab):
|
|||
client.core.rename_folder(self.torrent_id, pp + model[selected[0]][0],
|
||||
parent_path + model[selected[0]][0])
|
||||
else:
|
||||
#[(index, filepath), ...]
|
||||
# [(index, filepath), ...]
|
||||
to_rename = []
|
||||
for s in selected:
|
||||
to_rename.append((model[s][5], parent_path + model[s][0]))
|
||||
|
|
|
@ -61,7 +61,7 @@ class FilterTreeView(component.Component):
|
|||
self.sidebar.notebook.connect("hide", self._on_hide)
|
||||
|
||||
# Create the treestore
|
||||
#cat, value, label, count, pixmap, visible
|
||||
# cat, value, label, count, pixmap, visible
|
||||
self.treestore = gtk.TreeStore(str, str, str, int, gtk.gdk.Pixbuf, bool)
|
||||
|
||||
# Create the column and cells
|
||||
|
@ -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")
|
||||
|
|
|
@ -30,7 +30,7 @@ def singleton(cls):
|
|||
class PathChoosersHandler(component.Component):
|
||||
|
||||
def __init__(self, paths_config_key=None):
|
||||
#self.chooser_name = "PathChooser_%d" % (len(PathChooser.path_choosers) +1)
|
||||
# self.chooser_name = "PathChooser_%d" % (len(PathChooser.path_choosers) +1)
|
||||
component.Component.__init__(self, "PathChoosersHandler")
|
||||
self.path_choosers = []
|
||||
self.paths_list_keys = []
|
||||
|
@ -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"] = \
|
||||
|
@ -1025,8 +1025,8 @@ class Preferences(component.Component):
|
|||
# 0:"None"
|
||||
if proxy_type == 0:
|
||||
hides.extend(["entry_proxy_pass", "entry_proxy_user", "entry_proxy_host", "spin_proxy_port",
|
||||
"label_proxy_pass", "label_proxy_user", "label_proxy_host", "label_proxy_port",
|
||||
"chk_proxy_host_resolve", "chk_proxy_peer_conn"])
|
||||
"label_proxy_pass", "label_proxy_user", "label_proxy_host", "label_proxy_port",
|
||||
"chk_proxy_host_resolve", "chk_proxy_peer_conn"])
|
||||
# 1:"Socks4", 2:"Socks5", 4:"HTTP"
|
||||
elif proxy_type in (1, 2, 4):
|
||||
if proxy_type in (2, 4):
|
||||
|
|
|
@ -30,7 +30,7 @@ class SideBar(component.Component):
|
|||
self.notebook = builder.get_object("sidebar_notebook")
|
||||
self.hpaned = builder.get_object("main_window_hpaned")
|
||||
self.config = ConfigManager("gtkui.conf")
|
||||
#self.hpaned_position = self.hpaned.get_position()
|
||||
# self.hpaned_position = self.hpaned.get_position()
|
||||
|
||||
# Tabs holds references to the Tab widgets by their name
|
||||
self.tabs = {}
|
||||
|
|
|
@ -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)
|
||||
|
@ -536,7 +536,7 @@ class TorrentView(ListView, component.Component):
|
|||
def mark_dirty(self, torrent_id=None):
|
||||
for row in self.liststore:
|
||||
if not torrent_id or row[self.columns["torrent_id"].column_indices[0]] == torrent_id:
|
||||
#log.debug("marking %s dirty", torrent_id)
|
||||
# log.debug("marking %s dirty", torrent_id)
|
||||
row[self.columns["dirty"].column_indices[0]] = True
|
||||
if torrent_id:
|
||||
break
|
||||
|
@ -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")
|
||||
|
|
|
@ -212,7 +212,7 @@ class SessionProxy(component.Component):
|
|||
break
|
||||
|
||||
return to_fetch
|
||||
#-----------------------------------------------------------------------
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
if not filter_dict:
|
||||
# This means we want all the torrents status
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
@ -93,31 +98,31 @@ release = version
|
|||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of documents that shouldn't be included in the build.
|
||||
#unused_docs = []
|
||||
# unused_docs = []
|
||||
|
||||
# List of directories, relative to source directories, that shouldn't be searched
|
||||
# for source files.
|
||||
#exclude_dirs = []
|
||||
# exclude_dirs = []
|
||||
exclude_pattern = ['deluge/_libtorrent.py', 'deluge/__rpcapi.py']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
@ -133,19 +138,19 @@ html_style = 'default.css'
|
|||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (within the static path) to place at the top of
|
||||
# the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
|
@ -158,34 +163,34 @@ html_last_updated_fmt = '%b %d, %Y'
|
|||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_use_modindex = True
|
||||
# html_use_modindex = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, the reST sources are included in the HTML build as _sources/<name>.
|
||||
#html_copy_source = True
|
||||
# html_copy_source = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = ''
|
||||
# html_file_suffix = ''
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'delugedoc'
|
||||
|
@ -195,10 +200,10 @@ htmlhelp_basename = 'delugedoc'
|
|||
# ------------------------
|
||||
|
||||
# The paper size ('letter' or 'a4').
|
||||
#latex_paper_size = 'letter'
|
||||
# latex_paper_size = 'letter'
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#latex_font_size = '10pt'
|
||||
# latex_font_size = '10pt'
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, document class [howto/manual]).
|
||||
|
@ -209,17 +214,17 @@ latex_documents = [
|
|||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
# latex_use_parts = False
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#latex_preamble = ''
|
||||
# latex_preamble = ''
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_use_modindex = True
|
||||
# latex_use_modindex = True
|
||||
|
|
4
setup.py
4
setup.py
|
@ -189,11 +189,11 @@ class BuildDocs(BuildDoc):
|
|||
try:
|
||||
return old_import(name, globals, locals, fromlist, level)
|
||||
except ImportError as ex:
|
||||
#sys.stdout.write("ImportError: %s\n" % ex)
|
||||
# sys.stdout.write("ImportError: %s\n" % ex)
|
||||
return Mock()
|
||||
|
||||
except Exception as ex:
|
||||
#sys.stdout.write("Skipping Exception: %s\n" % ex)
|
||||
# sys.stdout.write("Skipping Exception: %s\n" % ex)
|
||||
return Mock()
|
||||
__builtins__.__import__ = new_import
|
||||
|
||||
|
|
133
win32/icon.py
133
win32/icon.py
|
@ -28,114 +28,127 @@ import types
|
|||
try:
|
||||
StringTypes = types.StringTypes
|
||||
except AttributeError:
|
||||
StringTypes = [ type("") ]
|
||||
StringTypes = [type("")]
|
||||
|
||||
|
||||
class Structure:
|
||||
def __init__ (self):
|
||||
size = self._sizeInBytes = struct.calcsize (self._format_)
|
||||
self._fields_ = list (struct.unpack (self._format_, '\000' * size))
|
||||
def __init__(self):
|
||||
size = self._sizeInBytes = struct.calcsize(self._format_)
|
||||
self._fields_ = list(struct.unpack(self._format_, '\000' * size))
|
||||
indexes = self._indexes_ = {}
|
||||
for i in range (len (self._names_)):
|
||||
for i in range(len(self._names_)):
|
||||
indexes[self._names_[i]] = i
|
||||
def dump (self):
|
||||
#print "I: DUMP of", self
|
||||
|
||||
def dump(self):
|
||||
# print "I: DUMP of", self
|
||||
for name in self._names_:
|
||||
if name[0] != '_':
|
||||
#print "I: %20s = %s" % (name, getattr (self, name))
|
||||
# print "I: %20s = %s" % (name, getattr(self, name))
|
||||
pass
|
||||
def __getattr__ (self, name):
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name in self._names_:
|
||||
index = self._indexes_[name]
|
||||
return self._fields_[index]
|
||||
try:
|
||||
return self.__dict__[name]
|
||||
except KeyError:
|
||||
raise AttributeError, name
|
||||
def __setattr__ (self, name, value):
|
||||
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):
|
||||
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):
|
||||
|
||||
class ICONDIRENTRY(Structure):
|
||||
_names_ = "bWidth", "bHeight", "bColorCount", "bReserved", "wPlanes", "wBitCount", "dwBytesInRes", "dwImageOffset"
|
||||
_format_ = "bbbbhhii"
|
||||
|
||||
class GRPICONDIR (Structure):
|
||||
|
||||
class GRPICONDIR(Structure):
|
||||
_names_ = "idReserved", "idType", "idCount"
|
||||
_format_ = "hhh"
|
||||
|
||||
class GRPICONDIRENTRY (Structure):
|
||||
|
||||
class GRPICONDIRENTRY(Structure):
|
||||
_names_ = "bWidth", "bHeight", "bColorCount", "bReserved", "wPlanes", "wBitCount", "dwBytesInRes", "nID"
|
||||
_format_ = "bbbbhhih"
|
||||
|
||||
|
||||
class IconFile:
|
||||
def __init__ (self, path):
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
file = open (path, "rb")
|
||||
file = open(path, "rb")
|
||||
self.entries = []
|
||||
self.images = []
|
||||
header = self.header = ICONDIRHEADER()
|
||||
header.fromfile (file)
|
||||
for i in range (header.idCount):
|
||||
header.fromfile(file)
|
||||
for i in range(header.idCount):
|
||||
entry = ICONDIRENTRY()
|
||||
entry.fromfile (file)
|
||||
self.entries.append (entry)
|
||||
entry.fromfile(file)
|
||||
self.entries.append(entry)
|
||||
for e in self.entries:
|
||||
file.seek (e.dwImageOffset, 0)
|
||||
self.images.append (file.read (e.dwBytesInRes))
|
||||
file.seek(e.dwImageOffset, 0)
|
||||
self.images.append(file.read(e.dwBytesInRes))
|
||||
|
||||
def grp_icon_dir (self):
|
||||
def grp_icon_dir(self):
|
||||
return self.header.tostring()
|
||||
|
||||
def grp_icondir_entries (self, id=1):
|
||||
def grp_icondir_entries(self, id=1):
|
||||
data = ""
|
||||
for entry in self.entries:
|
||||
e = GRPICONDIRENTRY()
|
||||
for n in e._names_[:-1]:
|
||||
setattr(e, n, getattr (entry, n))
|
||||
setattr(e, n, getattr(entry, n))
|
||||
e.nID = id
|
||||
id = id + 1
|
||||
data = data + e.tostring()
|
||||
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
|
||||
|
||||
hdst = win32api.BeginUpdateResource (dstpath, 0)
|
||||
hdst = win32api.BeginUpdateResource(dstpath, 0)
|
||||
|
||||
iconid = 1
|
||||
for i in range(len(icons)):
|
||||
f = icons[i]
|
||||
data = f.grp_icon_dir()
|
||||
data = data + f.grp_icondir_entries(iconid)
|
||||
win32api.UpdateResource (hdst, RT_GROUP_ICON, i, data)
|
||||
#print "I: Writing RT_GROUP_ICON %d resource with %d bytes" % (i, len(data))
|
||||
win32api.UpdateResource(hdst, RT_GROUP_ICON, i, data)
|
||||
# print "I: Writing RT_GROUP_ICON %d resource with %d bytes" % (i, len(data))
|
||||
for data in f.images:
|
||||
win32api.UpdateResource (hdst, RT_ICON, iconid, data)
|
||||
#print "I: Writing RT_ICON %d resource with %d bytes" % (iconid, len (data))
|
||||
win32api.UpdateResource(hdst, RT_ICON, iconid, data)
|
||||
# print "I: Writing RT_ICON %d resource with %d bytes" % (iconid, len(data))
|
||||
iconid = iconid + 1
|
||||
|
||||
win32api.EndUpdateResource (hdst, 0)
|
||||
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 ]
|
||||
srcpath = [srcpath]
|
||||
|
||||
def splitter(s):
|
||||
try:
|
||||
|
@ -145,7 +158,7 @@ def CopyIcons (dstpath, srcpath):
|
|||
return s, None
|
||||
|
||||
srcpath = map(splitter, srcpath)
|
||||
#print "I: SRCPATH", srcpath
|
||||
# print "I: SRCPATH", srcpath
|
||||
|
||||
if len(srcpath) > 1:
|
||||
# At the moment, we support multiple icons only from .ico files
|
||||
|
@ -153,36 +166,36 @@ 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)
|
||||
|
||||
srcpath,index = srcpath[0]
|
||||
srcpath, index = srcpath[0]
|
||||
srcext = os.path.splitext(srcpath)[1]
|
||||
if string.lower (srcext) == '.ico':
|
||||
return CopyIcons_FromIco (dstpath, [srcpath])
|
||||
if string.lower(srcext) == '.ico':
|
||||
return CopyIcons_FromIco(dstpath, [srcpath])
|
||||
if index is not None:
|
||||
print "I: Updating icons from", srcpath, ", %d to" % index, dstpath
|
||||
else:
|
||||
print "I: Updating icons from", srcpath, "to", dstpath
|
||||
import win32api #, win32con
|
||||
hdst = win32api.BeginUpdateResource (dstpath, 0)
|
||||
hsrc = win32api.LoadLibraryEx (srcpath, 0, LOAD_LIBRARY_AS_DATAFILE)
|
||||
import win32api
|
||||
hdst = win32api.BeginUpdateResource(dstpath, 0)
|
||||
hsrc = win32api.LoadLibraryEx(srcpath, 0, LOAD_LIBRARY_AS_DATAFILE)
|
||||
if index is None:
|
||||
grpname = win32api.EnumResourceNames (hsrc, RT_GROUP_ICON)[0]
|
||||
grpname = win32api.EnumResourceNames(hsrc, RT_GROUP_ICON)[0]
|
||||
elif index >= 0:
|
||||
grpname = win32api.EnumResourceNames (hsrc, RT_GROUP_ICON)[index]
|
||||
grpname = win32api.EnumResourceNames(hsrc, RT_GROUP_ICON)[index]
|
||||
else:
|
||||
grpname = -index
|
||||
data = win32api.LoadResource (hsrc, RT_GROUP_ICON, grpname)
|
||||
win32api.UpdateResource (hdst, RT_GROUP_ICON, grpname, data)
|
||||
for iconname in win32api.EnumResourceNames (hsrc, RT_ICON):
|
||||
data = win32api.LoadResource (hsrc, RT_ICON, iconname)
|
||||
win32api.UpdateResource (hdst, RT_ICON, iconname, data)
|
||||
win32api.FreeLibrary (hsrc)
|
||||
win32api.EndUpdateResource (hdst, 0)
|
||||
data = win32api.LoadResource(hsrc, RT_GROUP_ICON, grpname)
|
||||
win32api.UpdateResource(hdst, RT_GROUP_ICON, grpname, data)
|
||||
for iconname in win32api.EnumResourceNames(hsrc, RT_ICON):
|
||||
data = win32api.LoadResource(hsrc, RT_ICON, iconname)
|
||||
win32api.UpdateResource(hdst, RT_ICON, iconname, data)
|
||||
win32api.FreeLibrary(hsrc)
|
||||
win32api.EndUpdateResource(hdst, 0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
|
Loading…
Add table
Reference in a new issue