pyTooling.CLIAbstraction.Argument
This module implements command line arguments without prefix character(s).
Variables
Classes
CommandLineArgument: Base-class for all Argument classes.ExecutableArgument: Represents the executable.DelimiterArgument: Represents a delimiter symbol like--.NamedArgument: Base-class for all command line arguments with a name.ValuedArgument: Base-class for all command line arguments with a value.StringArgument: Represents a simple string argument.StringListArgument: Represents a list of string argument (StringArgument).PathArgument: Represents a single path argument.PathListArgument: Represents a list of path arguments (PathArgument).
Variables
- pyTooling.CLIAbstraction.Argument.ValueT
The type of value in a valued argument.
~ValueT
Classes
- class pyTooling.CLIAbstraction.Argument.CommandLineArgument[source]
Base-class for all Argument classes.
An argument instance can be converted via
AsArgumentto a single string value or a sequence of string values (tuple) usable e.g. withsubprocess.Popen. Each argument class implements at least onepatternparameter to specify how argument are formatted.There are multiple derived formats supporting:
commands
→Commandsimple names (flags)
→Flag,BooleanFlagsimple values (vlaued flags)
→StringArgument,PathArgumentnames and values
→ValuedFlag,OptionalValuedFlagkey-value pairs
→NamedKeyValuePairsArgument
Inheritance
- abstractmethod AsArgument()[source]
Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal name and value.
- Return type:
- Returns:
Formatted argument.
- Raises:
NotImplementedError – This is an abstract method and must be overwritten by a subclass.
- abstractmethod __str__()[source]
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- Raises:
NotImplementedError – This is an abstract method and must be overwritten by a subclass.
- abstractmethod __repr__()[source]
Return a string representation of this argument instance.
Note
By default, this method is identical to
__str__().- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- Raises:
NotImplementedError – This is an abstract method and must be overwritten by a subclass.
- classmethod GetMethodsWithAttributes(predicate: Nullable[TAttributeFilter[TAttr]] = None) dict[Callable[..., Any], tuple[Attribute, ...]]
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (Nullable[TAttributeFilter[TAttr]]) – Optional, an attribute class, an iterable of attribute classes, or
Noneto accept every attribute.- Return type:
dict[Callable[…, Any], tuple[Attribute, …]]
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- __new__(**kwargs)
- class pyTooling.CLIAbstraction.Argument.ExecutableArgument[source]
Represents the executable.
Inheritance
- property Executable: Path
Property to access the path to the wrapped executable (
_executable).
- AsArgument()[source]
Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal path to the wrapped executable.
- __str__()[source]
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- __repr__()
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- classmethod GetMethodsWithAttributes(predicate: Nullable[TAttributeFilter[TAttr]] = None) dict[Callable[..., Any], tuple[Attribute, ...]]
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (Nullable[TAttributeFilter[TAttr]]) – Optional, an attribute class, an iterable of attribute classes, or
Noneto accept every attribute.- Return type:
dict[Callable[…, Any], tuple[Attribute, …]]
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- __new__(**kwargs)
- class pyTooling.CLIAbstraction.Argument.DelimiterArgument[source]
Represents a delimiter symbol like
--.Inheritance
- AsArgument()[source]
Convert this argument instance to a string representation with proper escaping using the matching pattern.
- __str__()[source]
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- __repr__()
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- classmethod GetMethodsWithAttributes(predicate: Nullable[TAttributeFilter[TAttr]] = None) dict[Callable[..., Any], tuple[Attribute, ...]]
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (Nullable[TAttributeFilter[TAttr]]) – Optional, an attribute class, an iterable of attribute classes, or
Noneto accept every attribute.- Return type:
dict[Callable[…, Any], tuple[Attribute, …]]
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- __new__(**kwargs)
- class pyTooling.CLIAbstraction.Argument.NamedArgument[source]
Base-class for all command line arguments with a name.
Inheritance
- AsArgument()[source]
Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal name.
- Return type:
- Returns:
Formatted argument.
- Raises:
ValueError – If internal name is None.
- __str__()[source]
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- __repr__()
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- classmethod GetMethodsWithAttributes(predicate: Nullable[TAttributeFilter[TAttr]] = None) dict[Callable[..., Any], tuple[Attribute, ...]]
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (Nullable[TAttributeFilter[TAttr]]) – Optional, an attribute class, an iterable of attribute classes, or
Noneto accept every attribute.- Return type:
dict[Callable[…, Any], tuple[Attribute, …]]
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- __new__(**kwargs)
- class pyTooling.CLIAbstraction.Argument.ValuedArgument[source]
Base-class for all command line arguments with a value.
Inheritance
- __init__(value)[source]
Initializes a ValuedArgument instance.
- Parameters:
value (
TypeVar(ValueT)) – Value to be stored internally.- Raises:
ValueError – If parameter ‘value’ is None.
ValueError – If parameter ‘value’ is None.
- Return type:
None
- property Value: ValueT
Property to access the internal value (
_value).- Returns:
Internal value.
- Raises:
ValueError – If
Noneis assigned.
- AsArgument()[source]
Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal value.
- __str__()[source]
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- __repr__()
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- classmethod GetMethodsWithAttributes(predicate: Nullable[TAttributeFilter[TAttr]] = None) dict[Callable[..., Any], tuple[Attribute, ...]]
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (Nullable[TAttributeFilter[TAttr]]) – Optional, an attribute class, an iterable of attribute classes, or
Noneto accept every attribute.- Return type:
dict[Callable[…, Any], tuple[Attribute, …]]
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- __new__(**kwargs)
- class pyTooling.CLIAbstraction.Argument.StringArgument[source]
Represents a simple string argument.
A list of strings is available as
StringListArgument.Inheritance
- AsArgument()
Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal value.
- classmethod GetMethodsWithAttributes(predicate: Nullable[TAttributeFilter[TAttr]] = None) dict[Callable[..., Any], tuple[Attribute, ...]]
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (Nullable[TAttributeFilter[TAttr]]) – Optional, an attribute class, an iterable of attribute classes, or
Noneto accept every attribute.- Return type:
dict[Callable[…, Any], tuple[Attribute, …]]
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Value: ValueT
Property to access the internal value (
_value).- Returns:
Internal value.
- Raises:
ValueError – If
Noneis assigned.
- __init__(value)
Initializes a ValuedArgument instance.
- Parameters:
value (
TypeVar(ValueT)) – Value to be stored internally.- Raises:
ValueError – If parameter ‘value’ is None.
ValueError – If parameter ‘value’ is None.
- Return type:
None
- __new__(**kwargs)
- __repr__()
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- __str__()
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- class pyTooling.CLIAbstraction.Argument.StringListArgument[source]
Represents a list of string argument (
StringArgument).Inheritance
- property Value: list[str]
Property to access the internal list of str objects (
_values).Note
On assignment, the list object is not replaced, but cleared and then reused by adding the given elements of the iterable.
- Returns:
Reference to the internal list of str objects.
- Raises:
TypeError – If an assigned iterable contains elements which are not of type string.
- AsArgument()[source]
Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal value.
- __str__()[source]
Return a string representation of this argument instance.
- Return type:
- Returns:
Space separated sequence of arguments formatted and each enclosed in double quotes.
- __repr__()[source]
Return a string representation of this argument instance.
- Return type:
- Returns:
Comma separated sequence of arguments formatted and each enclosed in double quotes.
- classmethod GetMethodsWithAttributes(predicate: Nullable[TAttributeFilter[TAttr]] = None) dict[Callable[..., Any], tuple[Attribute, ...]]
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (Nullable[TAttributeFilter[TAttr]]) – Optional, an attribute class, an iterable of attribute classes, or
Noneto accept every attribute.- Return type:
dict[Callable[…, Any], tuple[Attribute, …]]
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- __new__(**kwargs)
- class pyTooling.CLIAbstraction.Argument.PathArgument[source]
Represents a single path argument.
A list of paths is available as
PathListArgument.Inheritance
- AsArgument()[source]
Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal value.
- __str__()[source]
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- __repr__()
Return a string representation of this argument instance.
- Return type:
- Returns:
Argument formatted and enclosed in double quotes.
- classmethod GetMethodsWithAttributes(predicate: Nullable[TAttributeFilter[TAttr]] = None) dict[Callable[..., Any], tuple[Attribute, ...]]
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (Nullable[TAttributeFilter[TAttr]]) – Optional, an attribute class, an iterable of attribute classes, or
Noneto accept every attribute.- Return type:
dict[Callable[…, Any], tuple[Attribute, …]]
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- __new__(**kwargs)
- class pyTooling.CLIAbstraction.Argument.PathListArgument[source]
Represents a list of path arguments (
PathArgument).Inheritance
- classmethod GetMethodsWithAttributes(predicate: Nullable[TAttributeFilter[TAttr]] = None) dict[Callable[..., Any], tuple[Attribute, ...]]
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (Nullable[TAttributeFilter[TAttr]]) – Optional, an attribute class, an iterable of attribute classes, or
Noneto accept every attribute.- Return type:
dict[Callable[…, Any], tuple[Attribute, …]]
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- __new__(**kwargs)
- property Value: list[Path]
Property to access the internal list of path objects (
_paths).Note
On assignment, the list object is not replaced, but cleared and then reused by adding the given elements of the iterable.
- AsArgument()[source]
Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal value.