pyTooling.CLIAbstraction
Basic abstraction layer for executables.
Submodules
- pyTooling.CLIAbstraction.Argument
- pyTooling.CLIAbstraction.BooleanFlag
- pyTooling.CLIAbstraction.Command
- pyTooling.CLIAbstraction.Flag
- pyTooling.CLIAbstraction.KeyValueFlag
- pyTooling.CLIAbstraction.OptionalValuedFlag
- pyTooling.CLIAbstraction.ValuedFlag
- pyTooling.CLIAbstraction.ValuedFlagList
- pyTooling.CLIAbstraction.ValuedTupleFlag
Exceptions
CLIAbstractionException
: The exception is raised by pyTooling internal features.DryRunException
: This exception is raised if an executable is launched while in dry-run mode.
Classes
CLIArgument
: An attribute to annotate nested classes as an CLI argument.Environment
: Undocumented.Program
: Represent a simple command line interface (CLI) executable (program or script).Executable
: Represent a CLI executable derived fromProgram
, that adds an abstraction ofsubprocess.Popen
.OutputFilteredExecutable
: Represent a CLI executable derived fromProgram
, that adds an abstraction ofsubprocess.Popen
.
Exceptions
- exception pyTooling.CLIAbstraction.CLIAbstractionException[source]
Inheritance
- classmethod __new__(*args, **kwargs)
- __init__(*args, **kwargs)
- exception pyTooling.CLIAbstraction.DryRunException[source]
This exception is raised if an executable is launched while in dry-run mode.
Inheritance
- classmethod __new__(*args, **kwargs)
- __init__(*args, **kwargs)
Classes
- class pyTooling.CLIAbstraction.CLIArgument[source]
An attribute to annotate nested classes as an CLI argument.
Inheritance
- 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
- __call__(entity)
Attributes get attached to an entity (function, class, method) and an index is updated at the attribute for reverse lookups.
- _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 pyTooling.CLIAbstraction.Program[source]
Represent a simple command line interface (CLI) executable (program or script).
Inheritance
-
_executablePath:
Path
The path to the executable (binary, script, …).
-
__cliParameters__:
Dict
[Type
[CommandLineArgument
],Optional
[CommandLineArgument
]] List of all CLI parameters (used CLI options).
-
_executablePath:
- class pyTooling.CLIAbstraction.Executable[source]
Represent a CLI executable derived from
Program
, that adds an abstraction ofsubprocess.Popen
.Inheritance
- __init__(executablePath=None, binaryDirectoryPath=None, workingDirectory=None, environment=None, dryRun=False)[source]
- Parameters:
executablePath (Path)
binaryDirectoryPath (Path)
workingDirectory (Path)
environment (Environment | 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.
- __repr__()
Return repr(self).
- __str__()
Return str(self).
-
_executablePath:
Path
The path to the executable (binary, script, …).
- class pyTooling.CLIAbstraction.OutputFilteredExecutable[source]
Inheritance
-
__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.
- __repr__()
Return repr(self).
- __str__()
Return str(self).
-
_executablePath:
Path
The path to the executable (binary, script, …).
- property HasWarnings
True if warnings were found while processing the output stream.
- property HasErrors
True if errors were found while processing the output stream.
- property HasFatals
True if fatals were found while processing the output stream.
-
__cliOptions__: