Parse configuration arguments
197205
def parse_config_args(args)
      result = {}
      args.scan(/--?([a-z\-\_]+)\s([\d]+)\s?/).each do |arg|
        result[arg.first] = arg.last
      end
      {'raw' => args, 'parsed' => result}
    end
239652
def parse_known_args(self, args=None, namespace=None):
        """"""
        # load the config_manager within the scope of the method that uses it
        # so that we avoid circular references in the outer scope
        from configman.config_manager import ConfigurationManager
        configuration_manager = ConfigurationManager(
            definition_source=[self.get_required_config()],
            values_source_list=self.value_source_list,
            argv_source=args,
            app_name=self.prog,
            app_version=self.version,
            app_description=self.description,
            use_auto_help=False,
        )
        conf = configuration_manager.get_config(
            mapping_class=create_key_translating_dot_dict(
                "HyphenUnderscoreDict",
                (('-', '_'),)
            )
        )
        return conf
853655
function parseListConfig(string) {
		var items = {};

		// Collapse whitespace around ,
		string = string.replace(/\s*,\s*/g, ",");

		string.split(/,+/).forEach(function(name) {
			name = name.trim();
			if (!name) {
				return;
			}
			items[name] = true;
		});
		return items;
	}
1076400
def parse_args(arguments, apply_config=False):
    """"""
    parser = create_parser()
    args = parser.parse_args(arguments)

    if not args.files and not args.list_fixes:
        parser.error('incorrect number of arguments')

    args.files = [decode_filename(name) for name in args.files]

    if apply_config:
        parser = read_config(args, parser)
        args = parser.parse_args(arguments)
        args.files = [decode_filename(name) for name in args.files]

    if '-' in args.files:
        if len(args.files) > 1:
            parser.error('cannot mix stdin and regular files')

        if args.diff:
            parser.error('--diff cannot be used with standard input')

        if args.in_place:
            parser.error('--in-place cannot be used with standard input')

        if args.recursive:
            parser.error('--recursive cannot be used with standard input')

    if len(args.files) > 1 and not (args.in_place or args.diff):
        parser.error('autopep8 only takes one filename as argument '
                     'unless the "--in-place" or "--diff" args are '
                     'used')

    if args.recursive and not (args.in_place or args.diff):
        parser.error('--recursive must be used with --in-place or --diff')

    if args.in_place and args.diff:
        parser.error('--in-place and --diff are mutually exclusive')

    if args.max_line_length <= 0:
        parser.error('--max-line-length must be greater than 0')

    if args.select:
        args.select = _split_comma_separated(args.select)

    if args.ignore:
        args.ignore = _split_comma_separated(args.ignore)
        if not all(
                any(
                    conflicting_code.startswith(ignore_code)
                    for ignore_code in args.ignore
                )
                for conflicting_code in CONFLICTING_CODES
        ):
            args.ignore.update(CONFLICTING_CODES)
    elif not args.select:
        if args.aggressive:
            # Enable everything by default if aggressive.
            args.select = {'E', 'W1', 'W2', 'W3', 'W6'}
        else:
            args.ignore = _split_comma_separated(DEFAULT_IGNORE)

    if args.exclude:
        args.exclude = _split_comma_separated(args.exclude)
    else:
        args.exclude = {}

    if args.jobs < 1:
        # Do not import multiprocessing globally in case it is not supported
        # on the platform.
        import multiprocessing
        args.jobs = multiprocessing.cpu_count()

    if args.jobs > 1 and not args.in_place:
        parser.error('parallel jobs requires --in-place')

    if args.line_range:
        if args.line_range[0] <= 0:
            parser.error('--range must be positive numbers')
        if args.line_range[0] > args.line_range[1]:
            parser.error('First value of --range should be less than or equal '
                         'to the second')

    return args
