Process arguments using the supplied +pos_vals+ Array of positional
 argument values, and the +kw_vals+ Hash of keyword/value.
774328
def process_args(pos_vals, kw_vals, rest_vals)
            result = {}

            # Process positional arguments
            pos_args = @definition.positional_args
            pos_args.each_with_index do |arg, i|
                break if i >= pos_vals.length
                result[arg.key] = process_arg_val(arg, pos_vals[i], result)
            end
            if pos_vals.size > pos_args.size
                if @definition.rest_args?
                    rest_vals = pos_vals[pos_args.size..-1] + rest_vals
                else
                    self.errors << "#{pos_vals.size} positional #{pos_vals.size == 1 ? 'argument' : 'arguments'} #{
                        pos_vals.size == 1 ? 'was' : 'were'} supplied, but only #{pos_args.size} #{
                        pos_args.size == 1 ? 'is' : 'are'} defined"
                end
            end

            # Process key-word based arguments
            kw_vals.each do |arg, val|
                result[arg.key] = process_arg_val(arg, val, result)
            end

            # Process rest values
            if rest_vals.size > 0
                if rest_arg = @definition.rest_args
                    result[rest_arg.key] = process_arg_val(rest_arg, rest_vals, result)
                else
                    self.errors << "#{rest_vals.size} rest #{rest_vals.size == 1 ? 'value' : 'values'} #{
                        rest_vals.size == 1 ? 'was' : 'were'} supplied, but no rest argument is defined"
                end
            end

            # Default unspecified arguments
            @definition.args.select{ |arg| !result.has_key?(arg.key) }.each do |arg|
                result[arg.key] = process_arg_val(arg, arg.default, result, true)
            end

            # Validate if any set requirements have been satisfied
            self.errors.concat(@definition.validate_requirements(result))
            if self.errors.size > 0
                @show_usage = true
            elsif result.empty?
                EmptyArgs.new
            else
                props = result.keys
                @definition.args.each{ |arg| props << arg.key unless result.has_key?(arg.key) }
                args = Struct.new(*props)
                args.new(*result.values)
            end
        end
769336
def _process_arguments(self, arguments):
        
        if not arguments:
            return None
        a = arguments.split(" :", 1)
        arglist = a[0].split()
        if len(a) == 2:
            arglist.append(a[1])
        return arglist
854575
def add_args(parser, positional=False):
    
    group = parser.add_argument_group("read loading")
    group.add_argument("reads" if positional else "--reads",
        nargs="+", default=[],
        help="Paths to bam files. Any number of paths may be specified.")

    group.add_argument(
        "--read-source-name",
        nargs="+",
        help="Names for each read source. The number of names specified "
        "must match the number of bam files. If not specified, filenames are "
        "used for names.")

    # Add filters
    group = parser.add_argument_group(
        "read filtering",
        "A number of read filters are available. See the pysam "
        "documentation (http://pysam.readthedocs.org/en/latest/api.html) "
        "for details on what these fields mean. When multiple filter "
        "options are specified, reads must match *all* filters.")

    for (name, (kind, message, function)) in READ_FILTERS.items():
        extra = {}
        if kind is bool:
            extra["action"] = "store_true"
            extra["default"] = None
        elif kind is int:
            extra["type"] = int
            extra["metavar"] = "N"
        elif kind is str:
            extra["metavar"] = "STRING"
        group.add_argument("--" + name.replace("_", "-"),
            help=message,
            **extra)
910704
def values_list(self, *fields, **kwargs):
        
        flat = kwargs.pop('flat', False)
        if kwargs:
            raise TypeError('Unexpected keyword arguments to values_list: %s'
                            % (kwargs.keys(),))
        if flat and len(fields) > 1:
            raise TypeError("'flat' is not valid when values_list is called with more than one field.")
        clone = self.only(fields)
        clone._values_list = True
        clone._flat_values_list = flat
        return clone
