Python argparse._ArgumentGroup() Examples
The following are 15
code examples of argparse._ArgumentGroup().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
argparse
, or try the search function
.
Example #1
Source File: psort_tool.py From plaso with Apache License 2.0 | 6 votes |
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.'))
Example #2
Source File: config.py From manticore with GNU Affero General Public License v3.0 | 6 votes |
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, )
Example #3
Source File: state.py From lightbus with Apache License 2.0 | 6 votes |
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", )
Example #4
Source File: options.py From pdm with MIT License | 5 votes |
def add_to_group(self, group: argparse._ArgumentGroup) -> None: group.add_argument(*self.args, **self.kwargs)
Example #5
Source File: input_arguments.py From black-widow with GNU General Public License v3.0 | 5 votes |
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()
Example #6
Source File: _argparse.py From cliff with Apache License 2.0 | 5 votes |
def add_argument_group(self, *args, **kwargs): group = _ArgumentGroup(self, *args, **kwargs) self._action_groups.append(group) return group
Example #7
Source File: manager.py From plaso with Apache License 2.0 | 5 votes |
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.')
Example #8
Source File: image_export_tool.py From plaso with Apache License 2.0 | 5 votes |
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.'))
Example #9
Source File: psteal_tool.py From plaso with Apache License 2.0 | 5 votes |
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.'))
Example #10
Source File: psort_tool.py From plaso with Apache License 2.0 | 5 votes |
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.'))
Example #11
Source File: cli.py From lbry-sdk with MIT License | 5 votes |
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
Example #12
Source File: interactive.py From rasa-for-botfront with Apache License 2.0 | 5 votes |
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
Example #13
Source File: args.py From antismash with GNU Affero General Public License v3.0 | 5 votes |
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))
Example #14
Source File: __init__.py From lightbus with Apache License 2.0 | 5 votes |
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
Example #15
Source File: train.py From neural-logic-machines with Apache License 2.0 | 4 votes |
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')