502789
def _parse_arguments(arguments=None):
    """"""
    dir_hash = hashlib.sha1(os.getcwd().encode("utf-8")).hexdigest()

    parser = argparse.ArgumentParser(description="""Lint for Polysquare style guide""")
    parser.add_argument("--checks",
                        nargs=0,
                        action=ShowAvailableChecksAction,
                        help="""list available checks""")
    parser.add_argument("files",
                        nargs="*",
                        metavar=("FILE"),
                        help="""read FILE""",
                        type=str)
    parser.add_argument("--whitelist",
                        nargs="*",
                        help="""list of checks that should only be run""",
                        default=None)
    parser.add_argument("--blacklist",
                        nargs="*",
                        help="""list of checks that should never be run""",
                        default=None)
    parser.add_argument("--fix-what-you-can",
                        action="store_const",
                        help="""fix errors automatically""",
                        const=True)
    parser.add_argument("--spellcheck-cache",
                        help="""path to spell-checking cache file""",
                        default=None)
    parser.add_argument("--log-technical-terms-to",
                        help="""path to file to log technical terms to""",
                        default=None)
    parser.add_argument("--stamp-file-path",
                        help="""path to directory to store cached results""",
                        default=os.path.join(tempfile.gettempdir(),
                                             "jobstamps",
                                             "spellcheck_linter",
                                             dir_hash))
    parser.add_argument("--block-regexps",
                        help="""Regular expressions to exclude from all checks.""",
                        nargs="*",
                        default=None)

    return parser.parse_args(arguments)
381412
def parse_config(args=sys.argv):
    
    parser = argparse.ArgumentParser(
        description='Read in the config file')
    parser.add_argument(
        'config_file',
        help='Configuration file.',
        metavar='FILE', type=extant_file)
    return parser.parse_args(args[1:])
1066763
def scan_config_argument(ctx, param, value, config_dir=None):
    """"""
    if callable(config_dir):
        config_dir = config_dir()

    if not config:
        click.echo("Enter at least one CONFIG")
        click.echo(ctx.get_help(), color=ctx.color)
        ctx.exit()

    if isinstance(value, string_types):
        value = scan_config(value, config_dir=config_dir)

    elif isinstance(value, tuple):
        value = tuple([scan_config(v, config_dir=config_dir) for v in value])

    return value
941086
def __parse(self, configuration):
        
        for entry in (
            "properties",
            "environment",
            "paths",
            "bundles",
            "components",
        ):
            # Check if current values must be reset
            reset_key = "reset_{0}".format(entry)

            # Compute the name of the method
            call_name = "add" if not configuration.get(reset_key) else "set"
            method = getattr(self.__state, "{0}_{1}".format(call_name, entry))

            # Update configuration
            method(configuration.get(entry))
248668
def parse_config(file_name='/usr/local/etc/pkg.conf'):
    '''
    
    '''
    ret = {}
    if not os.path.isfile(file_name):
        return 'Unable to find {0} on file system'.format(file_name)

    with salt.utils.files.fopen(file_name) as ifile:
        for line in ifile:
            line = salt.utils.stringutils.to_unicode(line)
            if line.startswith('#') or line.startswith('\n'):
                pass
            else:
                key, value = line.split('\t')
                ret[key] = value
    ret['config_file'] = file_name
    return ret
1099305
def parse(self, arguments=None):
        
        arguments = self.arguments or arguments
        # FIXME: prep/normalize arguments in __init__
        # Split arguments if given as string and run the parser
        if isinstance(arguments, basestring):
            arguments = utils.split(arguments)

        # run the wrapped argparser command to gather user set arg values
        # FROM: https://docs.python.org/3/library/argparse.html
        # Sometimes a script may only parse a few of the command-line
        # arguments, passing the remaining arguments on to another script or
        # program.  In these cases, the parse_known_args() method can be
        # useful. It works much like parse_args() except that it does not
        # produce an error when extra arguments are present. Instead, it
        # returns a two item tuple containing the populated namespace and
        # the list of remaining argument strings.
        opts, _arguments = self.parser.parse_known_args(arguments)

        if not opts.config_file:
            opts.config_file = os.path.expanduser(DEFAULT_IDID_CONFIG)
        opts.config = Configuration().from_file(opts.config_file)
        # alias shortcut
        self.config = opts.config

        # if we're passing arguments in as a string we might get \n's or null
        # strings '' that we want to be sure to ignore
        _arguments = filter(
            lambda x: x if x else None, [_.strip() for _ in _arguments if _])

        # Now let the subclass parse the remaining special opts that
        # weren't consumed by default argparser
        opts = self._parse(opts, _arguments)

        return opts
