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.DryRunException[source]
This exception is raised if an executable is launched while in dry-run mode.
Inheritance
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.
- 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 pyTooling.CLIAbstraction.Environment(variables=None)[source]
Inheritance
- class pyTooling.CLIAbstraction.Program(executablePath=None, binaryDirectoryPath=None, dryRun=False)[source]
Represent a simple command line interface (CLI) executable (program or script).
Inheritance
- classmethod __init_subclass__(*args, **kwargs)[source]
Whenever a subclass is derived from :class:
Program
, all nested classes declared withinProgram
and which are marked with attributeCLIArgument
are collected and then listed in the__cliOptions__
dictionary.
-
__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.
- class pyTooling.CLIAbstraction.Executable(executablePath=None, binaryDirectoryPath=None, workingDirectory=None, dryRun=False)[source]
Represent a CLI executable derived from
Program
, that adds an abstraction ofsubprocess.Popen
.Inheritance
- __init__(executablePath=None, binaryDirectoryPath=None, workingDirectory=None, dryRun=False)[source]
- class property HasClassAttributes: bool
Check if class has Attributes.
- Returns:
True
, if the class has Attributes.
- class property HasMethodAttributes: bool
Check if class has any method with Attributes.
- Returns:
True
, if the class has any method with Attributes.
-
__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 withinProgram
and which are marked with attributeCLIArgument
are collected and then listed in the__cliOptions__
dictionary.
- __repr__()
Return repr(self).
- __str__()
Return str(self).
- class pyTooling.CLIAbstraction.OutputFilteredExecutable(platform, dryrun, executablePath)[source]
Inheritance
- class property HasClassAttributes: bool
Check if class has Attributes.
- Returns:
True
, if the class has Attributes.
- class property HasMethodAttributes: bool
Check if class has any method with Attributes.
- Returns:
True
, if the class has any method with Attributes.
-
__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 withinProgram
and which are marked with attributeCLIArgument
are collected and then listed in the__cliOptions__
dictionary.
- __repr__()
Return repr(self).
- __str__()
Return str(self).
- 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.