lbaf.Utils.lbsArgumentParser.PromptArgumentParser class

An argument parser that adds the --prompt option to prompt user for args

Methods

def _PromptArgumentParser__print_description(self)
Output colored description
def add_argument(self, *args, **kwargs)
add_argument(dest, ..., name=value, ...) add_argument(option_string, option_string, ..., name=value, ...)
def add_argument_group(self, *args, **kwargs)
def add_mutually_exclusive_group(self, **kwargs)
def add_subparsers(self, **kwargs)
def convert_arg_line_to_args(self, arg_line)
def error(self, message)
error(message: string)
def exit(self, status = 0, message = None)
def format_help(self)
def format_usage(self)
def get_default(self, dest)
def parse_args(self, args = None, namespace = None)
def parse_intermixed_args(self, args = None, namespace = None)
def parse_known_args(self, args = None, namespace = None)
Parse known args.
def parse_known_intermixed_args(self, args = None, namespace = None)
Prints an error message to the console
Prints an info message to the console
Prints a success message to the console
Prints a warning message to the console
def prompt(self, question: str, value_type: typing.Optional[str] = None, default: typing.Union[str, int, float, None] = None, required: bool = False, choices: typing.Union[dict, list, None] = None, validate: typing.Optional[typing.Callable] = None)
Asks a question
def register(self, registry_name, value, object)
def set_args(self, args: dict, namespace = None)
This method init updates a namespace with the default values and with the given arguments.
def set_defaults(self, **kwargs)

Special methods

def __init__(self, prog = None, usage = None, description = None, epilog = None, parents = None, formatter_class = <class 'argparse.HelpFormatter'>, prefix_chars = '-', fromfile_prefix_chars = None, argument_default = None, conflict_handler = 'error', add_help = True, allow_abbrev = True, prompt_default: bool = False)
def __repr__(self)

Method documentation

def lbaf.Utils.lbsArgumentParser.PromptArgumentParser.error(self, message)

error(message: string)

Prints a usage message incorporating the message to stderr and exits.

If you override this in a subclass, it should not return -- it should either exit or raise an exception.

def lbaf.Utils.lbsArgumentParser.PromptArgumentParser.parse_known_args(self, args = None, namespace = None)

Parse known args.

:param args: arguments. If dictionary will set args instead of parsing it from the cli.

def lbaf.Utils.lbsArgumentParser.PromptArgumentParser.set_args(self, args: dict, namespace = None)

This method init updates a namespace with the default values and with the given arguments.

:param args: arguments dictionary to set specific argument values