pyVersioning.CLI

Classes


Classes

class pyVersioning.CLI.ProjectAttributeGroup(groupName)[source]

This attribute group applies the following ArgParse attributes:

  • --project-name

  • --project-variant

  • --project-version

Inheritance

Inheritance diagram of ProjectAttributeGroup

Parameters:

groupName (str)

__call__(func)[source]

Attributes get attached to an entity (function, class, method) and an index is updated at the attribute for reverse lookups.

Parameters:
  • entity – Entity (function, class, method), to attach an attribute to.

  • func (Entity)

Return type:

TypeVar(Entity, bound= Union[Type, Callable])

Returns:

Same entity, with attached attribute.

Raises:

TypeError – If parameter ‘entity’ is not a function, class nor method.

classmethod GetAttributes(method, includeSubClasses=True)

Returns attached attributes of this kind for a given method.

Parameters:
  • method (MethodType)

  • includeSubClasses (bool)

Return type:

Tuple[Attribute, ...]

Returns:

Raises:

TypeError

classmethod GetClasses(scope=None, subclassOf=None)

Return a generator for all classes, where this attribute is attached to.

The resulting item stream can be filtered by:
  • scope - when the item is a nested class in scope scope.

  • subclassOf - when the item is a subclass of subclassOf.

Parameters:
Return type:

Generator[TypeVar(TAttr, bound= Attribute), None, None]

Returns:

A sequence of classes where this attribute is attached to.

classmethod GetFunctions(scope=None)

Return a generator for all functions, where this attribute is attached to.

The resulting item stream can be filtered by:
  • scope - when the item is a nested class in scope scope.

Parameters:

scope (Optional[Type]) – Undocumented.

Return type:

Generator[TypeVar(TAttr, bound= Attribute), None, None]

Returns:

A sequence of functions where this attribute is attached to.

classmethod GetMethods(scope=None)

Return a generator for all methods, where this attribute is attached to.

The resulting item stream can be filtered by:
  • scope - when the item is a nested class in scope scope.

Parameters:

scope (Optional[Type]) – Undocumented.

Return type:

Generator[TypeVar(TAttr, bound= Attribute), None, None]

Returns:

A sequence of methods where this attribute is attached to.

property GroupName: str

Returns the name of the command group.

static _AppendAttribute(entity, attribute)

Append an attribute to a language entity (class, method, function).

Hint

This method can be used in attribute groups to apply multiple attributes within __call__ method.

class GroupAttribute(Attribute):
  def __call__(self, entity: Entity) -> Entity:
    self._AppendAttribute(entity, SimpleAttribute(...))
    self._AppendAttribute(entity, SimpleAttribute(...))

    return entity
Parameters:
Raises:

TypeError – If parameter ‘entity’ is not a class, method or function.

Return type:

None

__init__(groupName)

The constructor expects a ‘groupName’ which can be used to group sub-commands for better readability.

Parameters:

groupName (str)

Return type:

None

classmethod __init_subclass__(**kwargs)

Ensure each derived class has its own instance of _functions, _classes and _methods to register the usage of that Attribute.

Return type:

None

Parameters:

kwargs (Any)

_classes: ClassVar[List[Any]] = []

List of classes, this Attribute was attached to.

_functions: ClassVar[List[Any]] = []

List of functions, this Attribute was attached to.

_methods: ClassVar[List[Any]] = []

List of methods, this Attribute was attached to.

_scope: ClassVar[AttributeScope] = 7

Allowed language construct this attribute can be used with.

class pyVersioning.CLI.CompilerAttributeGroup(groupName)[source]

This attribute group applies the following ArgParse attributes:

  • --compiler-name

  • --compiler-version

  • --compiler-config

  • --compiler-options

Inheritance

Inheritance diagram of CompilerAttributeGroup

Parameters:

groupName (str)

__call__(func)[source]

Attributes get attached to an entity (function, class, method) and an index is updated at the attribute for reverse lookups.

Parameters:
  • entity – Entity (function, class, method), to attach an attribute to.

  • func (Entity)

Return type:

TypeVar(Entity, bound= Union[Type, Callable])

Returns:

Same entity, with attached attribute.

Raises:

TypeError – If parameter ‘entity’ is not a function, class nor method.

classmethod GetAttributes(method, includeSubClasses=True)

Returns attached attributes of this kind for a given method.

Parameters:
  • method (MethodType)

  • includeSubClasses (bool)

Return type:

Tuple[Attribute, ...]

Returns:

Raises:

TypeError

classmethod GetClasses(scope=None, subclassOf=None)

Return a generator for all classes, where this attribute is attached to.

The resulting item stream can be filtered by:
  • scope - when the item is a nested class in scope scope.

  • subclassOf - when the item is a subclass of subclassOf.

Parameters:
Return type:

Generator[TypeVar(TAttr, bound= Attribute), None, None]

Returns:

A sequence of classes where this attribute is attached to.

classmethod GetFunctions(scope=None)

Return a generator for all functions, where this attribute is attached to.

The resulting item stream can be filtered by:
  • scope - when the item is a nested class in scope scope.

