Skip to content

string

string #

The text JSON scalar.

String #

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) -> str:
        """Decode a ``Map`` folder name back into its text value."""
        return name

key_decode(name) classmethod #

Decode a Map folder name back into its text value.

Source code in capturegraph-lib/capturegraph/types/scalars/primitives/string.py
@classmethod
def key_decode(cls, name: str) -> str:
    """Decode a ``Map`` folder name back into its text value."""
    return 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}")