Function builds kwargs variable for run_window
193531
def _build_flags(self):
        
        # Check if all entries for selected arguments are nonempty
        for arg_dict in [x for x in self.args.values() if self.arg_is_selected(x)]:
            if 'entry' in arg_dict and not arg_dict['entry'].get_text():
                self.gui_helper.execute_dialog("Entry {0} is empty".format(arg_dict['label']))
                return False

        # Check for active CheckButtons
        for arg_dict in [x for x in self.args.values() if self.arg_is_selected(x)]:
            arg_name = arg_dict['arg'].get_dest()
            if 'entry' in arg_dict:
                self.kwargs[arg_name] = arg_dict['entry'].get_text()
            else:
                if arg_dict['arg'].get_gui_hint('type') == 'const':
                    self.kwargs[arg_name] = arg_dict['arg'].kwargs['const']
                else:
                    self.kwargs[arg_name] = True

        # Check for non active CheckButtons but with defaults flag
        for arg_dict in [x for x in self.args.values() if not self.arg_is_selected(x)]:
            arg_name = arg_dict['arg'].get_dest()
            if 'default' in arg_dict['arg'].kwargs:
                self.kwargs[arg_name] = arg_dict['arg'].get_gui_hint('default')
            elif arg_name in self.kwargs:
                del self.kwargs[arg_name]

        return True
1120332
def override_args(**kwargs):
  

  override_kwargs = kwargs

  def custom_getter(getter, *args, **kwargs):
    """Custom getter with certain named arguments overridden.

    Args:
      getter: Underlying variable getter to invoke.
      *args: Arguments, compatible with those of tf.get_variable.
      **kwargs: Keyword arguments, compatible with those of tf.get_variable.

    Returns:
      The result of invoking `getter(*args, **kwargs)` except that certain
      kwargs entries may have been overridden.
    """
    kwargs.update(override_kwargs)
    return getter(*args, **kwargs)

  return custom_getter
1195139
def execute(func: types.FunctionType):
    
    spec = getfullargspec(func)
    default = spec.defaults
    arg_cursor = 0

    def get_item(name):
        nonlocal arg_cursor
        ctx = func.__globals__
        value = ctx.get(name, _undef)
        if value is _undef:
            try:
                value = default[arg_cursor]
                arg_cursor += 1
            except (TypeError, IndexError):
                raise ValueError(f"Current context has no variable `{name}`")
        return value

    return func(*(get_item(arg_name) for arg_name in spec.args))
1128164
def get_kwargs(self):
        """"""
        return {k: v for k, v in vars(self).items() if k not in self._ignored}
1014391
def build_function(name, args=None, defaults=None, doc=None):
    """"""
    args, defaults = args or [], defaults or []
    # first argument is now a list of decorators
    func = nodes.FunctionDef(name, doc)
    func.args = argsnode = nodes.Arguments()
    argsnode.args = []
    for arg in args:
        argsnode.args.append(nodes.Name())
        argsnode.args[-1].name = arg
        argsnode.args[-1].parent = argsnode
    argsnode.defaults = []
    for default in defaults:
        argsnode.defaults.append(nodes.const_factory(default))
        argsnode.defaults[-1].parent = argsnode
    argsnode.kwarg = None
    argsnode.vararg = None
    argsnode.parent = func
    if args:
        register_arguments(func)
    return func
505297
def get_kwargs(kwargs):
    
    return {
        key: value for key, value in six.iteritems(kwargs)
        if key != 'self'
    }
1280373
def generate_accepted_kwargs(function, *named_arguments):
    
    if hasattr(function, '__code__') and takes_kwargs(function):
        function_takes_kwargs = True
        function_takes_arguments = []
    else:
        function_takes_kwargs = False
        function_takes_arguments = takes_arguments(function, *named_arguments)

    def accepted_kwargs(kwargs):
        if function_takes_kwargs:
            return kwargs
        elif function_takes_arguments:
            return {key: value for key, value in kwargs.items() if key in function_takes_arguments}
        return {}
    return accepted_kwargs
