Create a parser for the 'analyze' subcommand.
421824
def _add_parser_arguments_analyze(self, subparsers):
        
        lyze_pars = subparsers.add_parser(
            "analyze",
            help="Perform basic analysis on this catalog.")

        lyze_pars.add_argument(
            '--count', '-c', dest='count',
            default=False, action='store_true',
            help='Determine counts of entries, files, etc.')

        return lyze_pars
1090847
def get_subparser(self, name, dest="subcommand", **kwargs):
        """"""
        if name not in self.children:
            # Create the subparser.
            subparsers = self._get_subparsers(dest)
            parser = subparsers.add_parser(name, **kwargs)
            self.children[name] = NamedParser(name, parser)
        return self.children[name]
178724
def generate_counts_subparser(subparsers):
    """"""
    parser = subparsers.add_parser(
        'counts', description=constants.COUNTS_DESCRIPTION,
        epilog=constants.COUNTS_EPILOG, formatter_class=ParagraphFormatter,
        help=constants.COUNTS_HELP)
    parser.set_defaults(func=ngram_counts)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    utils.add_query_arguments(parser)
1080824
def addSubparser(subparsers, subcommand, description):
    
    parser = subparsers.add_parser(
        subcommand, description=description, help=description)
    return parser
854273
def parser(self):
        """"""
        if self._command_parser is None:
            parents = []
            if self.need_verbose:
                parents.append(_verbose_parser)
            if self.need_settings:
                parents.append(_settings_parser)

            self._command_parser = self._main_parser.add_parser(self.name,
                                                                help=self.help,
                                                                parents=parents,
                                                                formatter_class=argparse.RawDescriptionHelpFormatter)
        return self._command_parser
1337966
def run_analysis(self, argv):
        """"""
        args = self._parser.parse_args(argv)
        obs = BinnedAnalysis.BinnedObs(irfs=args.irfs,
                                       expCube=args.expcube,
                                       srcMaps=args.cmap,
                                       binnedExpMap=args.bexpmap)

        like = BinnedAnalysis.BinnedAnalysis(obs,
                                             optimizer='MINUIT',
                                             srcModel=GtSrcmapsCatalog.NULL_MODEL,
                                             wmap=None)

        source_factory = pyLike.SourceFactory(obs.observation)
        source_factory.readXml(args.srcmdl, BinnedAnalysis._funcFactory,
                               False, True, True)

        srcNames = pyLike.StringVector()
        source_factory.fetchSrcNames(srcNames)

        min_idx = args.srcmin
        max_idx = args.srcmax
        if max_idx < 0:
            max_idx = srcNames.size()

        for i in xrange(min_idx, max_idx):
            if i == min_idx:
                like.logLike.saveSourceMaps(args.outfile)
                pyLike.CountsMapBase.copyAndUpdateDssKeywords(args.cmap,
                                                              args.outfile,
                                                              None,
                                                              args.irfs)

            srcName = srcNames[i]
            source = source_factory.releaseSource(srcName)
            like.logLike.addSource(source, False)
            like.logLike.saveSourceMap_partial(args.outfile, source)
            like.logLike.deleteSource(srcName)

        if args.gzip:
            os.system("gzip -9 %s" % args.outfile)
665179
def subparsers(self):
        """"""
        try:
            return self.__subparsers
        except AttributeError:
            parent = super(ArgumentParser, self)
            self.__subparsers = parent.add_subparsers(title="drill down")
            self.__subparsers.metavar = "COMMAND"
            return self.__subparsers
264345
def make_parser():
    """"""
    p = optparse.OptionParser()
    p.add_option('--prefix', metavar='DIR', help='install SDK in DIR')
    p.add_option('--bindir', metavar='DIR', help='install tools in DIR')
    p.add_option('--force', action='store_true', default=False,
        help='over-write existing installation')
    p.add_option('--no-bindir', action='store_true', default=False,
        help='do not install tools on DIR')

    return p
1008278
def cli():
    """"""
    parser = argparse.ArgumentParser()
    parser.add_argument('api', help="""
        API to call.
        One one of 'article', 'frontpage', 'product', 'image', 'analyze', or
        'discussion'.
    """)
    parser.add_argument('url', help="""
        URL to pass as the 'url' parameter.
    """)
    parser.add_argument('token', help="""
        API key (token).
        Get one at https://www.diffbot.com/.
    """)
    parser.add_argument('-a', '--all', help="""
        Request all fields.
    """, action='store_true')
    parser.add_argument('-f', '--file', help="""
        File to read data from.
        Use '-' to read from STDIN.
    """)
    fields = text = html = None
    _args = parser.parse_args()
    if _args.all:
        fields = '*'
    if _args.file == '-':
        text = sys.stdin.read()
    elif _args.file:
        with open(_args.file, 'rb') as src:
            if os.path.splitext(_args.file)[1] in ('.html', '.htm'):
                html = src.read().decode(ENCODING)
            else:
                text = src.read().decode(ENCODING)
    print(json.dumps((api(_args.api, _args.url, _args.token,
                          html=html or None,
                          text=text or None,
                          fields=fields)),
                     sort_keys=True,
                     indent=2))
