PEP8-ify most of plugins/trezor

This commit is contained in:
Neil Booth 2015-12-27 15:10:53 +09:00
parent c02daa56b0
commit 7372e0e082
4 changed files with 18 additions and 10 deletions

View File

@ -2,6 +2,7 @@ from sys import stderr
from electrum.i18n import _ from electrum.i18n import _
class GuiMixin(object): class GuiMixin(object):
# Requires: self.proto, self.device # Requires: self.proto, self.device
@ -53,6 +54,7 @@ class GuiMixin(object):
word = raw_input() word = raw_input()
return self.proto.WordAck(word=word) return self.proto.WordAck(word=word)
def trezor_client_class(protocol_mixin, base_client, proto): def trezor_client_class(protocol_mixin, base_client, proto):
'''Returns a class dynamically.''' '''Returns a class dynamically.'''

View File

@ -6,6 +6,7 @@ from electrum.i18n import _
from electrum.plugins import BasePlugin, hook from electrum.plugins import BasePlugin, hook
from electrum.transaction import deserialize, is_extended_pubkey from electrum.transaction import deserialize, is_extended_pubkey
class TrezorCompatiblePlugin(BasePlugin): class TrezorCompatiblePlugin(BasePlugin):
# Derived classes provide: # Derived classes provide:
# #

View File

@ -1,6 +1,7 @@
from plugins.trezor.qt_generic import QtPlugin from plugins.trezor.qt_generic import QtPlugin
from trezorlib.qt.pinmatrix import PinMatrixWidget from trezorlib.qt.pinmatrix import PinMatrixWidget
class Plugin(QtPlugin): class Plugin(QtPlugin):
pin_matrix_widget_class = PinMatrixWidget pin_matrix_widget_class = PinMatrixWidget
icon_file = ":icons/trezor.png" icon_file = ":icons/trezor.png"

View File

@ -13,6 +13,7 @@ from electrum_gui.qt.util import *
from electrum.i18n import _ from electrum.i18n import _
from electrum.plugins import hook from electrum.plugins import hook
class QtHandler: class QtHandler:
'''An interface between the GUI (here, QT) and the device handling '''An interface between the GUI (here, QT) and the device handling
logic for handling I/O. This is a generic implementation of the logic for handling I/O. This is a generic implementation of the
@ -150,8 +151,8 @@ class QtPlugin(TrezorPlugin):
@hook @hook
def receive_menu(self, menu, addrs): def receive_menu(self, menu, addrs):
if (not self.wallet.is_watching_only() and self.atleast_version(1, 3) if (not self.wallet.is_watching_only() and
and len(addrs) == 1): self.atleast_version(1, 3) and len(addrs) == 1):
menu.addAction(_("Show on %s") % self.device, menu.addAction(_("Show on %s") % self.device,
lambda: self.show_address(addrs[0])) lambda: self.show_address(addrs[0]))
@ -175,8 +176,11 @@ class QtPlugin(TrezorPlugin):
except BaseException as e: except BaseException as e:
window.show_error(str(e)) window.show_error(str(e))
return return
get_label = lambda: self.get_client().features.label
update_label = lambda: current_label.setText("Label: %s" % get_label()) def update_label():
label = self.get_client().features.label
current_label.setText("Label: %s" % label)
d = WindowModalDialog(window, _("%s Settings") % self.device) d = WindowModalDialog(window, _("%s Settings") % self.device)
layout = QGridLayout(d) layout = QGridLayout(d)
layout.addWidget(QLabel(_("%s Options") % self.device), 0, 0) layout.addWidget(QLabel(_("%s Options") % self.device), 0, 0)