Bases: JSONScalar, Keyable
A participant identity.
As a Map key, a participant encodes to its stable identifier (the
folder name); key_decode returns that identifier string.
Attributes:
| Name |
Type |
Description |
name |
str
|
|
identifier |
str
|
The stable unique identifier.
|
Source code in capturegraph-lib/capturegraph/types/scalars/identity/user_id.py
| class UserID(JSONScalar, Keyable, name="edu.cornell.user_id"):
"""A participant identity.
As a ``Map`` key, a participant encodes to its stable ``identifier`` (the
folder name); ``key_decode`` returns that identifier string.
Attributes:
name: The display name.
identifier: The stable unique identifier.
"""
name: str
identifier: str
@classmethod
def key_encode(cls, key: object) -> str:
"""Encode a ``Map`` key as the participant's stable identifier."""
if isinstance(key, UserID):
return key.identifier
if isinstance(key, str):
return key
raise TypeError(f"UserID key must be str or UserID, got {key!r}")
@classmethod
def key_decode(cls, name: str) -> str:
"""Decode a ``Map`` folder name back into the identifier string."""
return name
|
key_decode(name)
classmethod
Decode a Map folder name back into the identifier string.
Source code in capturegraph-lib/capturegraph/types/scalars/identity/user_id.py
| @classmethod
def key_decode(cls, name: str) -> str:
"""Decode a ``Map`` folder name back into the identifier string."""
return name
|
key_encode(key)
classmethod
Encode a Map key as the participant's stable identifier.
Source code in capturegraph-lib/capturegraph/types/scalars/identity/user_id.py
| @classmethod
def key_encode(cls, key: object) -> str:
"""Encode a ``Map`` key as the participant's stable identifier."""
if isinstance(key, UserID):
return key.identifier
if isinstance(key, str):
return key
raise TypeError(f"UserID key must be str or UserID, got {key!r}")
|