1113282
def create_parser():
    
    select = create_select()
    scan = create_scan()
    delete = create_delete()
    update = create_update()
    insert = create_insert()
    create = create_create()
    drop = create_drop()
    alter = create_alter()
    dump = create_dump()
    load = create_load()
    base = (
        select | scan | delete | update | insert | create | drop | alter | dump | load
    )
    explain = upkey("explain").setResultsName("action") + Group(
        select | scan | delete | update | insert | create | drop | alter
    )
    analyze = upkey("analyze").setResultsName("action") + Group(
        select | scan | delete | update | insert
    )
    dql = explain | analyze | base
    dql.ignore("--" + restOfLine)
    return dql
158410
def prepare_parser(program):
    """"""
    parser = ArgumentParser(
        description=PROG_DESCRIPTION, prog=program,
        formatter_class=HelpFormatter,
        add_help=False)
    parser.add_argument(
        "-h", "--help", action=MinimalHelpAction, help=argparse.SUPPRESS)

    # Register sub-commands.
    submodules = (
        "nodes", "machines", "devices", "controllers",
        "fabrics", "vlans", "subnets", "spaces",
        "files", "tags", "users",
        "profiles", "shell",
    )
    cmd_help.register(parser)
    for submodule in submodules:
        module = import_module("." + submodule, __name__)
        module.register(parser)

    # Register global options.
    parser.add_argument(
        '--debug', action='store_true', default=False,
        help=argparse.SUPPRESS)

    return parser
320258
def create_parser():
    """"""
    parser = argparse.ArgumentParser(description=docstring_summary(__doc__),
                                     prog='autopep8')
    parser.add_argument('--version', action='version',
                        version='%(prog)s {} ({})'.format(
                            __version__, _get_package_version()))
    parser.add_argument('-v', '--verbose', action='count',
                        default=0,
                        help='print verbose messages; '
                             'multiple -v result in more verbose messages')
    parser.add_argument('-d', '--diff', action='store_true',
                        help='print the diff for the fixed source')
    parser.add_argument('-i', '--in-place', action='store_true',
                        help='make changes to files in place')
    parser.add_argument('--global-config', metavar='filename',
                        default=DEFAULT_CONFIG,
                        help='path to a global pep8 config file; if this file '
                             'does not exist then this is ignored '
                             '(default: {})'.format(DEFAULT_CONFIG))
    parser.add_argument('--ignore-local-config', action='store_true',
                        help="don't look for and apply local config files; "
                             'if not passed, defaults are updated with any '
                             "config files in the project's root directory")
    parser.add_argument('-r', '--recursive', action='store_true',
                        help='run recursively over directories; '
                             'must be used with --in-place or --diff')
    parser.add_argument('-j', '--jobs', type=int, metavar='n', default=1,
                        help='number of parallel jobs; '
                             'match CPU count if value is less than 1')
    parser.add_argument('-p', '--pep8-passes', metavar='n',
                        default=-1, type=int,
                        help='maximum number of additional pep8 passes '
                             '(default: infinite)')
    parser.add_argument('-a', '--aggressive', action='count', default=0,
                        help='enable non-whitespace changes; '
                             'multiple -a result in more aggressive changes')
    parser.add_argument('--experimental', action='store_true',
                        help='enable experimental fixes')
    parser.add_argument('--exclude', metavar='globs',
                        help='exclude file/directory names that match these '
                             'comma-separated globs')
    parser.add_argument('--list-fixes', action='store_true',
                        help='list codes for fixes; '
                        'used by --ignore and --select')
    parser.add_argument('--ignore', metavar='errors', default='',
                        help='do not fix these errors/warnings '
                             '(default: {})'.format(DEFAULT_IGNORE))
    parser.add_argument('--select', metavar='errors', default='',
                        help='fix only these errors/warnings (e.g. E4,W)')
    parser.add_argument('--max-line-length', metavar='n', default=79, type=int,
                        help='set maximum allowed line length '
                             '(default: %(default)s)')
    parser.add_argument('--line-range', '--range', metavar='line',
                        default=None, type=int, nargs=2,
                        help='only fix errors found within this inclusive '
                             'range of line numbers (e.g. 1 99); '
                             'line numbers are indexed at 1')
    parser.add_argument('--indent-size', default=DEFAULT_INDENT_SIZE,
                        type=int, help=argparse.SUPPRESS)
    parser.add_argument('--hang-closing', action='store_true',
                        help='hang-closing option passed to pycodestyle')
    parser.add_argument('--exit-code', action='store_true',
                        help='change to behavior of exit code.'
                             ' default behavior of return value, 0 is no '
                             'differences, 1 is error exit. return 2 when'
                             ' add this option. 2 is exists differences.')
    parser.add_argument('files', nargs='*',
                        help="files to format or '-' for standard in")

    return parser