Parameters:

scope (Optional[Type]) – Undocumented.

Return type:

Generator[TypeVar(TAttr, bound= Attribute), None, None]

Returns:

A sequence of functions where this attribute is attached to.

classmethod GetMethods(scope=None)

Return a generator for all methods, where this attribute is attached to.

The resulting item stream can be filtered by:
  • scope - when the item is a nested class in scope scope.

Parameters:

scope (Optional[Type]) – Undocumented.

Return type:

Generator[TypeVar(TAttr, bound= Attribute), None, None]

Returns:

A sequence of methods where this attribute is attached to.

property GroupName: str

Returns the name of the command group.

static _AppendAttribute(entity, attribute)

Append an attribute to a language entity (class, method, function).

Hint

This method can be used in attribute groups to apply multiple attributes within __call__ method.

class GroupAttribute(Attribute):
  def __call__(self, entity: Entity) -> Entity:
    self._AppendAttribute(entity, SimpleAttribute(...))
    self._AppendAttribute(entity, SimpleAttribute(...))

    return entity
Parameters:
Raises:

TypeError – If parameter ‘entity’ is not a class, method or function.

Return type:

None

__init__(groupName)

The constructor expects a ‘groupName’ which can be used to group sub-commands for better readability.

Parameters:

groupName (str)

Return type:

None

classmethod __init_subclass__(**kwargs)

Ensure each derived class has its own instance of _functions, _classes and _methods to register the usage of that Attribute.

Return type:

None

Parameters:

kwargs (Any)

_classes: ClassVar[List[Any]] = []

List of classes, this Attribute was attached to.

_functions: ClassVar[List[Any]] = []

List of functions, this Attribute was attached to.

_methods: ClassVar[List[Any]] = []

List of methods, this Attribute was attached to.

_scope: ClassVar[AttributeScope] = 7

Allowed language construct this attribute can be used with.

class pyVersioning.CLI.Application[source]

pyVersioning’s command line interface application class.

Inheritance

Inheritance diagram of Application

__init__()[source]

Initializer of a line based terminal interface.

Return type:

None

_PrintHeadline()[source]

Helper method to print the program headline.

Return type:

None

_PrintVersion()[source]

Helper method to print the version information.

Return type:

None

HandleDefault(args)[source]

Handle program calls for no given command.

Return type:

None

Parameters:

args (Namespace)

HandleHelp(args)[source]

Handle program calls for command help.

Return type:

None

Parameters:

args (Namespace)

HandleVersion(args)[source]

Handle program calls for command version.

Return type:

None

Parameters:

args (Namespace)

HandleVariables(args)[source]

Handle program calls for command variables.

Return type:

None

Parameters:

args (Namespace)

HandleField(args)[source]

Handle program calls for command field.

Return type:

None

Parameters:

args (Namespace)

HandleFillOut(args)[source]

Handle program calls for command fillout.

Return type:

None

Parameters:

args (Namespace)

HandleJSON(args)[source]

Handle program calls for command json.

Return type:

None

Parameters:

args (Namespace)

HandleYAML(args)[source]

Handle program calls for command yaml.

Return type:

None

Parameters:

args (Namespace)

CheckPythonVersion(version)

Check if the used Python interpreter fulfills the minimum version requirements.

Return type:

None

property Debug: bool

Returns true, if debug messages are enabled.

Exit(returnCode=0)

Exit the terminal application by uninitializing color support and returning an Exit code.

Return type:

NoReturn

Parameters:

returnCode (int)

ExitOnPreviousCriticalWarnings(includeErrors=True)

Exit application if critical warnings have been printed.

Return type:

None

Parameters:

includeErrors (bool)

ExitOnPreviousErrors()

Exit application if errors have been printed.

Return type:

None

ExitOnPreviousWarnings(includeCriticalWarnings=True, includeErrors=True)

Exit application if warnings have been printed.

Return type:

None

Parameters:
  • includeCriticalWarnings (bool)

  • includeErrors (bool)

FATAL_EXIT_CODE: ClassVar[int] = 255

Return code for fatal exits.

FatalExit(returnCode=0)

Exit the terminal application by uninitializing color support and returning a fatal Exit code.

Return type:

NoReturn

Parameters:

returnCode (int)

Foreground = {'BLUE': '\x1b[94m', 'CYAN': '\x1b[96m', 'DARK_BLUE': '\x1b[34m', 'DARK_CYAN': '\x1b[36m', 'DARK_GRAY': '\x1b[90m', 'DARK_GREEN': '\x1b[32m', 'DARK_RED': '\x1b[31m', 'DARK_YELLOW': '\x1b[33m', 'ERROR': '\x1b[91m', 'GRAY': '\x1b[37m', 'GREEN': '\x1b[92m', 'HEADLINE': '\x1b[95m', 'MAGENTA': '\x1b[95m', 'NOCOLOR': '\x1b[39m', 'RED': '\x1b[91m', 'WARNING': '\x1b[93m', 'WHITE': '\x1b[97m', 'YELLOW': '\x1b[93m'}

