pyVersioning.CLI
Classes
ProjectAttributeGroup
: This attribute group applies the following ArgParse attributes:CompilerAttributeGroup
: This attribute group applies the following ArgParse attributes:Application
: pyVersioning’s command line interface application class.
Classes
- class pyVersioning.CLI.ProjectAttributeGroup(groupName)[source]
This attribute group applies the following ArgParse attributes:
--project-name
--project-variant
--project-version
Inheritance
- 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.
- classmethod GetAttributes(method, includeSubClasses=True)
Returns attached attributes of this kind for a given method.
- 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 scopescope
.subclassOf
- when the item is a subclass ofsubclassOf
.
- Parameters:
- Return type:
- 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 scopescope
.
- 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 scopescope
.
- 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
- __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.
- _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
- 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.
- classmethod GetAttributes(method, includeSubClasses=True)
Returns attached attributes of this kind for a given method.
- 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 scopescope
.subclassOf
- when the item is a subclass ofsubclassOf
.
- Parameters:
- Return type:
- 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 scopescope
.
- 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 scopescope
.
- 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
- __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.
- _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
- CheckPythonVersion(version)
Check if the used Python interpreter fulfills the minimum version requirements.
- Return type:
- Exit(returnCode=0)
Exit the terminal application by uninitializing color support and returning an Exit code.
- ExitOnPreviousCriticalWarnings(includeErrors=True)
Exit application if critical warnings have been printed.
- ExitOnPreviousWarnings(includeCriticalWarnings=True, includeErrors=True)
Exit application if warnings have been printed.
- 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.
- 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).
- 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:
- Returns:
True, if ‘colorama’ package could be imported and initialized.
- 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.
- 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.
- PrintNotImplementedError(ex)
Prints a not-implemented exception of type
NotImplementedError
.- Return type:
- Parameters:
ex (NotImplementedError)
- 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:
- Returns:
True, if ‘colorama’ package could be imported and uninitialized.
- WriteLine(line)
Print a formatted line to the underlying terminal/console offered by the operating system.
- WriteLineToStdErr(message, end='\\n')
Low-level method for writing to
STDERR
.
- WriteLineToStdOut(message, end='\\n')
Low-level method for writing to
STDOUT
.
- WriteNormal(message, indent=0, appendLinebreak=True)
Write a normal message.
Depending on internal settings and rules, a message might be skipped.
- WriteToStdErr(message)
Low-level method for writing to
STDERR
.
- WriteToStdOut(message)
Low-level method for writing to
STDOUT
.
- _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