|
|
@ -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 = [] |
|
|
|