pyTooling.CLIAbstraction.Argument

This module implements command line arguments without prefix character(s).

Variables

Classes


Variables

pyTooling.CLIAbstraction.Argument.ValueT

The type of value in a valued argument.

~ValueT

Classes

class pyTooling.CLIAbstraction.Argument.CommandLineArgument(*args: Any, **kwargs: Any)[source]

Base-class for all Argument classes.

An argument instance can be converted via AsArgument to a single string value or a sequence of string values (tuple) usable e.g. with subprocess.Popen. Each argument class implements at least one pattern parameter to specify how argument are formatted.

There are multiple derived formats supporting:

Inheritance

Inheritance diagram of CommandLineArgument

Parameters:
classmethod __init_subclass__(*args, pattern=None, **kwargs)[source]

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • pattern (Optional[str]) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

static __new__(cls, *args, **kwargs)[source]
Parameters:
abstract 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:

Union[str, Iterable[str]]

Returns:

Formatted argument.

Raises:

NotImplementedError – This is an abstract method and must be overwritten by a subclass.

abstract __str__()[source]

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

Raises:

NotImplementedError – This is an abstract method and must be overwritten by a subclass.

abstract __repr__()[source]

Return a string representation of this argument instance.

Note

By default, this method is identical to __str__().

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

Raises:

NotImplementedError – This is an abstract method and must be overwritten by a subclass.

class pyTooling.CLIAbstraction.Argument.ExecutableArgument(executable)[source]

Represents the executable.

Inheritance

Inheritance diagram of ExecutableArgument

Parameters:

executable (Path)

__init__(executable)[source]

Initializes a ExecutableArgument instance.

Parameters:

executable (Path) – Path to the executable.

Raises:

TypeError – If parameter ‘executable’ is not of type Path.

Return type:

None

property Executable: Path

Get the internal path to the wrapped executable.

Returns:

Internal path to the 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.

Return type:

Union[str, Iterable[str]]

Returns:

Formatted argument.

__str__()[source]

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

__repr__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

classmethod __init_subclass__(*args, pattern=None, **kwargs)

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • pattern (Optional[str]) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

static __new__(cls, *args, **kwargs)
Parameters:
class pyTooling.CLIAbstraction.Argument.DelimiterArgument(*args: Any, **kwargs: Any)[source]

Represents a delimiter symbol like --.

Inheritance

Inheritance diagram of DelimiterArgument

Parameters:
classmethod __init_subclass__(*args, pattern='--', **kwargs)[source]

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • pattern (str) – This pattern is used to format an argument. Default: "--".

  • kwargs (Any) – Any keyword argument.

AsArgument()[source]

Convert this argument instance to a string representation with proper escaping using the matching pattern.

Return type:

Union[str, Iterable[str]]

Returns:

Formatted argument.

__str__()[source]

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

__repr__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

static __new__(cls, *args, **kwargs)
Parameters:
class pyTooling.CLIAbstraction.Argument.NamedArgument(*args: Any, **kwargs: Any)[source]

Base-class for all command line arguments with a name.

Inheritance

Inheritance diagram of NamedArgument

Parameters:
classmethod __init_subclass__(*args, name=None, pattern='{0}', **kwargs)[source]

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • name (Optional[str]) – Name of the argument.

  • pattern (str) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

static __new__(cls, *args, **kwargs)[source]
Parameters:
property Name: str

Get the internal name.

Returns:

Internal name.

AsArgument()[source]

Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal name.

Return type:

Union[str, Iterable[str]]

Returns:

Formatted argument.

Raises:

ValueError – If internal name is None.

__str__()[source]

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

__repr__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

class pyTooling.CLIAbstraction.Argument.ValuedArgument(value)[source]

Base-class for all command line arguments with a value.

Inheritance

Inheritance diagram of ValuedArgument

Parameters:

value (ValueT)

classmethod __init_subclass__(*args, pattern='{0}', **kwargs)[source]

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • pattern (str) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

__init__(value)[source]

Initializes a ValuedArgument instance.

Parameters:

value (TypeVar(ValueT)) – Value to be stored internally.

Raises:

TypeError – If parameter ‘value’ is None.

Return type:

None

property Value: ValueT

Get the internal value.

Returns:

Internal value.

AsArgument()[source]

Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal value.

Return type:

Union[str, Iterable[str]]

Returns:

Formatted argument.

__str__()[source]

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

__repr__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

__class_getitem__()

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo[T]: ….

static __new__(cls, *args, **kwargs)
Parameters:
class pyTooling.CLIAbstraction.Argument.StringArgument(value)[source]

Represents a simple string argument.

A list of strings is available as StringListArgument.

Inheritance

Inheritance diagram of StringArgument

Parameters:

value (ValueT)

classmethod __init_subclass__(*args, pattern='{0}', **kwargs)[source]

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • pattern (str) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

AsArgument()

Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal value.

Return type:

Union[str, Iterable[str]]

Returns:

Formatted argument.

property Value: ValueT

Get the internal value.

Returns:

Internal value.

__class_getitem__()

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo[T]: ….

__init__(value)

Initializes a ValuedArgument instance.

Parameters:

value (TypeVar(ValueT)) – Value to be stored internally.

Raises:

TypeError – If parameter ‘value’ is None.

Return type:

None

static __new__(cls, *args, **kwargs)
Parameters:
__repr__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

__str__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

class pyTooling.CLIAbstraction.Argument.StringListArgument(values)[source]

Represents a list of string argument (StringArgument).

Inheritance

Inheritance diagram of StringListArgument

Parameters:

values (Iterable[str])

__init__(values)[source]

Initializes a StringListArgument instance.

Parameters:

values (Iterable[str]) – An iterable of str instances.

Raises:

TypeError – If iterable parameter ‘values’ contains elements not of type str.

Return type:

None

property Value: List[str]

Get the internal list of str objects.

Returns:

Reference to the internal list of str objects.

AsArgument()[source]

Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal value.

Return type:

Union[str, Iterable[str]]

Returns:

Sequence of formatted arguments.

__str__()[source]

Return a string representation of this argument instance.

Return type:

str

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:

str

Returns:

Comma separated sequence of arguments formatted and each enclosed in double quotes.

__class_getitem__()

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo[T]: ….

classmethod __init_subclass__(*args, pattern='{0}', **kwargs)

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • pattern (str) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

static __new__(cls, *args, **kwargs)
Parameters:
class pyTooling.CLIAbstraction.Argument.PathArgument(path)[source]

Represents a single path argument.

A list of paths is available as PathListArgument.

Inheritance

Inheritance diagram of PathArgument

Parameters:

path (Path)

__init__(path)[source]

Initializes a PathArgument instance.

Parameters:

path (Path) – Path to a filesystem object.

Raises:

TypeError – If parameter ‘path’ is not of type Path.

Return type:

None

property Value: Path

Get the internal path object.

Returns:

Internal path object.

AsArgument()[source]

Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal value.

Return type:

Union[str, Iterable[str]]

Returns:

Formatted argument.

__str__()[source]

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

__repr__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

classmethod __init_subclass__(*args, pattern=None, **kwargs)

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • pattern (Optional[str]) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

static __new__(cls, *args, **kwargs)
Parameters:
class pyTooling.CLIAbstraction.Argument.PathListArgument(paths)[source]

Represents a list of path arguments (PathArgument).

Inheritance

Inheritance diagram of PathListArgument

Parameters:

paths (Iterable[Path])

classmethod __init_subclass__(*args, pattern=None, **kwargs)

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • pattern (Optional[str]) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

static __new__(cls, *args, **kwargs)
Parameters:
__init__(paths)[source]

Initializes a PathListArgument instance.

Parameters:

paths (Iterable[Path]) – An iterable os Path instances.

Raises:

TypeError – If iterable parameter ‘paths’ contains elements not of type Path.

Return type:

None

property Value: List[Path]

Get the internal list of path objects.

Returns:

Reference to the internal list of path objects.

AsArgument()[source]

Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal value.

Return type:

Union[str, Iterable[str]]

Returns:

Sequence of formatted arguments.

__str__()[source]

Return a string representation of this argument instance.

Return type:

str

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:

str

Returns:

Comma separated sequence of arguments formatted and each enclosed in double quotes.