241529
def execute_scriptfunction() -> None:
    
    try:
        args_given = []
        kwargs_given = {}
        for arg in sys.argv[1:]:
            if len(arg) < 3:
                args_given.append(arg)
            else:
                try:
                    key, value = parse_argument(arg)
                    kwargs_given[key] = value
                except ValueError:
                    args_given.append(arg)
        logfilepath = prepare_logfile(kwargs_given.pop('logfile', 'stdout'))
        logstyle = kwargs_given.pop('logstyle', 'plain')
        try:
            funcname = str(args_given.pop(0))
        except IndexError:
            raise ValueError(
                'The first positional argument defining the function '
                'to be called is missing.')
        try:
            func = hydpy.pub.scriptfunctions[funcname]
        except KeyError:
            available_funcs = objecttools.enumeration(
                sorted(hydpy.pub.scriptfunctions.keys()))
            raise ValueError(
                f'There is no `{funcname}` function callable by `hyd.py`.  '
                f'Choose one of the following instead: {available_funcs}.')
        args_required = inspect.getfullargspec(func).args
        nmb_args_required = len(args_required)
        nmb_args_given = len(args_given)
        if nmb_args_given != nmb_args_required:
            enum_args_given = ''
            if nmb_args_given:
                enum_args_given = (
                    f' ({objecttools.enumeration(args_given)})')
            enum_args_required = ''
            if nmb_args_required:
                enum_args_required = (
                    f' ({objecttools.enumeration(args_required)})')
            raise ValueError(
                f'Function `{funcname}` requires `{nmb_args_required:d}` '
                f'positional arguments{enum_args_required}, but '
                f'`{nmb_args_given:d}` are given{enum_args_given}.')
        with _activate_logfile(logfilepath, logstyle, 'info', 'warning'):
            func(*args_given, **kwargs_given)
    except BaseException as exc:
        if logstyle not in LogFileInterface.style2infotype2string:
            logstyle = 'plain'
        with _activate_logfile(logfilepath, logstyle, 'exception', 'exception'):
            arguments = ', '.join(sys.argv)
            print(f'Invoking hyd.py with arguments `{arguments}` '
                  f'resulted in the following error:\n{str(exc)}\n\n'
                  f'See the following stack traceback for debugging:\n',
                  file=sys.stderr)
            traceback.print_tb(sys.exc_info()[2])
237630
def process_kwargs(self, kwargs, prefix='default_', delete=True):
        
        processed = []
        for k in kwargs:
            if hasattr(self, prefix + k):
                processed += [k]
                setattr(self, prefix + k, kwargs[k])
        for k in processed:
            del(kwargs[k])
        return kwargs
1211228
def call(self):
        """"""
        assert self.satisfied, self
        LOG.debug('call %s.%s', self.func.__module__, self.func.__qualname__)
        kwargs = {arg.name: arg.read() for arg in self.args}
        out_value = self.func(**kwargs)
        if self.writeto is None:
            writeto = set()
        elif isinstance(self.writeto, Variable):
            self.writeto.write(out_value)
            writeto = {self.writeto}
        else:
            # A variable can be written multiple times, but we only
            # return a unique set of variables.
            for var, value in zip(self.writeto, out_value):
                var.write(value)
            writeto = set(self.writeto)
        self._release()  # Only call _release() on normal exit.
        return writeto
544829
def runUAT(self, args):
		
		Utility.run([self.getRunUATScript()] + args, cwd=self.getEngineRoot(), raiseOnError=True)
1122461
def add_argument(*args, **kwargs):
    

    def decorator(func):
        func = ScriptAdaptor._wrap(func)
        func._add_argument(args, kwargs)
        return func
    return decorator
178107
def _process_window(self, ji_win, func, **kwargs):
        
        arr = self.get_arrays(ji_win)
        result = func(arr, **kwargs)
        return result
122098
def apply_kwargs(func, **kwargs):
    
    new_kwargs = {}
    params = signature(func).parameters
    for param_name in params.keys():
        if param_name in kwargs:
            new_kwargs[param_name] = kwargs[param_name]
    return func(**new_kwargs)
844293
def split_kwargs_by_func(kwargs, func):
    ""
    args = func_args(func)
    func_kwargs = {a:kwargs.pop(a) for a in args if a in kwargs}
    return func_kwargs, kwargs
410108
def elog(exc, func, args=None, kwargs=None, str=str, pretty=True, name=''):
    '''
    '''
    from .str import safe_str

    args = args if args else ()
    kwargs = kwargs if kwargs else {}
    name = '{}.{}'.format(get_mod(func), name) if name else full_funcname(func)

    if pretty:
        invocation = ', '.join([safe_str(arg) for arg in args])
        if kwargs:
            invocation += ', '
            invocation += ', '.join(['{}={}'.format(key, safe_str(value))
                                     for key, value in sorted(kwargs.items())])
    else:
        invocation = 'args={}, kwargs={}'.format(safe_str(args), safe_str(kwargs))

    msg = '***{}***: "{}" --- {}({})'.format(get_typename(exc),
                                             message(exc),
                                             name,
                                             invocation)
    elogger.error(msg)
1363112
def execute(self, func, *args, **kwargs):
        
        return [
            func(item, *args, **kwargs) for item in self.to_lst()
        ]