Browse Source

qml: simplify path_protect decorator

master
Sander van Grieken 3 years ago
parent
commit
6733665dac
  1. 9
      electrum/gui/qml/auth.py

9
electrum/gui/qml/auth.py

@ -4,11 +4,9 @@ from PyQt5.QtCore import pyqtSignal, pyqtSlot, pyqtProperty
from electrum.logging import get_logger from electrum.logging import get_logger
def auth_protect(message='', method='pin', reject=None): def auth_protect(func=None, reject=None, method='pin', message=''):
def decorator(func=None):
if func is None: if func is None:
return partial(auth_protect, reject=reject, method=method) return partial(auth_protect, reject=reject, method=method, message=message)
@wraps(func) @wraps(func)
def wrapper(self, *args, **kwargs): def wrapper(self, *args, **kwargs):
@ -17,11 +15,10 @@ def auth_protect(message='', method='pin', reject=None):
if hasattr(self, '__auth_fcall'): if hasattr(self, '__auth_fcall'):
_logger.debug('object already has a pending authed function call') _logger.debug('object already has a pending authed function call')
raise Exception('object already has a pending authed function call') raise Exception('object already has a pending authed function call')
setattr(self, '__auth_fcall', (func,args,kwargs,reject)) setattr(self, '__auth_fcall', (func, args, kwargs, reject))
getattr(self, 'authRequired').emit(method, message) getattr(self, 'authRequired').emit(method, message)
return wrapper return wrapper
return decorator
class AuthMixin: class AuthMixin:
_auth_logger = get_logger(__name__) _auth_logger = get_logger(__name__)

Loading…
Cancel
Save