Terminal colors

static GetTerminalSize()

Returns the terminal size as tuple (width, height) for Windows, macOS (Darwin), Linux, cygwin (Windows), MinGW32/64 (Windows).

Return type:

Tuple[int, int]

Returns:

A tuple containing width and height of the terminal’s size in characters.

Raises:

PlatformNotSupportedException – When a platform is not yet supported.

property Height: int

Returns the current terminal window’s height.

INDENT: ClassVar[str] = '  '

Indentation. Default: "  " (2 spaces)

ISSUE_TRACKER_URL: ClassVar[str] = None

URL to the issue tracker for reporting bugs.

InitializeColors()

Initialize the terminal for color support by colorama.

Return type:

bool

Returns:

True, if ‘colorama’ package could be imported and initialized.

property LogLevel: Severity

Return the current minimal severity level for writing.

property MainParser: ArgumentParser

Returns the main parser.

NOT_IMPLEMENTED_EXCEPTION_EXIT_CODE: ClassVar[int] = 240

Return code, if unimplemented methods or code sections were called.

PYTHON_VERSION_CHECK_FAILED_EXIT_CODE: ClassVar[int] = 254

Return code, if version check was not successful.

PrintException(ex)

Prints an exception of type Exception and its traceback.

If the exception as a nested action, the cause is printed as well.

If ISSUE_TRACKER_URL is configured, a URL to the issue tracker is added.

Return type:

NoReturn

Parameters:

ex (Exception)

PrintExceptionBase(ex)

Prints an exception of type ExceptionBase and its traceback.

If the exception as a nested action, the cause is printed as well.

If ISSUE_TRACKER_URL is configured, a URL to the issue tracker is added.

Return type:

NoReturn

Parameters:

ex (Exception)

PrintNotImplementedError(ex)

Prints a not-implemented exception of type NotImplementedError.

Return type:

NoReturn

Parameters:

ex (NotImplementedError)

property Quiet: bool

Returns true, if quiet mode is enabled.

property SubParsers: Dict

Returns the sub-parsers.

UNHANDLED_EXCEPTION_EXIT_CODE: ClassVar[int] = 241

Return code, if an unhandled exception reached the topmost exception handler.

UninitializeColors()

Uninitialize the terminal for color support by colorama.

Return type:

bool

Returns:

True, if ‘colorama’ package could be imported and uninitialized.

property Verbose: bool

Returns true, if verbose messages are enabled.

property Width: int

Returns the current terminal window’s width.

WriteLine(line)

Print a formatted line to the underlying terminal/console offered by the operating system.

Return type:

bool

Parameters:

line (Line)

WriteLineToStdErr(message, end='\\n')

Low-level method for writing to STDERR.

Parameters:
  • message (str) – Message to write to STDERR.

  • end (str) – Use newline character. Default: \n.

Return type:

int

Returns:

Number of written characters.

WriteLineToStdOut(message, end='\\n')

Low-level method for writing to STDOUT.

Parameters:
  • message (str) – Message to write to STDOUT.

  • end (str) – Use newline character. Default: \n.

Return type:

int

Returns:

Number of written characters.

WriteNormal(message, indent=0, appendLinebreak=True)

Write a normal message.

Depending on internal settings and rules, a message might be skipped.

Parameters:
  • message (str) – Message to write.

  • indent (int) – Indentation level of the message.

  • appendLinebreak (bool) – Append a linebreak after the message. Default: True

Return type:

bool

Returns:

True, if message was actually written.

WriteToStdErr(message)

Low-level method for writing to STDERR.

Parameters:

message (str) – Message to write to STDERR.

Return type:

int

Returns:

Number of written characters.

WriteToStdOut(message)

Low-level method for writing to STDOUT.

Parameters:

message (str) – Message to write to STDOUT.

Return type:

int

Returns:

Number of written characters.

_LOG_LEVEL_ROUTING__: Dict[Severity, Tuple[Callable[[str, str], int]]]

Message routing rules.

_LOG_MESSAGE_FORMAT__ = {Severity.Debug: '{DARK_GRAY}{message}{NOCOLOR}', Severity.Verbose: '{GRAY}{message}{NOCOLOR}', Severity.DryRun: '{DARK_CYAN}[DRY] {message}{NOCOLOR}', Severity.Normal: '{GRAY}{message}{NOCOLOR}', Severity.Info: '{WHITE}{message}{NOCOLOR}', Severity.Warning: '{YELLOW}[WARNING] {message}{NOCOLOR}', Severity.Critical: '{DARK_YELLOW}[CRITICAL] {message}{NOCOLOR}', Severity.Quiet: '{WHITE}{message}{NOCOLOR}', Severity.Error: '{RED}[ERROR] {message}{NOCOLOR}', Severity.Fatal: '{DARK_RED}[FATAL] {message}{NOCOLOR}'}

Message formatting rules.

_height: int

Terminal height in characters

_stderr: TextIOWrapper

STDERR

_stdin: TextIOWrapper

STDIN

_stdout: TextIOWrapper

STDOUT

_width: int

Terminal width in characters