Sets up the argument parser and returns it

    :returns: the parser
    :rtype: :class:`optparse.OptionParser`
    :raises: None
960704
def setup_parser():
    
    parser = optparse.OptionParser(
        usage="""\
usage: %prog [options] -o <output_path> <module_path> [exclude_path, ...]

Look recursively in <module_path> for Python modules and packages and create
one reST file with automodule directives per package in the <output_path>.

The <exclude_path>s can be files and/or directories that will be excluded
from generation.

Note: By default this script will not overwrite already created files.""")

    parser.add_option('-o', '--output-dir', action='store', dest='destdir',
                      help='Directory to place all output', default='')
    parser.add_option('-d', '--maxdepth', action='store', dest='maxdepth',
                      help='Maximum depth of submodules to show in the TOC '
                      '(default: 4)', type='int', default=4)
    parser.add_option('-f', '--force', action='store_true', dest='force',
                      help='Overwrite existing files')
    parser.add_option('-l', '--follow-links', action='store_true',
                      dest='followlinks', default=False,
                      help='Follow symbolic links. Powerful when combined '
                      'with collective.recipe.omelette.')
    parser.add_option('-n', '--dry-run', action='store_true', dest='dryrun',
                      help='Run the script without creating files')
    parser.add_option('-e', '--separate', action='store_true',
                      dest='separatemodules',
                      help='Put documentation for each module on its own page')
    parser.add_option('-P', '--private', action='store_true',
                      dest='includeprivate',
                      help='Include "_private" modules')
    parser.add_option('-T', '--no-toc', action='store_true', dest='notoc',
                      help='Don\'t create a table of contents file')
    parser.add_option('-E', '--no-headings', action='store_true',
                      dest='noheadings',
                      help='Don\'t create headings for the module/package '
                           'packages (e.g. when the docstrings already contain '
                           'them)')
    parser.add_option('-s', '--suffix', action='store', dest='suffix',
                      help='file suffix (default: rst)', default='rst')
    parser.add_option('-F', '--full', action='store_true', dest='full',
                      help='Generate a full project with sphinx-quickstart')
    parser.add_option('-H', '--doc-project', action='store', dest='header',
                      help='Project name (default: root module name)')
    parser.add_option('-A', '--doc-author', action='store', dest='author',
                      type='str',
                      help='Project author(s), used when --full is given')
    parser.add_option('-V', '--doc-version', action='store', dest='version',
                      help='Project version, used when --full is given')
    parser.add_option('-R', '--doc-release', action='store', dest='release',
                      help='Project release, used when --full is given, '
                      'defaults to --doc-version')
    return parser
1254299
def make_option_group(group, parser):
    # type: (Dict[str, Any], ConfigOptionParser) -> OptionGroup
    
    option_group = OptionGroup(parser, group['name'])
    for option in group['options']:
        option_group.add_option(option())
    return option_group
249166
def parse
      opts = OptionParser.new(&method(:set_options))
      opts.parse!(@args)
      return process_url if url_present?
      opts.help
    end
676428
def option_parser
      @option_parser ||= OptionParser.new do |opts|
        opts.banner = 'Usage: stove [OPTIONS]'

        opts.separator ''
        opts.separator 'Plugins:'

        opts.on('--no-git', 'Do not use the git plugin. Skips tagging if specified.') do
          options[:no_git] = true
        end

        opts.separator ''
        opts.separator 'Upload Options:'

        opts.on('--endpoint [URL]', 'Supermarket endpoint') do |v|
          options[:endpoint] = v
        end

        opts.on('--username [USERNAME]', 'Username to authenticate with') do |v|
          options[:username] = v
        end

        opts.on('--key [PATH]', 'Path to the private key on disk') do |v|
          options[:key] = v
        end

        opts.on('--[no-]extended-metadata', 'Include non-backwards compatible metadata keys such as `issues_url`') do |v|
          options[:extended_metadata] = v
        end

        opts.on('--no-ssl-verify', 'Turn off ssl verify') do
          options[:ssl_verify] = false
        end

        opts.separator ''
        opts.separator 'Git Options:'

        opts.on('--remote [REMOTE]', 'Name of the git remote') do |v|
          options[:remote] = v
        end

        opts.on('--branch [BRANCH]', 'Name of the git branch') do |v|
          options[:branch] = v
        end

        opts.on('--sign', 'Sign git tags') do
          options[:sign] = true
        end

        opts.separator ''
        opts.separator 'Artifactory Options:'

        opts.on('--artifactory [URL]', 'URL for the Artifactory repository') do |v|
          options[:artifactory] = v
        end

        opts.on('--artifactory-key [KEY]', 'Artifactory API key to use') do |v|
          options[:artifactory_key] = if v[0] == '@'
            # If passed a key looking like @foo, read it as a file. This allows
            # passing in the key securely.
            IO.read(File.expand_path(v[1..-1]))
          else
            v
          end
        end

        opts.separator ''
        opts.separator 'Global Options:'

        opts.on('--log-level [LEVEL]', 'Set the log verbosity') do |v|
          options[:log_level] = v
        end

        opts.on('--path [PATH]', 'Change the path to a cookbook') do |v|
          options[:path] = v
        end

        opts.on_tail('-h', '--help', 'Show this message') do
          puts opts
          exit
        end

        opts.on_tail('-v', '--version', 'Show version') do
          puts Stove::VERSION
          exit(0)
        end
      end
    end
