electrum

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

commit b076f5294f919fb7ae1c04e64feadcb58ce8e6db
parent 0ac2ca8ed34bf9eb78a49e1b4d4eb76140ea0a81
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun,  3 Mar 2019 17:32:00 +0100

wizard: allow kwargs in run()

Diffstat:
Melectrum/base_wizard.py | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/electrum/base_wizard.py b/electrum/base_wizard.py @@ -28,7 +28,7 @@ import sys import copy import traceback from functools import partial -from typing import List, TYPE_CHECKING, Tuple, NamedTuple, Any +from typing import List, TYPE_CHECKING, Tuple, NamedTuple, Any, Dict from . import bitcoin from . import keystore @@ -61,6 +61,7 @@ class GoBack(Exception): pass class WizardStackItem(NamedTuple): action: Any args: Any + kwargs: Dict[str, Any] storage_data: dict @@ -81,21 +82,21 @@ class BaseWizard(object): def set_icon(self, icon): pass - def run(self, *args): + def run(self, *args, **kwargs): action = args[0] args = args[1:] storage_data = copy.deepcopy(self.data) - self._stack.append(WizardStackItem(action, args, storage_data)) + self._stack.append(WizardStackItem(action, args, kwargs, storage_data)) if not action: return if type(action) is tuple: self.plugin, action = action if self.plugin and hasattr(self.plugin, action): f = getattr(self.plugin, action) - f(self, *args) + f(self, *args, **kwargs) elif hasattr(self, action): f = getattr(self, action) - f(*args) + f(*args, **kwargs) else: raise Exception("unknown action", action) @@ -113,7 +114,7 @@ class BaseWizard(object): # FIXME only self.storage is properly restored self.data = copy.deepcopy(stack_item.storage_data) # rerun 'previous' frame - self.run(stack_item.action, *stack_item.args) + self.run(stack_item.action, *stack_item.args, **stack_item.kwargs) def reset_stack(self): self._stack = []