commit 7372e0e082e2311c6de90eaaf1c3b0a436bb12d0
parent c02daa56b0f48f8fd2e110e7d0ed6e434ff696e8
Author: Neil Booth <kyuupichan@gmail.com>
Date: Sun, 27 Dec 2015 15:10:53 +0900
PEP8-ify most of plugins/trezor
Diffstat:
4 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/plugins/trezor/client.py b/plugins/trezor/client.py
@@ -2,6 +2,7 @@ from sys import stderr
from electrum.i18n import _
+
class GuiMixin(object):
# Requires: self.proto, self.device
@@ -47,12 +48,13 @@ class GuiMixin(object):
return self.proto.PassphraseAck(passphrase=passphrase)
def callback_WordRequest(self, msg):
- #TODO
+ # TODO
stderr.write("Enter one word of mnemonic:\n")
stderr.flush()
word = raw_input()
return self.proto.WordAck(word=word)
+
def trezor_client_class(protocol_mixin, base_client, proto):
'''Returns a class dynamically.'''
diff --git a/plugins/trezor/plugin.py b/plugins/trezor/plugin.py
@@ -6,6 +6,7 @@ from electrum.i18n import _
from electrum.plugins import BasePlugin, hook
from electrum.transaction import deserialize, is_extended_pubkey
+
class TrezorCompatiblePlugin(BasePlugin):
# Derived classes provide:
#
@@ -123,7 +124,7 @@ class TrezorCompatiblePlugin(BasePlugin):
txinputtype = self.types.TxInputType()
if txin.get('is_coinbase'):
prev_hash = "\0"*32
- prev_index = 0xffffffff # signed int -1
+ prev_index = 0xffffffff # signed int -1
else:
if for_sig:
x_pubkeys = txin['x_pubkeys']
@@ -149,7 +150,7 @@ class TrezorCompatiblePlugin(BasePlugin):
)
txinputtype = self.types.TxInputType(
script_type=self.types.SPENDMULTISIG,
- multisig= multisig
+ multisig=multisig
)
# find which key is mine
for x_pubkey in x_pubkeys:
diff --git a/plugins/trezor/qt.py b/plugins/trezor/qt.py
@@ -1,6 +1,7 @@
from plugins.trezor.qt_generic import QtPlugin
from trezorlib.qt.pinmatrix import PinMatrixWidget
+
class Plugin(QtPlugin):
pin_matrix_widget_class = PinMatrixWidget
icon_file = ":icons/trezor.png"
diff --git a/plugins/trezor/qt_generic.py b/plugins/trezor/qt_generic.py
@@ -13,6 +13,7 @@ from electrum_gui.qt.util import *
from electrum.i18n import _
from electrum.plugins import hook
+
class QtHandler:
'''An interface between the GUI (here, QT) and the device handling
logic for handling I/O. This is a generic implementation of the
@@ -129,7 +130,7 @@ class QtPlugin(TrezorPlugin):
if storage.get('wallet_type') != self.wallet_class.wallet_type:
return
seed = wizard.enter_seed_dialog(_("Enter your %s seed") % self.device,
- None, func=lambda x:True)
+ None, func=lambda x: True)
if not seed:
return
wallet = self.wallet_class(storage)
@@ -150,8 +151,8 @@ class QtPlugin(TrezorPlugin):
@hook
def receive_menu(self, menu, addrs):
- if (not self.wallet.is_watching_only() and self.atleast_version(1, 3)
- and len(addrs) == 1):
+ if (not self.wallet.is_watching_only() and
+ self.atleast_version(1, 3) and len(addrs) == 1):
menu.addAction(_("Show on %s") % self.device,
lambda: self.show_address(addrs[0]))
@@ -175,8 +176,11 @@ class QtPlugin(TrezorPlugin):
except BaseException as e:
window.show_error(str(e))
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)
layout = QGridLayout(d)
layout.addWidget(QLabel(_("%s Options") % self.device), 0, 0)
@@ -200,6 +204,6 @@ class QtPlugin(TrezorPlugin):
update_label()
change_label_button = QPushButton("Modify")
change_label_button.clicked.connect(modify_label)
- layout.addWidget(current_label,3,0)
- layout.addWidget(change_label_button,3,1)
+ layout.addWidget(current_label, 3, 0)
+ layout.addWidget(change_label_button, 3, 1)
d.exec_()