Return an inspect.BoundArguments object for the application
        of this Struct's signature to its arguments. Add missing values
        for default fields as keyword arguments.
559059
def get_boundargs(cls, *args, **kargs):
        
        boundargs = cls._signature.bind(*args, **kargs)
        # Include default arguments.
        for param in cls._signature.parameters.values():
            if (param.name not in boundargs.arguments and
                param.default is not param.empty):
                boundargs.arguments[param.name] = param.default
        return boundargs
384442
def _required_args(fn):
  """"""
  spec = getargspec(fn)
  if not spec.defaults:
    return []

  arg_names = spec.args[-len(spec.defaults):]
  return [name for name, val in zip(arg_names, spec.defaults)
          if val is REQUIRED_ARG]
1344298
def getArguments(parser):
    ""
    args = parser.parse_args()
    
    # check mutual exlusive and reaquired arguments
    if args.lmodel and args.smodel:
        parser.error('only one of --load-model and --save-model can be supplied, as they decide on whether to apply the application or the training mode')
    if not args.lmodel and not args.smodel:
        parser.error('exactly one of --load-model or --save-model has to be supplied')
    
    # application mode
    if args.lmodel:
        if not os.path.isfile(args.lmodel):
            parser.error('the supplied model file {} does not exist'.format(args.lmodel))
        if not args.simages:
            parser.error('--save-images must be supplied when running the application mode')
    
    # training mode
    if args.smodel:
        if not args.landmarkp in ('L2', 'L3', 'L4'):
            args.landmarkp = sequenceOfIntegersGeAscendingStrict(args.landmarkp)
        if not 'auto' == args.stdspace:
            args.stdspace = sequenceOfIntegersGeAscendingStrict(args.stdspace)
        if not args.force and os.path.isfile(args.smodel):
            parser.error('the target model file {} already exists'.format(args.smodel))
        
    # others
    if args.simages:
        if not os.path.isdir(args.simages):
            parser.error('--save-images must be a valid directory')
    if args.masks and len(args.masks) != len(args.images):
        parser.error('the same number of masks must be passed to --masks as images have been supplied') 
    
    return args
807191
def check_params(**kwargs):
    

    missing_params = []
    check = True

    for param in kwargs:
        if kwargs[param] is None:
            missing_params.append(param)

    if len(missing_params) > 0:
        print("POT - Warning: following necessary parameters are missing")
        for p in missing_params:
            print("\n", p)

        check = False

    return check
1328160
def get_kwargs_defaults(argspec):
    """"""
    arg_names = tuple(argspec.args)
    defaults = argspec.defaults or ()
    num_args = len(argspec.args) - len(defaults)
    kwargs_defaults = {}
    for i, default_value in enumerate(defaults):
        kwargs_defaults[arg_names[num_args + i]] = default_value
    if getattr(argspec, "kwonlydefaults", None):
        kwargs_defaults.update(argspec.kwonlydefaults)
    return kwargs_defaults
1144701
def prepare_arguments(self, attributes):
        """"""
        kwargs = dict(attributes)
        # 1. Extension points
        kwargs = self.factory._adjust_kwargs(**kwargs)

        # 2. Remove hidden objects
        kwargs = {
            k: v for k, v in kwargs.items()
            if k not in self.exclude and k not in self.parameters and v is not declarations.SKIP
        }

        # 3. Rename fields
        for old_name, new_name in self.rename.items():
            if old_name in kwargs:
                kwargs[new_name] = kwargs.pop(old_name)

        # 4. Extract inline args
        args = tuple(
            kwargs.pop(arg_name)
            for arg_name in self.inline_args
        )

        return args, kwargs
873353
def extract_init_args(instance):
    
    cls = instance.__class__
    args = [x for x in inspect.getargspec(cls.__init__).args if x != 'self']
    return [instance.__dict__[key] for key in args]
61955
private String getArgumentDescription(
            final Map<String, NamedArgumentDefinition> allActualArguments,
            final Collection<CommandLinePluginDescriptor<?>> pluginDescriptors) {
        final StringBuilder sb = new StringBuilder();
        if (!getDocString().isEmpty()) {
            sb.append(getDocString());
            sb.append("  ");
        }
        if (isCollection()) {
            if (isOptional()) {
                sb.append("This argument may be specified 0 or more times. ");
            } else {
                sb.append("This argument must be specified at least once. ");
            }
        }
        if (isOptional()) {
            sb.append("Default value: ");
            sb.append(getDefaultValueAsString());
            sb.append(". ");
        } else {
            sb.append("Required. ");
        }

        // if this argument definition is a string field claimed by a plugin descriptor (i.e.,
        // it holds the names of plugins specified by the user on the command line, such as read filter names),
        // then we need to delegate to the plugin descriptor to generate the list of allowed values
        if (!usageForPluginDescriptorArgument(sb, pluginDescriptors)) {
            // If the argument wasn't claimed by any descriptor, treat it as a normal argument
            sb.append(getOptionsAsDisplayString());
        }

        if (!getMutexTargetList().isEmpty()) {
            sb.append(" Cannot be used in conjunction with argument(s)");
            for (final String argument : getMutexTargetList()) {
                final NamedArgumentDefinition mutexArgumentDefinition = allActualArguments.get(argument);
                sb.append(" ").append(mutexArgumentDefinition.getUnderlyingField().getName());
                if (!mutexArgumentDefinition.getShortName().isEmpty()) {
                    sb.append(" (").append(mutexArgumentDefinition.getShortName()).append(")");
                }
            }
        }
        return sb.toString();
    }