213881
def parse():
    """"""

    # Build the list of subcommand modules
    modnames = [mod for (_, mod, _)
                in pkgutil.iter_modules(payu.subcommands.__path__,
                                        prefix=payu.subcommands.__name__ + '.')
                if mod.endswith('_cmd')]

    subcmds = [importlib.import_module(mod) for mod in modnames]

    # Construct the subcommand parser
    parser = argparse.ArgumentParser()
    parser.add_argument('--version', action='version',
                        version='payu {0}'.format(payu.__version__))

    subparsers = parser.add_subparsers()

    for cmd in subcmds:
        cmd_parser = subparsers.add_parser(cmd.title, **cmd.parameters)
        cmd_parser.set_defaults(run_cmd=cmd.runcmd)

        for arg in cmd.arguments:
            cmd_parser.add_argument(*arg['flags'], **arg['parameters'])

    # Display help if no arguments are provided
    if len(sys.argv) == 1:
        parser.print_help()
    else:
        args = vars(parser.parse_args())
        run_cmd = args.pop('run_cmd')
        run_cmd(**args)
1231163
def make_parser():
    """"""
    parser = ArgumentParser(
        'wait_for_complete.py',
        usage='%(prog)s [-h] queue_name [options]',
        description=('Wait for a set of batch jobs to complete, and monitor '
                     'them as they run.'),
        epilog=('Jobs can also be monitored, terminated, and otherwise '
                'managed on the AWS website. However this tool will also tag '
                'the instances, and should be run whenever a job is submitted '
                'to AWS.')
    )
    parser.add_argument(
        dest='queue_name',
        help=('The name of the queue to watch and wait for completion. If no '
              'jobs are specified, this will wait until all jobs in the queue '
              'are completed (either SUCCEEDED or FAILED).')
    )
    parser.add_argument(
        '--watch', '-w',
        dest='job_list',
        metavar='JOB_ID',
        nargs='+',
        help=('Specify particular jobs using their job ids, as reported by '
              'the submit command. Many ids may be specified.')
    )
    parser.add_argument(
        '--prefix', '-p',
        dest='job_name_prefix',
        help='Specify a prefix for the name of the jobs to watch and wait for.'
    )
    parser.add_argument(
        '--interval', '-i',
        dest='poll_interval',
        default=10,
        type=int,
        help=('The time interval to wait between job status checks, in '
              'seconds (default: %(default)d seconds).')
    )
    parser.add_argument(
        '--timeout', '-T',
        metavar='TIMEOUT',
        type=int,
        help=('If the logs are not updated for %(metavar)s seconds, '
              'print a warning. If `--kill_on_log_timeout` flag is set, then '
              'the offending jobs will be automatically terminated.')
    )
    parser.add_argument(
        '--kill_on_timeout', '-K',
        action='store_true',
        help='If a log times out, terminate the offending job.'
    )
    parser.add_argument(
        '--stash_log_method', '-l',
        choices=['s3', 'local'],
        metavar='METHOD',
        help=('Select a method from: [%(choices)s] to store the job logs. '
              'If no method is specified, the logs will not be '
              'loaded off of AWS. If \'s3\' is specified, then '
              '`job_name_prefix` must also be given, as this will indicate '
              'where on s3 to store the logs.')
    )
    return parser
782225
def run_analysis(args):
  """"""

  # Read the schema and input feature types
  schema_list = json.loads(
      file_io.read_file_to_string(args.schema_file))

  run_numerical_categorical_analysis(args, schema_list)

  # Also save a copy of the schema in the output folder.
  file_io.copy(args.schema_file,
               os.path.join(args.output_dir, SCHEMA_FILE),
               overwrite=True)
1197080
def parser():

    """"""

    parser = argparse.ArgumentParser()
    parser.add_argument('-c', '--config_paths', default=[], action='append',
                        help='path to a configuration directory')
    return parser
457430
def create_parser(self, subparsers):
        
        self.parser = subparsers.add_parser(self.name, help=self.help, parents=self.parents)
        self.add_arguments()
        self.parser.set_defaults(func=self.handle)
        return self.parser