def json2obj(data): data['this'] = data.pop('self', None) return nameddict('X', data.keys())(**data)
from atx import consts from atx import errors from atx import imutils from atx import logutils from atx.base import nameddict from atx.drivers import Pattern, Bounds, FindPoint warnings.simplefilter('default') __dir__ = os.path.dirname(os.path.abspath(__file__)) log = logutils.getLogger(__name__) Traceback = collections.namedtuple('Traceback', ['stack', 'exception']) HookEvent = nameddict('HookEvent', ['flag', 'args', 'kwargs', 'retval', 'traceback', 'depth', 'is_before']) def hook_wrap(event_type): def wrap(fn): @functools.wraps(fn) def _inner(*args, **kwargs): func_args = inspect.getcallargs(fn, *args, **kwargs) self = func_args.get('self') self._depth += 1 def trigger(event): for (f, event_flag) in self._listeners: if event_flag & event_type: event.args = args[1:] event.kwargs = kwargs event.flag = event_type
import traceback import tempfile import time from atx import imutils from atx.drivers import Pattern from atx import consts from atx.base import nameddict import atx.utils.texts as texts import atx.utils.adb as adb import atx.utils.images as images import atx.drivers.screen_mapping as mapping from atx.utils.images import ImageNotFoundError Traceback = collections.namedtuple('Traceback', ['stack', 'exception']) HookEvent = nameddict( 'HookEvent', ['args', 'kwargs', 'tag', 'flag', 'result', 'traceback', 'done']) ACTION_TIME = 0.3 def hook_wrap(event_type): def wrap(fn): @functools.wraps(fn) def _inner(*args, **kwargs): func_args = inspect.getcallargs(fn, *args, **kwargs) self = func_args.get('self') _tag = texts.unique(5) _traceback = None _result = None def trigger(event):