Put `func` with `args` and `kwargs` in `self.flow_func` for later.
7044
def coord(self, func:CoordFunc, *args, **kwargs)->'ImagePoints':
        ""
        if 'invert' in kwargs: kwargs['invert'] = True
        else: warn(f"{func.__name__} isn't implemented for {self.__class__}.")
        self.flow_func.append(partial(func, *args, **kwargs))
        return self
1361867
def register_func(self, func_name, func_kwargs):
        
        self.scan_funcs.append(func_name)
        self.scan_kwargs.append(func_kwargs)
31522
def wrap(self, function):
        
        func = inspect.getfullargspec(function)
        needed_arguments = func.args + func.kwonlyargs

        @wraps(function)
        def wrapper(*args, **kwargs):
            arguments = kwargs.copy()
            missing_arguments = needed_arguments - arguments.keys()
            for arg in missing_arguments:
                try:
                    arguments[arg] = self._get_argument(arg)
                except KeyError:
                    pass
            return function(*args, **arguments)

        return wrapper
1018679
def wrap(func, with_func):
  
  """
  func.__name__ = with_func.__name__
  func.__doc__ = with_func.__doc__
  func.__dict__.update(with_func.__dict__)

  return func
436424
def update_variables(func):
    

    @wraps(func)
    def wrapper(self, *args, **kwargs):
        result = func(self, *args, **kwargs)
        if isinstance(result, tuple):
            return self.process_register(result[0], result[1])
        else:
            return self.process_register(result)

    return wrapper
604434
def decorate_method(cls, func):
        
        func_args = [arg for arg in function_arguments(func) if arg != 'self']
        method_return_types = \
            Endpoint._parse_function_return_types_from_doc(func.__doc__)
        name = '%s.%s' % (cls.path, func.__name__)

        @wraps(func)
        def method_decorator(self, *args, **kwargs):
            for i in range(len(args)):
                kwargs[func_args[i]] = args[i]

            api_call = self.connection._pre_process_call(
                name, endpoint_params=kwargs)
            try:
                data = func(**kwargs)
            except RestException as e:
                api_call.error = e
                raise e

            except Exception as e:
                call_queue = self.connection._call_queue.get(
                    self.connection._get_thread_id(), [])
                if api_call in call_queue:
                    call_queue.remove(api_call)
                e = RestException(original_error=e,
                                  stack=traceback.format_exc())
                log.error('ApiCall Exception: %s' % e, exc_info=True)
                raise e
            return self.connection._post_process_call(
                api_call, data, method_return_types)

        method_decorator.rest_method = True
        return method_decorator
1363624
def once(func):
    """"""
    lock = threading.Lock()

    def new_func(*args, **kwargs):
        if new_func.called:
            return
        with lock:
            if new_func.called:
                return
            rv = func(*args, **kwargs)
            new_func.called = True
            return rv

    new_func = update_wrapper(new_func, func)
    new_func.called = False
    return new_func
213257
def decorate(self, func, target, *anoop, **kwnoop):
        
        if target:
            self.target = target

        def decorated(decorated_self, *args, **kwargs):
            self.handle_target(
                request=decorated_self.request,
                controller_args=args,
                controller_kwargs=kwargs
            )
            return func(decorated_self, *args, **kwargs)

        return decorated
217993
def nowarnings(func):
    
    @functools.wraps(func)
    def new_func(*args, **kwargs):
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            return func(*args, **kwargs)
    return new_func
26115
def _attach_arguments(self):
        """"""
        for arg in self.arguments:
            self.parser.add_argument(*arg[0], **arg[1])
673710
def CreateFlowArgs(self, flow_name=None):
    """"""
    if not self._flow_descriptors:
      self._flow_descriptors = {}

      result = self._context.SendRequest("ListFlowDescriptors", None)
      for item in result.items:
        self._flow_descriptors[item.name] = item

    try:
      flow_descriptor = self._flow_descriptors[flow_name]
    except KeyError:
      raise UnknownFlowName(flow_name)

    return utils.CopyProto(utils.UnpackAny(flow_descriptor.default_args))
831240
def func_args_as_dict(func, args, kwargs):
    
    if six.PY2:
        _getargspec = inspect.getargspec
    else:
        _getargspec = inspect.getfullargspec

    arg_names = list(
        OrderedDict.fromkeys(
            itertools.chain(
                _getargspec(func)[0],
                kwargs.keys()
            )
        )
    )
    return OrderedDict(
        list(six.moves.zip(arg_names, args)) +
        list(kwargs.items())
    )
359939
def add_callback(self, func):
        
        if func is None: return
        func_list = to_list(func)

        if not hasattr(self, 'callback_list'):
            self.callback_list = func_list
        else:
            self.callback_list.extend(func_list)
759568
def apply(self, func, args=(), kwds=dict()):
        """"""
        return self.apply_async(func, args, kwds).get()
202950
def self_if_parameters(func):
    
    @wraps(func)
    def wrapper(self, *args, **kwargs):
        result = func(self, *args, **kwargs)
        if args or kwargs:
            return self
        else:
            return result
    return wrapper
1231930
def call(self, func, *args, **kwargs):
        
        guessed_kwargs = self._guess_kwargs(func)
        for key, val in guessed_kwargs.items():
            kwargs.setdefault(key, val)
        try:
            return func(*args, **kwargs)
        except TypeError as exc:
            msg = (
                "tried calling function %r but failed, probably "
                "because it takes arguments that cannot be resolved"
            ) % func
            raise DiayException(msg) from exc
761298
def pre_run_hook(self, func, prefix=None):
        
        cf = self.capture(func, prefix=prefix)
        self.pre_run_hooks.append(cf)
        return cf