Bases: JSONScalar, Keyable
A text value.
Source code in capturegraph-lib/capturegraph/types/scalars/primitives/string.py
| class String(JSONScalar, Keyable, name="edu.cornell.string"):
"""A text value."""
value: str
@classmethod
def key_encode(cls, key: object) -> str:
"""Encode a ``Map`` key as its text (from a ``str`` or ``String``)."""
if isinstance(key, String):
return key.value
if isinstance(key, str):
return key
raise TypeError(f"String key must be str or String, got {key!r}")
@classmethod
def key_decode(cls, name: str) -> "String":
"""Decode a ``Map`` folder name back into its text."""
return String(name)
|
key_decode(name)
classmethod
Decode a Map folder name back into its text.
Source code in capturegraph-lib/capturegraph/types/scalars/primitives/string.py
| @classmethod
def key_decode(cls, name: str) -> "String":
"""Decode a ``Map`` folder name back into its text."""
return String(name)
|
key_encode(key)
classmethod
Encode a Map key as its text (from a str or String).
Source code in capturegraph-lib/capturegraph/types/scalars/primitives/string.py
| @classmethod
def key_encode(cls, key: object) -> str:
"""Encode a ``Map`` key as its text (from a ``str`` or ``String``)."""
if isinstance(key, String):
return key.value
if isinstance(key, str):
return key
raise TypeError(f"String key must be str or String, got {key!r}")
|