159641
def from_value(value = None):
        
        if isinstance(value, ProjectionParams):
            return value
        array = AnyValueArray.from_value(value) if value != None else AnyValueArray()
        return ProjectionParams(array)
255804
def fmt_dict_vals(dict_vals, shorten=True):
    
    items = dict_vals.items()
    if not items:
        return [fmt_val(None, shorten=shorten)]
    return ["%s=%s" % (k, fmt_val(v, shorten=shorten)) for k,v in items]
1355137
def process_args(args):
    """"""
    passed_args = args
    if isinstance(args, argparse.Namespace):
        passed_args = vars(passed_args)
    elif hasattr(args, "to_dict"):
        passed_args = passed_args.to_dict()

    return Box(passed_args, frozen_box=True, default_box=True)
1039861
def from_values(cls, vals):
        ""
        if util.config.future_deprecations:
            param.main.param.warning("%s.from_values is deprecated, the %s "
                                     "constructor may now be used directly.")
        return cls(items=cls._process_items(vals))
696617
def set_args(self, **kwargs):
        
        try:
            kwargs_items = kwargs.iteritems()
        except AttributeError:
            kwargs_items = kwargs.items()
        for key, val in kwargs_items:
            self.args[key] = val
1215155
def _parse_index_value(self, kwargs):
        
        if len(kwargs) == 0:
            return None, None
        elif len(kwargs) > 1:
            raise ValueError("You can't pass more than one value expression, "
                             "you passed {}".format(",".join(kwargs.keys())))

        name, value = list(kwargs.items())[0]

        if not name.startswith('value'):
            raise ValueError("The keyword arg {} is not valid for this "
                             "function".format(name))

        if name == 'value':
            return ('=', value)

        if not name.startswith('value__'):
            raise ValueError("The keyword arg {} is not valid for this "
                             "function".format(name))

        operator = name[name.find('__') + 2:]
        try:
            return (self._operator_values[operator], value)
        except KeyError:
            raise ValueError(
                "The operator {op} is not valid for index value matching. "
                "Valid operators are {valid}"
                .format(
                    op=operator,
                    valid=",".join(self._operator_values.keys()),
                ),
            )
486581
def p_kw_args_update(self, p):
        """"""
        p[0] = p[1]
        for key in p[3]:
            if key in p[1]:
                msg = "Keyword argument '%s' defined more than once." % key
                self.errors.append((msg, p.lineno(2), self.path))
        p[0].update(p[3])
269712
def process_params(self, params):
        '''
        
        '''
        for key, val in params.items():
            if key in LAUNCH_DATA_PARAMETERS and val != 'None':
                if key == 'roles':
                    if isinstance(val, list):
                        # If it's already a list, no need to parse
                        self.roles = list(val)
                    else:
                        # If it's a ',' delimited string, split
                        self.roles = val.split(',')
                else:
                    setattr(self, key, touni(val))
            elif 'custom_' in key:
                self.custom_params[key] = touni(val)
            elif 'ext_' in key:
                self.ext_params[key] = touni(val)
811144
def value_check(arg_name, pos, allowed_values):
    

    def decorator(fn):

        # brevity compromised in favour of readability
        def logic(*args, **kwargs):
            arg_count = len(args)
            if arg_count:
                if pos < arg_count:
                    if args[pos] in allowed_values:
                        return fn(*args, **kwargs)
                    else:
                        raise ValueError(
                            "'{0}' at position {1} not in allowed values {2}".format(args[pos], pos, allowed_values))
                else:
                    if arg_name in kwargs:
                        value = kwargs[arg_name]
                        if value in allowed_values:
                            return fn(*args, **kwargs)
                        else:
                            raise ValueError("'{0}' is not an allowed kwarg".format(arg_name))
                    else:
                        # partially applied functions because of incomplete args, let python handle this
                        return fn(*args, **kwargs)
            else:
                if arg_name in kwargs:
                    value = kwargs[arg_name]
                    if value in allowed_values:
                        return fn(*args, **kwargs)
                else:
                    raise ValueError("'{0}' is not an allowed kwarg".format(arg_name))

        return logic

    return decorator
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
516923
function arg($pos)
    {
        if (array_key_exists($pos, $this->parsedNamedArgs)) {
            return $this->parsedNamedArgs[$pos];
        }

        if (array_key_exists($pos, $this->parsedArgs)) {
            return $this->parsedArgs[$pos];
        }
    }
