当前位置: 首页>>代码示例>>Python>>正文


Python argparse._ArgumentGroup方法代码示例

本文整理汇总了Python中argparse._ArgumentGroup方法的典型用法代码示例。如果您正苦于以下问题:Python argparse._ArgumentGroup方法的具体用法?Python argparse._ArgumentGroup怎么用?Python argparse._ArgumentGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在argparse的用法示例。


在下文中一共展示了argparse._ArgumentGroup方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AddProcessingOptions

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def AddProcessingOptions(self, argument_group):
    """Adds processing options to the argument group

    Args:
      argument_group (argparse._ArgumentGroup): argparse argument group.
    """
    argument_helper_names = ['temporary_directory', 'zeromq']
    if self._CanEnforceProcessMemoryLimit():
      argument_helper_names.append('process_resources')
    helpers_manager.ArgumentHelperManager.AddCommandLineArguments(
        argument_group, names=argument_helper_names)

    argument_group.add_argument(
        '--worker-memory-limit', '--worker_memory_limit',
        dest='worker_memory_limit', action='store', type=int,
        metavar='SIZE', help=(
            'Maximum amount of memory (data segment and shared memory) '
            'a worker process is allowed to consume in bytes, where 0 '
            'represents no limit. The default limit is 2147483648 (2 GiB). '
            'If a worker process exceeds this limit is is killed by the main '
            '(foreman) process.')) 
开发者ID:log2timeline,项目名称:plaso,代码行数:23,代码来源:psort_tool.py

示例2: add_config_vars_to_argparse

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def add_config_vars_to_argparse(args):
    """
    Import all defined config vars into |args|, for parsing command line.
    :param args: A container for argparse vars
    :type args: argparse.ArgumentParser or argparse._ArgumentGroup
    :return:
    """
    global _groups
    for group_name, group in _groups.items():
        for key in group:
            obj = group._var_object(key)
            args.add_argument(
                f"--{group_name}.{key}",
                type=type(obj.default),
                default=obj.default,
                help=obj.description,
            ) 
开发者ID:trailofbits,项目名称:manticore,代码行数:19,代码来源:config.py

示例3: before_parse_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def before_parse_args(self, *, parser: ArgumentParser, subparsers: _ArgumentGroup):
        """Add some plugin-related args so behaviour can be customised"""
        run_command_parser = subparsers.choices["run"]
        state_run_group = run_command_parser.add_argument_group(title="State plugin arguments")
        state_run_group.add_argument(
            "--ping-interval",
            help="Interval between worker ping events in seconds. Ping events alert the bus "
            "that this Lightbus worker is alive, and are used to update the lightbus admin interface.",
            metavar="SECONDS",
            type=int,
            default=self.ping_interval,
        )
        state_run_group.add_argument(
            "--no-ping",
            help="Disable sending ping events on the internal.state API. This "
            "may result in your worker not appearing in the lightbus admin interface, "
            "but will reduce traffic and log volume.",
            action="store_true",
        ) 
开发者ID:adamcharnock,项目名称:lightbus,代码行数:21,代码来源:state.py

示例4: add_to_group

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def add_to_group(self, group: argparse._ArgumentGroup) -> None:
        group.add_argument(*self.args, **self.kwargs) 
开发者ID:frostming,项目名称:pdm,代码行数:4,代码来源:options.py

示例5: fill_formatter

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def fill_formatter(argument, formatter, depth=0):
        """
        Manage correctly the subgroups depth
        :param argument: The argument to format
        :param formatter: The formatter to fill
        :param depth: The initial depth of the printed params
        """
        actions = argument._action_groups
        if hasattr(argument, '_group_actions'):
            actions += argument._group_actions

        # print(type(argument))

        if type(argument) == ArgumentParser:
            subsections = True
        else:
            subsections = False
            formatter.start_section(get_spaced_line(argument.title, depth))

        for action_group in actions:
            if subsections:
                formatter.start_section(get_spaced_line(action_group.title, depth))
                formatter.add_text(get_spaced_line(action_group.description, depth))
                formatter.add_arguments(action_group._group_actions, depth=depth)
                for child_action_group in action_group._action_groups:
                    if type(child_action_group) == argparse._ArgumentGroup:
                        ArgumentParser.fill_formatter(child_action_group, formatter, depth)
            else:
                formatter.add_argument(action_group, depth=depth)

            if subsections:
                formatter.end_section()

        if not subsections:
            formatter.end_section() 
开发者ID:offensive-hub,项目名称:black-widow,代码行数:37,代码来源:input_arguments.py

示例6: add_argument_group

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def add_argument_group(self, *args, **kwargs):
        group = _ArgumentGroup(self, *args, **kwargs)
        self._action_groups.append(group)
        return group 
开发者ID:openstack,项目名称:cliff,代码行数:6,代码来源:_argparse.py

示例7: AddArguments

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def AddArguments(cls, argument_group):
    """Adds command line arguments to an argument group.

    This function takes an argument parser or an argument group object and adds
    to it all the command line arguments this helper supports.

    Args:
      argument_group (argparse._ArgumentGroup|argparse.ArgumentParser):
          argparse group.
    """
    argument_group.add_argument(
        '-c', '--correcto', dest='correcto', action='store_true',
        default=False, help='The correcto option.') 
开发者ID:log2timeline,项目名称:plaso,代码行数:15,代码来源:manager.py

示例8: AddFilterOptions

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def AddFilterOptions(self, argument_group):
    """Adds the filter options to the argument group.

    Args:
      argument_group (argparse._ArgumentGroup): argparse argument group.
    """
    names = ['artifact_filters', 'date_filters', 'filter_file']
    helpers_manager.ArgumentHelperManager.AddCommandLineArguments(
        argument_group, names=names)

    argument_group.add_argument(
        '-x', '--extensions', dest='extensions_string', action='store',
        type=str, metavar='EXTENSIONS', help=(
            'Filter on file name extensions. This option accepts multiple '
            'multiple comma separated values e.g. "csv,docx,pst".'))

    argument_group.add_argument(
        '--names', dest='names_string', action='store',
        type=str, metavar='NAMES', help=(
            'Filter on file names.  This option accepts a comma separated '
            'string denoting all file names, e.g. -x '
            '"NTUSER.DAT,UsrClass.dat".'))

    argument_group.add_argument(
        '--signatures', dest='signature_identifiers', action='store',
        type=str, metavar='IDENTIFIERS', help=(
            'Filter on file format signature identifiers. This option '
            'accepts multiple comma separated values e.g. "esedb,lnk". '
            'Use "list" to show an overview of the supported file format '
            'signatures.')) 
开发者ID:log2timeline,项目名称:plaso,代码行数:32,代码来源:image_export_tool.py

示例9: AddOutputTimeZoneOption

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def AddOutputTimeZoneOption(self, argument_group):
    """Adds the output time zone option to the argument group.

    Args:
      argument_group (argparse._ArgumentGroup): argparse argument group.
    """
    # Note the default here is None so we can determine if the time zone
    # option was set.
    argument_group.add_argument(
        '--output_time_zone', '--output-time-zone', dest='output_time_zone',
        action='store', metavar='TIME_ZONE', type=str, default=None, help=(
            'time zone of date and time values written to the output, if '
            'supported by the output format. Output formats that support '
            'this are: dynamic and l2t_csv. Use "list" to see a list of '
            'available time zones.')) 
开发者ID:log2timeline,项目名称:plaso,代码行数:17,代码来源:psteal_tool.py

