sshmitm.moduleparser module

BaseModule parsing library

This module is an extension to the standard Argparse module, which offers the possibility to load to load classes as BaseModule.

This module contains the following public classes:

  • ModuleParser – entry point to parse command line parameters.

    This class provides the same functionality as the ArgumentParser from the argparse module. However, it is possible to specify BaseModules and Plugins, which extend the functionality of the parser and the application respectively.

  • BaseModule – base class for BaseModules that can be used in the application.

    All BaseModules must be derived from this class. If a module does not originate from this class, a ModuleError occurs.

  • ModuleError – Exception thrown when errors occur when initializing modules or plugins.

    This exception is thrown when an error has occurred. Details can be found in the exception.

All other classes and functions in this module are either legacy or are implementation specific and should not be used in production applications.

class sshmitm.moduleparser.AddArgumentMethod(parser: _ModuleArgumentParser, container: _ActionsContainer | None = None, config_section: str | None = None)

Bases: object

class sshmitm.moduleparser.BaseModule(args: Sequence[str] | None = None, namespace: Namespace | None = None, **kwargs: Any)

Bases: object

classmethod add_module(*args: Any, **kwargs: Any) None
classmethod modules() List[Tuple[Action, Any]]
classmethod parser() _ModuleArgumentParser
classmethod parser_arguments() None
exception sshmitm.moduleparser.BaseModuleError

Bases: Exception

exception sshmitm.moduleparser.InvalidModuleArguments

Bases: BaseModuleError

exception sshmitm.moduleparser.ModuleError(moduleclass: Type[BaseModule] | Tuple[Type[BaseModule], ...] | None = None, baseclass: Type[BaseModule] | Tuple[Type[BaseModule], ...] | None = None, message: str | None = None)

Bases: BaseModuleError

class sshmitm.moduleparser.ModuleFormatter(prog, indent_increment=2, max_help_position=24, width=None)

Bases: HelpFormatter

Help message formatter which retains formatting of all help text. Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail.

class sshmitm.moduleparser.ModuleParser(**kwargs: Any)

Bases: _ModuleArgumentParser

add_module(*args: Any, **kwargs: Any) None
parse_args(args: Sequence[str] | None = None, namespace: Namespace | None = None) Namespace
parse_known_args(args: Sequence[str] | None = None, namespace: Namespace | None = None) Tuple[Namespace, List[str]]
sshmitm.moduleparser.load_module(entry_point_class: Type[BaseModule]) Type[Action]

Action to be able to define BaseModule with the “add_module” method of the ModuleParser as command line parameter

sshmitm.moduleparser.load_module_from_entrypoint(name: str, entry_point_class: Type[BaseModule]) Type[BaseModule] | None
sshmitm.moduleparser.set_module_kwargs(entry_point_class: Type[BaseModule], **kwargs: Any) Dict[str, Any]