"""
Provide presence roles.
"""
from __future__ import annotations
from typing import final
from typing_extensions import override
from betty.locale.localizable import Localizable, _
from betty.plugin import Plugin, PluginRepository
from betty.plugin.entry_point import EntryPointPluginRepository
from betty.serde.dump import DictDump, Dump, dump_default
[docs]
class PresenceRole(Plugin):
"""
A person's role at an event.
"""
pass
PRESENCE_ROLE_REPOSITORY: PluginRepository[PresenceRole] = EntryPointPluginRepository(
"betty.presence_role"
)
"""
The presence role plugin repository.
"""
[docs]
def ref_role(root_schema: DictDump[Dump]) -> DictDump[Dump]:
"""
Reference the PresenceRole schema.
"""
definitions = dump_default(root_schema, "definitions", dict)
if "role" not in definitions:
definitions["role"] = {
"type": "string",
"description": "A person's role in an event.",
}
return {
"$ref": "#/definitions/role",
}
[docs]
@final
class Subject(PresenceRole):
"""
Someone was the subject of the event.
The meaning of this role depends on the event type. For example, for :py:class:`betty.model.event_type.Marriage`,
the subjects are the people who got married. For :py:class:`betty.model.event_type.Death` it is the person who
died.
"""
[docs]
@final
class Beneficiary(PresenceRole):
"""
Someone was a `benificiary <https://en.wikipedia.org/wiki/Beneficiary>`_ in the event, such as a :py:class:`betty.model.event_type.Will`.
"""
[docs]
@final
class Celebrant(PresenceRole):
"""
Someone was the `celebrant <https://en.wikipedia.org/wiki/Officiant>`_ at the event.
This includes but is not limited to:
- civil servant
- religious leader
- civilian
"""