utilities
Utility methods.
| FUNCTION | DESCRIPTION |
|---|---|
diff_index |
Return the index where iterable2 is different from iterable1. |
eval_if_callable |
Tries to evaluate |
is_action |
Returns |
is_pipeline |
Returns |
pairs |
Return successive pairs taken from the input iterable. |
resolve_name |
Get a key or attr |
Classes¶
Functions¶
diff_index
¶
diff_index(iterable1: Iterable, iterable2: Iterable) -> Optional[int]
Return the index where iterable2 is different from iterable1.
eval_if_callable
¶
eval_if_callable(value: Any, config: Optional[Configuration] = None) -> Any
Tries to evaluate value as an action, a pipeline, or a callable if possible.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
A callable, action dictionary, list of action dictionaries, or other.
TYPE:
|
config
|
The configuration to use. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
The original value if it cannot be evaluated further. |
pairs
¶
pairs(iterable: Iterable) -> Iterable
Return successive pairs taken from the input iterable.
Like itertools.pairwise in 3.10, but will always include the last element by itself.
Example
list(pairs(“ABCD”)) [(“A”, “B”), (“B”, “C”), (“C”, “D”), (“D”, None)] list(pairs(“ABC”)) [(“A”, “B”), (“B”, “C”), (“C”, None)]
| PARAMETER | DESCRIPTION |
|---|---|
iterable
|
The iterable to combine into pairs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Iterable
|
An iterable of pairs. |
resolve_name
¶
resolve_name(obj: Any, name: str, default: Any = None) -> Any
Get a key or attr name from obj or default value.
Copied and modified from Django Template variable resolutions
Resolution methods:
- Mapping key lookup
- Attribute lookup
- Sequence index
| PARAMETER | DESCRIPTION |
|---|---|
obj
|
The object to access
TYPE:
|
name
|
A dotted name to the value, such as
TYPE:
|
default
|
If the name cannot be resolved from the object, return this value
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
The value at the resolved name or the default value. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If accessing the property raises one of these exceptions. |
AttributeError
|
If accessing the property raises one of these exceptions. |