604074
def parse_args(args=None):
    """"""
    # The argparse module provides a nice abstraction for argument parsing.
    # It automatically builds up the help text, too.
    parser = argparse.ArgumentParser(
            prog=__package__,
            description='Make substitutions in text files.',
        )
    parser.add_argument('-V', '--version',
                        action='version',
                        version="%%(prog)s %s" % (__version__,),
                        )

    group = parser.add_argument_group("Engine")
    group.add_argument('-e', '--engine',
                       dest='engine',
                       default='string.Template',
                       help="templating engine",
                       metavar="ENGINE",
                       )
    group.add_argument('-t', '--tolerant',
                       action='store_true',
                       dest='tolerant',
                       help="don't fail on missing names",
                       )

    group = parser.add_argument_group("Output")
    group.add_argument('-s', '--stdout',
                       action='append_const',
                       dest='outfiles',
                       const=sys.stdout,
                       help="use standard output",
                       )
    group.add_argument('-o', '--outfile',
                       action='append',
                       dest='outfiles',
                       help="output file",
                       metavar="FILE",
                       )
    group.add_argument('--vary',
                       action='store_true',
                       dest='vary',
                       help="vary output file name according to template",
                       )
    group.add_argument('-r', '--read-old',
                       action='store_true',
                       dest='read_old',
                       help="read preexisting output files and"
                            "hand the respective content to the template",
                       )
    group.add_argument('-d', '--delete-empty',
                       action='store_true',
                       dest='delete_empty',
                       help="delete file if output is empty",
                       )

    group = parser.add_argument_group("Input")
    group.add_argument('--stdin',
                       action='append_const',
                       dest='infiles',
                       const=sys.stdin,
                       help="use standard input",
                       )
    group.add_argument('-i', '--infile',
                       action='append',
                       dest='infiles',
                       help="any number of input files",
                       metavar="FILE",
                       )
    group.add_argument('-c', '--concatenate',
                       action='store_true',
                       dest='concatenate',
                       help="concatenate multiple input files into one output",
                       )

    group = parser.add_argument_group("Name-value pairs")
    group.add_argument('-a', '--arg',
                       action='append',
                       dest='args',
                       help="any number of name-value pairs",
                       metavar="NAME=VALUE",
                       )
    group.add_argument('-p', '--pyarg',
                       action='append',
                       dest='args',
                       type=_PyArg,
                       help="evaluate a python expression",
                       metavar="NAME=EXPRESSION",
                       )
    group.add_argument('-n', '--next',
                       action='append_const',
                       dest='args',
                       const='--',
                       help="begin next argument group",
                       )

    parser.add_argument(
                        dest='remainder',
                        nargs=argparse.REMAINDER,
                        help="possible input files and name-value pair groups "
                             "if not already specified through options",
                        )

    args = parser.parse_args(args)

    if args.engine == 'help':
        dump_engines()
        parser.exit(0)

    if args.engine not in engines.engines:
        parser.error("Engine '%s' is not available." % (args.engine,))

    if args.vary:
        if len(args.outfiles) != 1:
            parser.error("need exactly one output file template")
        if is_filelike(args.outfiles[0]):
            parser.error("vary requires an output file template")
    elif not args.outfiles:
        args.outfiles = [sys.stdout]

    if not args.infiles:
        if args.args:
            infiles = args.remainder
            args.remainder = []
            try:
                infiles.remove('--')
            except ValueError:
                pass
        else:
            first = 1 if args.remainder and args.remainder[0] == '--' else 0
            last = (len(args.remainder)
                    if args.vary or args.concatenate
                    else first + 1)
            for split, infile in enumerate(args.remainder[first:last], first):
                if infile == '--' or '=' in infile:
                    break
            else:
                split = last

            infiles = args.remainder[first:split]
            args.remainder = args.remainder[split:]

        args.infiles = [path if path != '-' else sys.stdin
                        for path in infiles] if infiles else [sys.stdin]

    if args.args:
        flat_args = args.args
    else:
        flat_args = args.remainder
        args.remainder = []
        if flat_args and flat_args[0] == '--':
            flat_args = flat_args[1:]

    args.args = []
    mapping = {}
    for arg in flat_args:
        if isinstance(arg, _PyArg):
            name_value = arg.split('=', 1)
            mapping[name_value[0]] = eval(name_value[1], {}, mapping)
        elif arg == '--':
            args.args.append(mapping)
            mapping = {}
        else:
            name_value = arg.split('=', 1)
            mapping[name_value[0]] = (name_value[1]
                                      if len(name_value) > 1
                                      else None)
    args.args.append(mapping)

    if args.remainder:
        parser.error("extraneous arguments left over")
    else:
        del args.remainder

    return args
