Return a proper contextual OptionParser
194983
def parser_factory(fake_args=None):
    """"""
    parser = ArgumentParser(description='aomi')
    subparsers = parser.add_subparsers(dest='operation',
                                       help='Specify the data '
                                       ' or extraction operation')
    extract_file_args(subparsers)
    environment_args(subparsers)
    aws_env_args(subparsers)
    seed_args(subparsers)
    render_args(subparsers)
    diff_args(subparsers)
    freeze_args(subparsers)
    thaw_args(subparsers)
    template_args(subparsers)
    password_args(subparsers)
    token_args(subparsers)
    help_args(subparsers)
    export_args(subparsers)

    if fake_args is None:
        return parser, parser.parse_args()

    return parser, parser.parse_args(fake_args)
1248290
def _parse_options(opts, delim):
    """"""
    options = {}
    for opt in opts.split(delim):
        key, val = opt.split("=")
        if key.lower() == 'readpreferencetags':
            options.setdefault('readpreferencetags', []).append(val)
        else:
            # str(option) to ensure that a unicode URI results in plain 'str'
            # option names. 'normalized' is then suitable to be passed as
            # kwargs in all Python versions.
            if str(key) in options:
                warnings.warn("Duplicate URI option %s" % (str(key),))
            options[str(key)] = unquote_plus(val)

    # Special case for deprecated options
    if "wtimeout" in options:
        if "wtimeoutMS" in options:
            options.pop("wtimeout")
        warnings.warn("Option wtimeout is deprecated, use 'wtimeoutMS'"
                      " instead")

    return options
78626
def parse_options(settings):
    ''''''
    optlist, args = getopt(sys.argv, 'x', [])
    settings['configfile'] = args[1]
    return settings
901504
function parseOptions(options) {
        options = _.defaults(options || {}, defaults);

        if (options.limit !== 'all') {
            options.limit = parseInt(options.limit, 10) || defaults.limit;
        }

        options.page = parseInt(options.page, 10) || defaults.page;

        return options;
    }
816241
def get_parser(self, prog_name, subcommand):
        
        parser = OptionParser(
            prog=prog_name,
            usage=self.usage(subcommand),
            version=self.get_version(),
            option_list=sorted(self.get_option_list()))
        return parser
1284878
def parse_options(self, kwargs):
        """"""
        kwargs = {camelize(key): value for key, value in kwargs.items()}
        for key in kwargs.keys():
            assert key in self.valid_options, (
                'The option {} is not in the available options: {}.'
                .format(key, ', '.join(self.valid_options))
            )
            assert isinstance(kwargs[key], self.valid_options[key]), (
                'The option {} must be one of the following types: {}.'
                .format(key, self.valid_options[key])
            )
        return kwargs
555147
def create_parser(self):
        
        return OptionParser(prog=self.prog_name,
                            usage=self.usage(),
                            version='%%prog %s' % self.get_version(),
                            option_list=self.option_list)
459322
def parse_options(self, options):
        
        for name in self.get_option_names():
            parse = getattr(self, "parse_option_{name:s}".format(
                name=name), None)
            if parse is not None and isinstance(parse, collections.Callable):
                options[name] = parse()
        return options
790621
def parse_shorts(tokens, options):
    """"""
    token = tokens.move()
    assert token.startswith('-') and not token.startswith('--')
    left = token.lstrip('-')
    parsed = []
    while left != '':
        short, left = '-' + left[0], left[1:]
        similar = [o for o in options if o.short == short]
        if len(similar) > 1:
            raise tokens.error('%s is specified ambiguously %d times' %
                               (short, len(similar)))
        elif len(similar) < 1:
            o = Option(short, None, 0)
            options.append(o)
            if tokens.error is DocoptExit:
                o = Option(short, None, 0, True)
        else:  # why copying is necessary here?
            o = Option(short, similar[0].long,
                       similar[0].argcount, similar[0].value)
            value = None
            if o.argcount != 0:
                if left == '':
                    if tokens.current() in [None, '--']:
                        raise tokens.error('%s requires argument' % short)
                    value = tokens.move()
                else:
                    value = left
                    left = ''
            if tokens.error is DocoptExit:
                o.value = value if value is not None else True
        parsed.append(o)
    return parsed
