Browse Source

PEP8-ify most of plugins/trezor

283
Neil Booth 9 years ago
parent
commit
7372e0e082
  1. 4
      plugins/trezor/client.py
  2. 5
      plugins/trezor/plugin.py
  3. 1
      plugins/trezor/qt.py
  4. 18
      plugins/trezor/qt_generic.py

4
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.'''

5
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:

1
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"

18
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_()

Loading…
Cancel
Save