910617
def parse_args():
    
    parser = argparse.ArgumentParser(
        description="Import existing secrets to YubiHSM eco system",
        add_help=True, formatter_class=argparse.ArgumentDefaultsHelpFormatter,)
    parser.add_argument('-D', '--device',
                        dest='device',
                        default=default_device,
                        required=False,
                        help='YubiHSM device',
                        )
    parser.add_argument('-O', '--output-dir', '--aead-dir',
                        dest='output_dir',
                        default=default_dir,
                        required=False,
                        help='Output directory (AEAD base dir)',
                        metavar='DIR',
                        )
    parser.add_argument('-v', '--verbose',
                        dest='verbose',
                        action='store_true', default=False,
                        help='Enable verbose operation',
                        )
    parser.add_argument('--debug',
                        dest='debug',
                        action='store_true', default=False,
                        help='Enable debug operation',
                        )
    parser.add_argument('--public-id-chars',
                        dest='public_id_chars',
                        type=int, default=default_public_id_chars,
                        required=False,
                        help='Number of chars in generated public ids',
                        metavar='NUM',
                        )
    parser.add_argument(
        '--key-handles',
        dest='key_handles',
        nargs='+',
        required=True,
        help='Key handle(s) to encrypt the imported secrets with',
        metavar='HANDLE',
     )
    parser.add_argument('--internal-db',
                        dest='internal_db',
                        action='store_true', default=False,
                        help='Store key in YubiHSM internal database',
                        )
    parser.add_argument(
        '--aes-key',
        dest='aes_key',
        required=False,
        default=None,
        help='AES key to use when generating AEADs (no YubiHSM)',
        metavar='HEXSTR',
     )
    parser.add_argument('--random-nonce',
                        dest='random_nonce',
                        action='store_true', default=False,
                        help='Let the HSM generate random nonce',
                        )

    args = parser.parse_args()
    if args.internal_db:
        if len(args.key_handles) != 1:
            sys.stderr.write("--internal-db requires exactly one key handle.\n")
            sys.exit(1)
        if args.aes_key:
            sys.stderr.write("--internal-db incompatible with --aes-key.\n")
            sys.exit(1)
    return args
1353577
def parse_arguments(self, conf):
    
    parsed_arguments_dict = {}
    arguments = self._arguments.arguments

    for arg_name in arguments:
      arg_meta = arguments[arg_name]
      """:type arg_meta ModuleArgumentItem"""
      try:
        if arg_meta.value_type is not None:
          arg = self.__convert_value_to_type(conf.get(arg_name), arg_meta.value_type)
        else:
          arg = conf.get(arg_name)
      except KeyError:
        if arg_meta.default is None:
          raise ArgumentException("Command require \"{}\" argument to be set".format(arg_name))

        # ToDo: check default value passed from user?
        arg = arg_meta.default

      parsed_arguments_dict[arg_name] = arg
    return parsed_arguments_dict
471924
function getConfigFromCommandLine(argv) {
	const options = {};
	forEach(argv, (value, key) => {
		if (key.startsWith('config:')) {
			options[key.replace(/^config:/, '')] = value;
		}
	});
	return options;
}
619277
def parse_args_and_kwargs(self, cmdline):
        '''
        
        '''
        # Parse args and kwargs
        args = []
        kwargs = {}

        if len(cmdline) > 1:
            for item in cmdline[1:]:
                if '=' in item:
                    (key, value) = item.split('=', 1)
                    kwargs[key] = value
                else:
                    args.append(item)
        return (args, kwargs)
1157654
function _parseParams(params, defaults) {
  const options = {};
  const attrs = {};

  Utils.each(params, (value, key) => {
    const coerced = Utils.coerceType(value);

    if (Utils.has(defaults.options, key)) {
      options[key] = coerced;
    } else if (Utils.has(defaults.attrs, key)) {
      attrs[key] = coerced;
    }
  });

  return [options, attrs];
}
765393
def _config_options(func):
    
    for param in SHConfig().get_params()[-1::-1]:
        func = click.option('--{}'.format(param), param,
                            help='Set new values to configuration parameter "{}"'.format(param))(func)
    return func