1224251
def parseBasicOptions(parser):
    
    (options, args) = parser.parse_args()

    setLoggingFromOptions(options)

    #Set up the temp dir root
    if options.tempDirRoot == "None":
        options.tempDirRoot = os.getcwd()

    return options, args
693155
function normalizeOptions(options = undefined) {
  switch (true) {
    case isPlainObject(options):
      return {
        ...defaults, ...options
      }

    case options && typeof options === "string":
      return {
        ...defaults, encoding: options
      }

    default:
      return defaults
  }
}
1186396
function parseOptions(options) {
    return {
        boolean: "boolean" in options ? options.boolean : true,
        number: "number" in options ? options.number : true,
        string: "string" in options ? options.string : true,
        allow: options.allow || []
    };
}
98710
function (parserOptions) {
            var me = this;
            if (parserOptions) {
                _gpfArrayForEach([
                    "header",
                    "separator",
                    "quote",
                    "newLine"
                ], function (optionName) {
                    if (parserOptions[optionName]) {
                        me["_" + optionName] = parserOptions[optionName];
                    }
                });
            }
        }
1256165
def _parse_multi_options(options, split_token=','):
    
    """
    if options:
        return [o.strip() for o in options.split(split_token) if o.strip()]
    else:
        return options
63274
def parse_options(cls, options):
        """"""
        if (not options.putty_select and not options.putty_ignore and
                not options.putty_auto_ignore):
            return

        options._orig_select = options.select
        options._orig_ignore = options.ignore

        options.putty_select = Parser(options.putty_select)._rules
        options.putty_ignore = Parser(options.putty_ignore)._rules

        if options.putty_auto_ignore:
            options.putty_ignore.append(AutoLineDisableRule())

        options.ignore_code = functools.partial(
            putty_ignore_code,
            options,
        )

        options.report._ignore_code = options.ignore_code
493229
def parseBasicOptions(parser):
    
    options = parser.parse_args()

    setLoggingFromOptions(options)

    #Set up the temp dir root
    if options.tempDirRoot == "None": # FIXME: Really, a string containing the word None?
        options.tempDirRoot = tempfile.gettempdir()

    return options
1055078
def option_parser():
    
    defaults = dict(template_paths=[], contexts=[], schema=None, output='-',
                    engine=None, list_engines=False, verbose=1)

    psr = argparse.ArgumentParser()
    psr.set_defaults(**defaults)

    psr.add_argument("template", type=str, nargs="?",
                     help="Template file path")
    psr.add_argument("-T", "--template-path", action="append",
                     dest="template_paths",
                     help="Template search path can be specified multiple "
                          "times. Note: Dir in which given template exists is "
                          "always included in the search paths (at the end of "
                          "the path list) regardless of this option. ")
    psr.add_argument("-C", "--context", action="append", dest="contexts",
                     help="Specify file path and optionally its filetype, to "
                          "provides context data to instantiate templates. "
                          " The option argument's format is "
                          " [type:]<file_name_or_path_or_glob_pattern>"
                          " ex. -C json:common.json -C ./specific.yaml -C "
                          "yaml:test.dat, -C yaml:/etc/foo.d/*.conf")
    psr.add_argument("-s", "--schema",
                     help="JSON schema file in any formats anyconfig "
                          "supports, to validate context files")
    psr.add_argument("-E", "--engine",
                     help="Specify template engine name such as 'jinja2'")
    psr.add_argument("-L", "--list-engines", action="store_true",
                     help="List supported template engines in your "
                          "environment")
    psr.add_argument("-o", "--output", help="Output filename [stdout]")
    psr.add_argument("-v", "--verbose", action="store_const", const=0,
                     help="Verbose mode")
    psr.add_argument("-q", "--quiet", action="store_const", const=2,
                     dest="verbose", help="Quiet mode")
    return psr