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.BaseModule(args: Optional[Sequence[str]] = None, namespace: Optional[Namespace] = 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: Optional[Union[Type[BaseModule], Tuple[Type[BaseModule], ...]]] = None, baseclass: Optional[Union[Type[BaseModule], Tuple[Type[BaseModule], ...]]] = None, message: Optional[str] = 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: Optional[Sequence[str]] = None, namespace: Optional[Namespace] = None) Namespace
parse_known_args(args: Optional[Sequence[str]] = None, namespace: Optional[Namespace] = 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.set_module_kwargs(entry_point_class: Type[BaseModule], **kwargs: Any) Dict[str, Any]