1374761
def addOptions(parser, config=Config()):
    
    # Wrapper function that allows toil to be used with both the optparse and
    # argparse option parsing modules
    addLoggingOptions(parser)  # This adds the logging stuff.
    if isinstance(parser, ArgumentParser):
        def addGroup(headingString, bodyString):
            return parser.add_argument_group(headingString, bodyString).add_argument

        parser.register("type", "bool", lambda v: v.lower() == "true")  # Custom type for arg=True/False.
        _addOptions(addGroup, config)
    else:
        raise RuntimeError("Unanticipated class passed to addOptions(), %s. Expecting "
                           "argparse.ArgumentParser" % parser.__class__)
651515
def parse_options(args) # :nodoc:
      option_parser_class = self.class.const_get("#{options[:subcommand_option_handling_strategy].to_s.capitalize}CommandOptionParser")
      OptionParsingResult.new.tap { |parsing_result|
        parsing_result.arguments = args
        parsing_result = @global_option_parser.parse!(parsing_result)
        option_parser_class.new(@accepts).parse!(parsing_result, options[:argument_handling_strategy])
      }
    end
128546
def argparser(self):
        

        if self.__argparser is None:
            self.__argparser = self.argparser_factory()
            self.init_argparser(self.__argparser)
        return self.__argparser
1305631
def get_option_parser():
    
    import optparse

    prs = optparse.OptionParser(
        usage=(
            "$0 pyrpo [-h] [-v] [-q] [-s .] "
            "[-r <report>] [--thg]"))

    prs.add_option('-s', '--scan',
                   dest='scan',
                   action='append',
                   default=[],
                   help='Path(s) to scan for repositories')

    prs.add_option('-r', '--report',
                   dest='reports',
                   action='append',
                   default=[],
                   help=("""origin, status, full, gitmodule, json, sh, str, pip, hgsub"""))
    prs.add_option('--thg',
                   dest='thg_report',
                   action='store_true',
                   help='Write a thg-reporegistry.xml file to stdout')

    prs.add_option('--template',
                   dest='report_template',
                   action='store',
                   help='Report template')

    prs.add_option('-v', '--verbose',
                   dest='verbose',
                   action='store_true',)
    prs.add_option('-q', '--quiet',
                   dest='quiet',
                   action='store_true',)

    return prs
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
487068
def add_to_parser(self, parser):
        
        setts = self.settings

        def sorter(x):
            return (setts[x].section, setts[x].order)

        for k in sorted(setts, key=sorter):
            setts[k].add_argument(parser)
        return parser
1137672
def setup(parser):
    
    parser.add_argument(
        '-p', '--paramfile', type=str, required=True,
        help='Parameter Range File')
    parser.add_argument(
        '-o', '--output', type=str, required=True, help='Output File')
    parser.add_argument(
        '-s', '--seed', type=int, required=False, default=None,
        help='Random Seed')
    parser.add_argument(
        '--delimiter', type=str, required=False, default=' ',
        help='Column delimiter')
    parser.add_argument('--precision', type=int, required=False,
                        default=8, help='Output floating-point precision')

    return parser
908170
def parse(self):
        
        (options, args) = self.parser.parse_args()
        self._set_attributes(args, options)
        return self._create_dictionary()
201686
def get_parser(self, prog_name):
        """"""
        parser = argparse.ArgumentParser(description=self.get_description(),
                                         prog=prog_name, add_help=False)
        return parser
180541
def register_arguments(self, parser):
        
        parser.add_argument('x', type=int, help='the first value')
        parser.add_argument('y', type=int, help='the second value')
1241392
def init(parser = None):
    

    global p,subparsers
    if parser is None:
        p = argparse.ArgumentParser()
    else:
        p = parser

    arg = p.add_argument

    subparsers = p.add_subparsers()
234670
def create_parser(self, prog_name, subcommand):
        
        parser = OptionParser(prog=prog_name,
                              usage=self.usage(subcommand),
                              option_list=self.option_list)
        return parser
917486
def add_option(self, parser):
        

        group = parser.add_argument_group(self.name)
        for stat in self.stats:
            stat.add_option(group)

        group.add_argument(
            "--{0}".format(self.option), action="store_true", help="All above")