410927
def noargs(self):
        ""
        noargs = inspect.ArgSpec(args=[], varargs=None, keywords=None, defaults=None)
        return self.argspec == noargs
182471
def get_functarguments(func):
    
    argspec = inspect.getargspec(func)
    if argspec.defaults is not None:
        args = argspec.args[:-len(argspec.defaults)]
        kwargs = dict(
            zip(argspec.args[-len(argspec.defaults):], argspec.defaults))
    else:
        args = argspec.args
        kwargs = {}
    if args and args[0] == 'self':
        args.pop(0)
    func.__named__ = []
    arguments = []
    shared = get_shared(func)
    for arg in args:
        if has_shared(arg, shared) is not False:
            continue
        if has_argument(arg, func.__cls__) is not False:
            continue
        arguments.append(([arg], {}, ))
        func.__named__.append(arg)
    for key, val in kwargs.items():
        if has_shared(key, shared) is not False:
            continue
        if has_argument(key, func.__cls__) is not False:
            continue
        if isinstance(val, dict):
            flags = [val.pop('lflag', '--%s' % key)]
            short = val.pop('flag', None)
            dest = val.get('dest', key).replace('-', '_')
            if short:
                flags.insert(0, short)
        else:
            flags = ['--%s' % key]
            val = dict(default=val)
            dest = key.replace('-', '_')
        func.__named__.append(dest)
        arguments.append((flags, val, ))
    return arguments
732905
def _get_default_args(func):
    
    args, varargs, keywords, defaults = inspect.getargspec(func)
    print(args)
    return dict(zip(reversed(args), reversed(defaults)))
516929
def _GetArgsDescription(self, args_type):
    """"""
    args = {}
    if args_type:
      for type_descriptor in args_type.type_infos:
        if not type_descriptor.hidden:
          args[type_descriptor.name] = {
              "description": type_descriptor.description,
              "default": type_descriptor.default,
              "type": "",
          }
          if type_descriptor.type:
            args[type_descriptor.name]["type"] = type_descriptor.type.__name__
    return args
413441
protected void initializeArguments() {

    Map<String, BasicDoubleLinkedNode<CliArgumentContainer>> argumentMap = new HashMap<>();
    BasicDoubleLinkedNode<CliArgumentContainer> startHead = null;
    BasicDoubleLinkedNode<CliArgumentContainer> startTail = null;
    BasicDoubleLinkedNode<CliArgumentContainer> endHead = null;
    BasicDoubleLinkedNode<CliArgumentContainer> endTail = null;
    for (CliArgumentContainer argumentContainer : this.arguments) {
      String id = argumentContainer.getId();
      if ((CliArgument.ID_FIRST.equals(id)) || (CliArgument.ID_LAST.equals(id))) {
        throw new NlsIllegalArgumentException(id, argumentContainer.toString());
      }
      if (argumentMap.containsKey(id)) {
        throw new DuplicateObjectException(argumentContainer, id);
      }
      BasicDoubleLinkedNode<CliArgumentContainer> node = new BasicDoubleLinkedNode<>();
      node.setValue(argumentContainer);
      argumentMap.put(id, node);
      CliArgument cliArgument = argumentContainer.getArgument();
      boolean addAfter = cliArgument.addAfter();
      String nextTo = cliArgument.addCloseTo();
      if (CliArgument.ID_FIRST.equals(nextTo)) {
        if ((startHead == null) || (startTail == null)) {
          startHead = node;
          startTail = node;
        } else {
          if (addAfter) {
            startTail.insertAsNext(node);
            startTail = node;
          } else {
            startHead.insertAsPrevious(node);
            startHead = node;
          }
        }
        argumentContainer.init();
      } else if (CliArgument.ID_LAST.equals(nextTo)) {
        if ((endTail == null) || (endHead == null)) {
          endTail = node;
          endHead = node;
        } else {
          if (addAfter) {
            endTail.insertAsNext(node);
            endTail = node;
          } else {
            endHead.insertAsPrevious(node);
            endHead = node;
          }
        }
        argumentContainer.init();
      }
    }
    if ((startTail != null) && (endHead != null)) {
      // connect start and end of list...
      startTail.insertAsNext(endHead);
    }
    for (BasicDoubleLinkedNode<CliArgumentContainer> node : argumentMap.values()) {
      List<String> cycle = initializeArgumentRecursive(node, argumentMap);
      if (cycle != null) {
        StringBuilder sb = new StringBuilder();
        for (int i = cycle.size() - 1; i >= 0; i--) {
          sb.append(cycle.get(i));
          if (i > 0) {
            sb.append("-->");
          }
        }
        throw new IllegalStateException("Cyclic dependency of CLI modes: " + sb.toString());
      }
    }
    // order arguments
    if (startHead != null) {
      this.arguments.clear();
      startHead.addToList(this.arguments);
    } else if (endHead != null) {
      this.arguments.clear();
      BasicDoubleLinkedNode<CliArgumentContainer> node = endHead;
      BasicDoubleLinkedNode<CliArgumentContainer> previous = node.getPrevious();
      while (previous != null) {
        node = previous;
        previous = node.getPrevious();
      }
      node.addToList(this.arguments);
    }
  }
