pyTooling.CLIAbstraction

Submodules

Classes

  • CLIArgument: An attribute to annotate nested classes as an CLI argument.

  • Program: Represent a simple command line interface (CLI) executable (program or script).

  • Executable: Represent a CLI executable derived from Program, that adds an abstraction of subprocess.Popen.

class pyTooling.CLIAbstraction.CLIArgument[source]

An attribute to annotate nested classes as an CLI argument.

Inheritance

Inheritance diagram of CLIArgument

classmethod GetAttributes(method, includeSubClasses=True)

Returns attached attributes for a given method.

Return type:

List[Attribute]

Parameters:
classmethod GetClasses(scope=None, filter=None)

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

Return type:

Generator[Type, None, None]

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

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

static _AppendAttribute(entity, attribute)

Helper method, to attach a given pyAttribute to an entity (function, class, method).

Return type:

None

Parameters:
  • entity (Entity) –

  • attribute (Attribute) –

__AttributesMemberName__: str = '__pyattr__'

Field name on entities (function, class, method) to store pyAttributes.

__call__(entity)

Make all classes derived from Attribute callable, so they can be used as a decorator.

Return type:

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

Parameters:

entity (Entity) –

classmethod __init_subclass__(**kwargs)

Ensure each derived class has its own instance of _classes to register the usage of that pyAttribute.

_classes: List[Any] = []

List of classes, this pyAttribute was attached to.

class pyTooling.CLIAbstraction.Program(executablePath=None, binaryDirectoryPath=None, dryRun=False)[source]

Represent a simple command line interface (CLI) executable (program or script).

Inheritance

Inheritance diagram of Program

Parameters:
  • executablePath (Path) –

  • binaryDirectoryPath (Path) –

  • dryRun (bool) –

_executableNames: ClassVar[Dict[str, str]]

Dictionary of platform specific executable names.

__cliOptions__: ClassVar[Dict[Type[CommandLineArgument], int]]

List of all possible CLI options.

classmethod __init_subclass__(*args, **kwargs)[source]

Whenever a subclass is derived from :class:Program, all nested classes declared within Program and which are marked with pyAttribute CLIOption are collected and then listed in the __cliOptions__ dictionary.

__init__(executablePath=None, binaryDirectoryPath=None, dryRun=False)[source]
Parameters:
  • executablePath (Path | None) –

  • binaryDirectoryPath (Path | None) –

  • dryRun (bool) –

_platform: str

Current platform the executable runs on (Linux, Windows, …)

_dryRun: bool

True, if program shall run in dry-run mode.

_executablePath: Path

The path to the executable (binary, script, …).

__cliParameters__: Dict[Type[CommandLineArgument], Optional[CommandLineArgument]]

List of all CLI parameters (used CLI options).

__getitem__(key)[source]

Access to a CLI parameter by CLI option (key must be of type CommandLineArgument), which is already used.

__repr__()[source]

Return repr(self).

__str__()[source]

Return str(self).

class pyTooling.CLIAbstraction.Executable(executablePath=None, binaryDirectoryPath=None, workingDirectory=None, dryRun=False)[source]

Represent a CLI executable derived from Program, that adds an abstraction of subprocess.Popen.

Inheritance

Inheritance diagram of Executable

Parameters:
  • executablePath (Path) –

  • binaryDirectoryPath (Path) –

  • workingDirectory (Path) –

  • dryRun (bool) –

__init__(executablePath=None, binaryDirectoryPath=None, workingDirectory=None, dryRun=False)[source]
Parameters:
  • executablePath (Path | None) –

  • binaryDirectoryPath (Path | None) –

  • workingDirectory (Path | None) –

  • dryRun (bool) –

__cliOptions__: ClassVar[Dict[Type[CommandLineArgument], int]] = {}

List of all possible CLI options.

__cliParameters__: Dict[Type[CommandLineArgument], Optional[CommandLineArgument]]

List of all CLI parameters (used CLI options).

__getitem__(key)

Access to a CLI parameter by CLI option (key must be of type CommandLineArgument), which is already used.

classmethod __init_subclass__(*args, **kwargs)

Whenever a subclass is derived from :class:Program, all nested classes declared within Program and which are marked with pyAttribute CLIOption are collected and then listed in the __cliOptions__ dictionary.

__repr__()

Return repr(self).

__str__()

Return str(self).

_dryRun: bool

True, if program shall run in dry-run mode.

_executableNames: ClassVar[Dict[str, str]]

Dictionary of platform specific executable names.

_executablePath: Path

The path to the executable (binary, script, …).

_platform: str

Current platform the executable runs on (Linux, Windows, …)

Exceptions

exception pyTooling.CLIAbstraction.CLIAbstractionException(message='')[source]

Inheritance

Inheritance diagram of CLIAbstractionException

Parameters:

message (str) –

__cause__

exception cause

__context__

exception context

__delattr__(name, /)

Implement delattr(self, name).

__getattribute__(name, /)

Return getattr(self, name).

__init__(message='')

ExceptionBase initializer.

Parameters:

message (str) – The exception message.

__new__(**kwargs)
__reduce__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__(name, value, /)

Implement setattr(self, name, value).

__str__()

Returns the exception’s message text.

Return type:

str

with_traceback(tb)

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

Return type:

None

exception pyTooling.CLIAbstraction.DryRunException(message='')[source]

This exception is raised if an executable is launched while in dry-run mode.

Inheritance

Inheritance diagram of DryRunException

Parameters:

message (str) –

__cause__

exception cause

__context__

exception context

__delattr__(name, /)

Implement delattr(self, name).

__getattribute__(name, /)

Return getattr(self, name).

__init__(message='')

ExceptionBase initializer.

Parameters:

message (str) – The exception message.

__new__(**kwargs)
__reduce__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__(name, value, /)

Implement setattr(self, name, value).

__str__()

Returns the exception’s message text.

Return type:

str

with_traceback(tb)

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

Return type:

None