Token
Represents a special or lazily-evaluated value.
Can be used to delay evaluation of a certain value in case, for example, that it requires some context or late-bound data. Can also be used to mark values that need special processing at document rendering time.
Tokens can be embedded into strings while retaining their original semantics.
Static Functions
Name | Description |
---|---|
as_any |
Return a resolvable representation of the given value. |
as_list |
Return a reversible list representation of this token. |
as_number |
Return a reversible number representation of this token. |
as_string |
Return a reversible string representation of this token. |
is_unresolved |
Returns true if obj represents an unresolved value. |
as_any
import ros_cdk_core
ros_cdk_core.Token.as_any(
value: typing.Any
)
Return a resolvable representation of the given value.
- Type: typing.Any
as_list
import ros_cdk_core
ros_cdk_core.Token.as_list(
value: typing.Any,
display_hint: str = None
)
Return a reversible list representation of this token.
- Type: typing.Any
- Type: str
A hint for the Token's purpose when stringifying it.
as_number
import ros_cdk_core
ros_cdk_core.Token.as_number(
value: typing.Any
)
Return a reversible number representation of this token.
- Type: typing.Any
as_string
import ros_cdk_core
ros_cdk_core.Token.as_string(
value: typing.Any,
display_hint: str = None
)
Return a reversible string representation of this token.
If the Token is initialized with a literal, the stringified value of the literal is returned. Otherwise, a special quoted string representation of the Token is returned that can be embedded into other strings.
Strings with quoted Tokens in them can be restored back into
complex values with the Tokens restored by calling resolve()
on the string.
- Type: typing.Any
- Type: str
A hint for the Token's purpose when stringifying it.
is_unresolved
import ros_cdk_core
ros_cdk_core.Token.is_unresolved(
obj: typing.Any
)
Returns true if obj represents an unresolved value.
One of these must be true:
obj
is an IResolvableobj
is a string containing at least one encodedIResolvable
obj
is either an encoded number or list
This does NOT recurse into lists or objects to see if they containing resolvables.
- Type: typing.Any
The object to test.