1113599
def get_pos_kw(self, token):
        """"""
        # Low byte indicates number of positional paramters,
        # high byte number of keyword parameters
        args_pos = token.attr & 0xff
        args_kw = (token.attr >> 8) & 0xff
        return args_pos, args_kw
1332181
def parse_args(self, flags, namespace):
    """"""
    flag_value_map = self._create_flag_value_map(flags)

    mutex_map = defaultdict(list)
    for args, kwargs in self._unnormalized_option_registrations_iter():
      self._validate(args, kwargs)
      dest = self.parse_dest(*args, **kwargs)

      # Compute the values provided on the command line for this option.  Note that there may be
      # multiple values, for any combination of the following reasons:
      #   - The user used the same flag multiple times.
      #   - The user specified a boolean flag (--foo) and its inverse (--no-foo).
      #   - The option has multiple names, and the user used more than one of them.
      #
      # We also check if the option is deprecated, but we only do so if the option is explicitly
      # specified as a command-line flag, so we don't spam users with deprecated option values
      # specified in config, which isn't something they control.
      implicit_value = kwargs.get('implicit_value')
      if implicit_value is None and kwargs.get('type') == bool:
        implicit_value = True  # Allows --foo to mean --foo=true.

      flag_vals = []

      def add_flag_val(v):
        if v is None:
          if implicit_value is None:
            raise ParseError('Missing value for command line flag {} in {}'.format(
              arg, self._scope_str()))
          else:
            flag_vals.append(implicit_value)
        else:
          flag_vals.append(v)

      for arg in args:
        # If the user specified --no-foo on the cmd line, treat it as if the user specified
        # --foo, but with the inverse value.
        if kwargs.get('type') == bool:
          inverse_arg = self._inverse_arg(arg)
          if inverse_arg in flag_value_map:
            flag_value_map[arg] = [self._invert(v) for v in flag_value_map[inverse_arg]]
            implicit_value = self._invert(implicit_value)
            del flag_value_map[inverse_arg]

        if arg in flag_value_map:
          for v in flag_value_map[arg]:
            add_flag_val(v)
          del flag_value_map[arg]

      # Get the value for this option, falling back to defaults as needed.
      try:
        val = self._compute_value(dest, kwargs, flag_vals)
      except ParseError as e:
        # Reraise a new exception with context on the option being processed at the time of error.
        # Note that other exception types can be raised here that are caught by ParseError (e.g.
        # BooleanConversionError), hence we reference the original exception type as type(e).
        raise type(e)(
          'Error computing value for {} in {} (may also be from PANTS_* environment variables).'
          '\nCaused by:\n{}'.format(', '.join(args), self._scope_str(), traceback.format_exc())
        )

      # If the option is explicitly given, check deprecation and mutual exclusion.
      if val.rank > RankedValue.HARDCODED:
        self._check_deprecated(dest, kwargs)

        mutex_dest = kwargs.get('mutually_exclusive_group')
        if mutex_dest:
          mutex_map[mutex_dest].append(dest)
          dest = mutex_dest
        else:
          mutex_map[dest].append(dest)

        if len(mutex_map[dest]) > 1:
          raise self.MutuallyExclusiveOptionError(
            "Can only provide one of the mutually exclusive options {}".format(mutex_map[dest]))

      setattr(namespace, dest, val)

    # See if there are any unconsumed flags remaining.
    if flag_value_map:
      raise ParseError('Unrecognized command line flags on {}: {}'.format(
        self._scope_str(), ', '.join(flag_value_map.keys())))

    return namespace