1217770
def _get_netengine_arguments(self, required=False):
        
        # inspect netengine class
        backend_class = self._get_netengine_backend()
        argspec = inspect.getargspec(backend_class.__init__)
        # store args
        args = argspec.args
        # remove known arguments
        for argument_name in ['self', 'host', 'port']:
            args.remove(argument_name)

        if required:
            # list of default values
            default_values = list(argspec.defaults)
            # always remove last default value, which is port number
            default_values = default_values[0:-1]

            # remove an amount of arguments equals to number of default values, starting from right
            args = args[0:len(args)-len(default_values)]

        return args
902372
def argument_getter_factory(route_spec):
     
    
    func_sig = inspect.signature(route_spec.handler_func)

    param_names = list(func_sig.parameters.keys())
    arg_getters  = build_argval_getters(route_spec)
    n_args = len(arg_getters)

    async def argument_getters(request):
        errors = None
        values = {}
        for i in range(n_args):
            try:
                arg_name = param_names[i]
                values[arg_name] = await arg_getters[i](request)
            except HTTPException:
                raise
            except Exception as exc :
                if errors is None: 
                    errors = []

                request.app.logger.error('', exc_info=True)

                exc_type = type(exc)

                data = {
                    "name": arg_name, 
                    "type": f"{exc_type.__module__}.{exc_type.__qualname__}",
                    "error": str(exc)
                }

                errors.append(data)

        if errors is not None:
            raise RESTfulArgumentError(errors)

        return values

    return argument_getters
1249406
def _make_args_checker(self):
        
        def _checker(*args, **kws):
            # Check if too many arguments are provided
            nargs = len(args)
            nnonvaargs = min(nargs, self._max_positional_args)
            if nargs > self._max_positional_args and self._ivararg is None:
                raise self._too_many_args_error(nargs)

            # Check if there are too few positional arguments (without defaults)
            if nargs < self._min_positional_args:
                missing = [p.name
                           for p in self.params[nargs:self._min_positional_args]
                           if p.name not in kws]
                # The "missing" arguments may still be provided as keywords, in
                # which case it's not an error at all.
                if missing:
                    raise self._too_few_args_error(missing, "positional")

            # Check if there are too few required keyword arguments
            if self._required_kwonly_args:
                missing = [kw
                           for kw in self._required_kwonly_args
                           if kw not in kws]
                if missing:
                    raise self._too_few_args_error(missing, "keyword")

            # Check types of positional arguments
            for i, argvalue in enumerate(args):
                param = self.params[i if i < self._max_positional_args else
                                    self._ivararg]
                if param.checker and not (
                    param.checker.check(argvalue) or
                    param.has_default and
                        (argvalue is param.default or argvalue == param.default)
                ):
                    raise self._param_type_error(param, param.name, argvalue)

            # Check types of keyword arguments
            for argname, argvalue in kws.items():
                argindex = self._iargs.get(argname)
                if argindex is not None and argindex < nnonvaargs:
                    raise self._repeating_arg_error(argname)
                index = self._iargs.get(argname)
                if index is None:
                    index = self._ivarkws
                if index is None:
                    s = "%s got an unexpected keyword argument `%s`" % \
                        (self.name_bt, argname)
                    raise self._type_error(s)
                param = self.params[index]
                if param.checker and not (
                    param.checker.check(argvalue) or
                    param.has_default and
                        (argvalue is param.default or argvalue == param.default)
                ):
                    raise self._param_type_error(param, argname, argvalue)

        return _checker
503472
def get_kwarg_names(func):
    
    sig = inspect.signature(func)
    kwonlyargs = [p.name for p in sig.parameters.values()
                  if p.default is not p.empty]
    return kwonlyargs