示例10: split_subparser_argument

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def split_subparser_argument(parent, original, name, condition):
    new_sub_parser = argparse._SubParsersAction(
        original.option_strings,
        original._prog_prefix,
        original._parser_class,
        metavar=original.metavar
    )
    new_sub_parser._name_parser_map = original._name_parser_map
    new_sub_parser._choices_actions = [
        a for a in original._choices_actions if condition(original._name_parser_map[a.dest])
    ]
    group = argparse._ArgumentGroup(parent, name)
    group._group_actions = [new_sub_parser]
    return group 
开发者ID:lbryio,项目名称:lbry-sdk,代码行数:16,代码来源:cli.py

示例11: _add_training_arguments

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def _add_training_arguments(parser: argparse.ArgumentParser) -> argparse._ArgumentGroup:
    train_arguments = parser.add_argument_group("Train Arguments")
    add_config_param(train_arguments)
    add_domain_param(train_arguments)
    add_out_param(
        train_arguments, help_text="Directory where your models should be stored."
    )
    add_augmentation_param(train_arguments)
    add_debug_plots_param(train_arguments)

    return train_arguments 
开发者ID:botfront,项目名称:rasa-for-botfront,代码行数:13,代码来源:interactive.py

示例12: _add_argument

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def _add_argument(self, group: argparse._ArgumentGroup, name: str,  # pylint: disable=protected-access
                      *args: Any, **kwargs: Any) -> None:
        self.skip_type_check = self.override
        # prevent the option name being considered destination by argparse
        if not name.startswith("-"):
            name = "-%s%s" % ("-" if len(name) > 1 else "", name)
        # most actions make types optional, so handle that
        if "type" not in kwargs and "action" in kwargs:
            self.skip_type_check = True
        self.verify_required(kwargs)

        name, kwargs["dest"] = self.process_names(name, kwargs["dest"])
        self.args.append(group.add_argument(name, *args, **kwargs)) 
开发者ID:antismash,项目名称:antismash,代码行数:15,代码来源:args.py

示例13: before_parse_args

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def before_parse_args(self, *, parser: ArgumentParser, subparsers: _ArgumentGroup):
        """ Setup command line argument parser

        Configuration is not available within the before_parse_args()
        hook. This hooks will be called in a separate throw-away instance of this Plugin.

        Note that we don't have an after_parse_args plugin hook. Instead we use the receive_args
        hook which is called once we have instantiated our plugins.
        """
        pass 
开发者ID:adamcharnock,项目名称:lightbus,代码行数:12,代码来源:__init__.py

示例14: make_trainer_parser

# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import _ArgumentGroup [as 别名]
def make_trainer_parser(cls, parser, defaults, prefix=None):
    for k, v in TrainerBase.__hyperparam_defaults__.items():
      defaults.setdefault(k, v)

    prefix = '--' if prefix is None else '--' + str(prefix) + '-'

    if not isinstance(parser, argparse._ArgumentGroup):
      parser = parser.add_argument_group('Trainer')
    parser.add_argument(
        prefix + 'epochs',
        type=int,
        default=defaults['epochs'],
        metavar='N',
        help='number of total epochs to run')
    parser.add_argument(
        prefix + 'epoch-size',
        type=int,
        default=defaults['epoch_size'],
        metavar='N',
        help='number of iterations per epoch')
    parser.add_argument(
        prefix + 'test-epoch-size',
        type=int,
        default=defaults['test_epoch_size'],
        metavar='N',
        help='number of iterations per test epoch')
    parser.add_argument(
        prefix + 'test-number-begin',
        type=int,
        default=defaults['test_number_begin'],
        metavar='N',
        help='begin number of nodes for test')
    parser.add_argument(
        prefix + 'test-number-step',
        type=int,
        default=defaults['test_number_step'],
        metavar='N',
        help='step number of nodes for test')
    parser.add_argument(
        prefix + 'test-number-end',
        type=int,
        default=defaults['test_number_end'],
        metavar='N',
        help='end number of nodes for test') 
开发者ID:google,项目名称:neural-logic-machines,代码行数:46,代码来源:train.py


注:本文中的argparse._ArgumentGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。