twizard: allow kwargs in run() - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit b076f5294f919fb7ae1c04e64feadcb58ce8e6db DIR parent 0ac2ca8ed34bf9eb78a49e1b4d4eb76140ea0a81 HTML Author: SomberNight <somber.night@protonmail.com> Date: Sun, 3 Mar 2019 17:32:00 +0100 wizard: allow kwargs in run() Diffstat: M electrum/base_wizard.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- DIR diff --git a/electrum/base_wizard.py b/electrum/base_wizard.py t@@ -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 t@@ -61,6 +61,7 @@ class GoBack(Exception): pass class WizardStackItem(NamedTuple): action: Any args: Any + kwargs: Dict[str, Any] storage_data: dict t@@ -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) t@@ -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 = []