pyTooling.CLIAbstraction.KeyValueFlag

Flag arguments represent simple boolean values by being present or absent.

See also

  • For flags with different pattern based on the boolean value itself.
    BooleanFlag

  • For flags with a value.
    ValuedFlag

  • For flags that have an optional value.
    NamedOptionalValuedFlag

Classes

  • NamedKeyValuePairsArgument: Class and base-class for all KeyValueFlag classes, which represents a flag argument with key and value

  • ShortKeyValueFlag: Represents a NamedKeyValueFlagArgument with a single dash in front of the switch name.

  • LongKeyValueFlag: Represents a NamedKeyValueFlagArgument with a double dash in front of the switch name.

  • WindowsKeyValueFlag: Represents a NamedKeyValueFlagArgument with a double dash in front of the switch name.


Classes

class pyTooling.CLIAbstraction.KeyValueFlag.NamedKeyValuePairsArgument(keyValuePairs)[source]

Class and base-class for all KeyValueFlag classes, which represents a flag argument with key and value (key-value-pairs).

An optional valued flag is a flag name followed by a value. The default delimiter sign is equal (=). Name and value are passed as one argument to the executable even if the delimiter sign is a whitespace character. If the value is None, no delimiter sign and value is passed.

Example:

  • -gWidth=100

Inheritance

Inheritance diagram of NamedKeyValuePairsArgument

Parameters:
classmethod __init_subclass__(*args, name=None, pattern='{0}{1}={2}', **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:
__init__(keyValuePairs)[source]
Parameters:

keyValuePairs (Dict[str, str])

Return type:

None

property Value: Dict[str, str]

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 name.

Return type:

Union[str, Iterable[str]]

Returns:

Formatted argument.

Raises:

ValueError – If internal name is None.

property Name: str

Get the internal name.

Returns:

Internal name.

__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]: ….

__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.KeyValueFlag.ShortKeyValueFlag(keyValuePairs)[source]

Represents a NamedKeyValueFlagArgument with a single dash in front of the switch name.

Example:

  • -DDEBUG=TRUE

Inheritance

Inheritance diagram of ShortKeyValueFlag

Parameters:
classmethod __init_subclass__(*args, name=None, pattern='-{0}{1}={2}', **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:
AsArgument()

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.

property Name: str

Get the internal name.

Returns:

Internal name.

property Value: Dict[str, str]

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__(keyValuePairs)
Parameters:

keyValuePairs (Dict[str, str])

Return type:

None

__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.KeyValueFlag.LongKeyValueFlag(keyValuePairs)[source]

Represents a NamedKeyValueFlagArgument with a double dash in front of the switch name.

Example:

  • --DDEBUG=TRUE

Inheritance

Inheritance diagram of LongKeyValueFlag

Parameters:
classmethod __init_subclass__(*args, name=None, pattern='--{0}{1}={2}', **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:
AsArgument()

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.

property Name: str

Get the internal name.

Returns:

Internal name.

property Value: Dict[str, str]

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__(keyValuePairs)
Parameters:

keyValuePairs (Dict[str, str])

Return type:

None

__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.KeyValueFlag.WindowsKeyValueFlag(keyValuePairs)[source]

Represents a NamedKeyValueFlagArgument with a double dash in front of the switch name.

Example:

  • --DDEBUG=TRUE

Inheritance

Inheritance diagram of WindowsKeyValueFlag

Parameters:
classmethod __init_subclass__(*args, name=None, pattern='/{0}:{1}={2}', **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.

AsArgument()

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.

property Name: str

Get the internal name.

Returns:

Internal name.

property Value: Dict[str, str]

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__(keyValuePairs)
Parameters:

keyValuePairs (Dict[str, str])

Return type:

None

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