electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 5e0179dac46a8c03f9795742171ba9bcf0407716
parent 9037f25da13873c751a1a333b43bae29296b0c13
Author: SomberNight <somber.night@protonmail.com>
Date:   Mon, 29 Oct 2018 00:20:45 +0100

qt console: expose more refs, and fix auto-complete for >2 depth

Diffstat:
Melectrum/gui/qt/console.py | 25++++++++++++++-----------
Melectrum/gui/qt/main_window.py | 19+++++++++++++------
2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/electrum/gui/qt/console.py b/electrum/gui/qt/console.py @@ -309,31 +309,34 @@ class Console(QtWidgets.QPlainTextEdit): super(Console, self).keyPressEvent(event) - - def completions(self): cmd = self.getCommand() lastword = re.split(' |\(|\)',cmd)[-1] beginning = cmd[0:-len(lastword)] path = lastword.split('.') + prefix = '.'.join(path[:-1]) + prefix = (prefix + '.') if prefix else prefix ns = self.namespace.keys() if len(path) == 1: ns = ns - prefix = '' else: + assert len(path) > 1 obj = self.namespace.get(path[0]) - prefix = path[0] + '.' - ns = dir(obj) - + try: + for attr in path[1:-1]: + obj = getattr(obj, attr) + except AttributeError: + ns = [] + else: + ns = dir(obj) completions = [] - for x in ns: - if x[0] == '_':continue - xx = prefix + x - if xx.startswith(lastword): - completions.append(xx) + for name in ns: + if name[0] == '_':continue + if name.startswith(path[-1]): + completions.append(prefix+name) completions.sort() if not completions: diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -42,6 +42,7 @@ from PyQt5.QtCore import * import PyQt5.QtCore as QtCore from PyQt5.QtWidgets import * +import electrum from electrum import (keystore, simple_config, ecc, constants, util, bitcoin, commands, coinchooser, paymentrequest) from electrum.bitcoin import COIN, is_address, TYPE_ADDRESS @@ -1950,18 +1951,24 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): console.history = self.config.get("console-history",[]) console.history_index = len(console.history) - console.updateNamespace({'wallet' : self.wallet, - 'network' : self.network, - 'plugins' : self.gui_object.plugins, - 'window': self}) - console.updateNamespace({'util' : util, 'bitcoin':bitcoin}) + console.updateNamespace({ + 'wallet': self.wallet, + 'network': self.network, + 'plugins': self.gui_object.plugins, + 'window': self, + 'config': self.config, + 'electrum': electrum, + 'daemon': self.gui_object.daemon, + 'util': util, + 'bitcoin': bitcoin, + }) c = commands.Commands(self.config, self.wallet, self.network, lambda: self.console.set_json(True)) methods = {} def mkfunc(f, method): return lambda *args: f(method, args, self.password_dialog) for m in dir(c): - if m[0]=='_' or m in ['network','wallet']: continue + if m[0]=='_' or m in ['network','wallet','config']: continue methods[m] = mkfunc(c._run, m) console.updateNamespace(methods)