"""
Provide Betty's ancestry event types.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, final
from typing_extensions import override
from betty.ancestry.event_type import EventType
from betty.locale.localizable import _
from betty.locale.localizer import DEFAULT_LOCALIZER
from betty.plugin import ShorthandPluginBase, PluginIdentifier
if TYPE_CHECKING:
from betty.ancestry.person import Person
[docs]
@final
class Unknown(ShorthandPluginBase, EventType):
"""
Describe an event for which no more specific type is known.
"""
_plugin_id = "unknown"
_plugin_label = _("Unknown")
[docs]
class DerivableEventType(EventType):
"""
Any event that that may be updated by the deriver API.
"""
pass # pragma: no cover
[docs]
class CreatableDerivableEventType(DerivableEventType):
"""
Any event type of which the deriver API may create new instances.
"""
[docs]
@classmethod
def may_create(cls, person: Person, lifetime_threshold: int) -> bool:
"""
Whether a new event of this type may be created for the given person.
"""
return True # pragma: no cover
[docs]
class PreBirthEventType(EventType):
"""
Any event that only ever takes place before someone's birth.
"""
[docs]
@override
@classmethod
def comes_before(cls) -> set[PluginIdentifier[EventType]]:
return {Birth} # pragma: no cover
[docs]
class StartOfLifeEventType(EventType):
"""
An event that indicates the start of someone's life.
This includes someone's actual birth, but also other types of events that take place
close to someone's birth and as such are indicators that that person was born around
the time of the start-of-life event.
"""
pass # pragma: no cover
[docs]
class DuringLifeEventType(EventType):
"""
Any event that only ever takes place during someone's life, e.g. after their birth and before their death.
"""
[docs]
@override
@classmethod
def comes_after(cls) -> set[PluginIdentifier[EventType]]:
return {Birth} # pragma: no cover
[docs]
@override
@classmethod
def comes_before(cls) -> set[PluginIdentifier[EventType]]:
return {Death} # pragma: no cover
[docs]
class EndOfLifeEventType(EventType):
"""
An event that indicates the end of someone's life.
This includes someone's actual death, but also other types of events that take place
close to someone's death and as such are indicators that that person died around the
time of the end-of-life event.
"""
pass # pragma: no cover
[docs]
class PostDeathEventType(EventType):
"""
An event that only ever happens after someone's death.
"""
[docs]
@override
@classmethod
def comes_after(cls) -> set[PluginIdentifier[EventType]]:
return {Death} # pragma: no cover
[docs]
@final
class Birth(CreatableDerivableEventType, StartOfLifeEventType, ShorthandPluginBase):
"""
Someone was born.
"""
_plugin_id = "birth"
_plugin_label = _("Birth")
[docs]
@override
@classmethod
def comes_before(cls) -> set[PluginIdentifier[EventType]]:
return {DuringLifeEventType} # pragma: no cover
[docs]
@final
class Baptism(DuringLifeEventType, StartOfLifeEventType, ShorthandPluginBase):
"""
Someone was `baptized <https://en.wikipedia.org/wiki/Baptism>`_.
"""
_plugin_id = "baptism"
_plugin_label = _("Baptism")
[docs]
@final
class BarMitzvah(DuringLifeEventType, StartOfLifeEventType, ShorthandPluginBase):
"""
Someone's `bar mitzvah <https://en.wikipedia.org/wiki/Bar_and_bat_mitzvah>`_ took place.
"""
_plugin_id = "bar-mitzvah"
_plugin_label = _("Bar mitzvah")
[docs]
@final
class BatMitzvah(DuringLifeEventType, StartOfLifeEventType, ShorthandPluginBase):
"""
Someone's `bat mitzvah <https://en.wikipedia.org/wiki/Bar_and_bat_mitzvah>`_ took place.
"""
_plugin_id = "bat-mitzvah"
_plugin_label = _("Bat mitzvah")
[docs]
@final
class Adoption(DuringLifeEventType, ShorthandPluginBase):
"""
Someone was adopted.
"""
_plugin_id = "adoption"
_plugin_label = _("Adoption")
[docs]
@final
class Death(CreatableDerivableEventType, EndOfLifeEventType, ShorthandPluginBase):
"""
Someone died.
"""
_plugin_id = "death"
_plugin_label = _("Death")
[docs]
@override
@classmethod
def comes_after(cls) -> set[PluginIdentifier[EventType]]:
return {DuringLifeEventType} # pragma: no cover
[docs]
@override
@classmethod
def may_create(cls, person: Person, lifetime_threshold: int) -> bool:
from betty.privacy.privatizer import Privatizer
return Privatizer(lifetime_threshold, localizer=DEFAULT_LOCALIZER).has_expired(
person, 1
)
[docs]
class FinalDispositionEventType(
PostDeathEventType, DerivableEventType, EndOfLifeEventType
):
"""
Someone's `final disposition <https://en.wikipedia.org/wiki/Disposal_of_human_corpses>`_ took place.
"""
pass # pragma: no cover
[docs]
@final
class Funeral(FinalDispositionEventType, ShorthandPluginBase):
"""
Someone's funeral took place.
"""
_plugin_id = "funeral"
_plugin_label = _("Funeral")
[docs]
@final
class Cremation(FinalDispositionEventType, ShorthandPluginBase):
"""
Someone was cremated.
"""
_plugin_id = "cremation"
_plugin_label = _("Cremation")
[docs]
@final
class Burial(FinalDispositionEventType, ShorthandPluginBase):
"""
Someone was buried.
"""
_plugin_id = "burial"
_plugin_label = _("Burial")
[docs]
@final
class Will(PostDeathEventType, ShorthandPluginBase):
"""
Someone's `will and testament <https://en.wikipedia.org/wiki/Will_and_testament>`_ came into effect.
"""
_plugin_id = "will"
_plugin_label = _("Will")
[docs]
@final
class Engagement(DuringLifeEventType, ShorthandPluginBase):
"""
People got engaged with the intent to marry.
"""
_plugin_id = "engagement"
_plugin_label = _("Engagement")
[docs]
@override
@classmethod
def comes_before(cls) -> set[PluginIdentifier[EventType]]:
return {Marriage} # pragma: no cover
[docs]
@final
class Marriage(DuringLifeEventType, ShorthandPluginBase):
"""
People were married.
"""
_plugin_id = "marriage"
_plugin_label = _("Marriage")
[docs]
@final
class MarriageAnnouncement(DuringLifeEventType, ShorthandPluginBase):
"""
People's marriage was announced.
"""
_plugin_id = "marriage-announcement"
_plugin_label = _("Announcement of marriage")
[docs]
@override
@classmethod
def comes_before(cls) -> set[PluginIdentifier[EventType]]:
return {Marriage} # pragma: no cover
[docs]
@final
class Divorce(DuringLifeEventType, ShorthandPluginBase):
"""
People were divorced.
"""
_plugin_id = "divorce"
_plugin_label = _("Divorce")
[docs]
@override
@classmethod
def comes_after(cls) -> set[PluginIdentifier[EventType]]:
return {Marriage} # pragma: no cover
[docs]
@final
class DivorceAnnouncement(DuringLifeEventType, ShorthandPluginBase):
"""
People's divorce was announced.
"""
_plugin_id = "divorce-announcement"
_plugin_label = _("Announcement of divorce")
[docs]
@override
@classmethod
def comes_after(cls) -> set[PluginIdentifier[EventType]]:
return {Marriage} # pragma: no cover
[docs]
@override
@classmethod
def comes_before(cls) -> set[PluginIdentifier[EventType]]:
return {Divorce} # pragma: no cover
[docs]
@final
class Residence(DuringLifeEventType, ShorthandPluginBase):
"""
Someone resided/lived in a place.
"""
_plugin_id = "residence"
_plugin_label = _("Residence")
[docs]
@final
class Immigration(DuringLifeEventType, ShorthandPluginBase):
"""
Someone immigrated to a place.
"""
_plugin_id = "immigration"
_plugin_label = _("Immigration")
[docs]
@final
class Emigration(ShorthandPluginBase, DuringLifeEventType):
"""
Someone emigrated from a place.
"""
_plugin_id = "emigration"
_plugin_label = _("Emigration")
[docs]
@final
class Occupation(ShorthandPluginBase, DuringLifeEventType):
"""
Someone's occupation, e.g. their main recurring activity.
This may include employment, education, stay at home parent, etc.
"""
_plugin_id = "occupation"
_plugin_label = _("Occupation")
[docs]
@final
class Retirement(ShorthandPluginBase, DuringLifeEventType):
"""
Someone `retired <https://en.wikipedia.org/wiki/Retirement>`_.
"""
_plugin_id = "retirement"
_plugin_label = _("Retirement")
[docs]
@final
class Correspondence(ShorthandPluginBase, EventType):
"""
People corresponded with each other.
"""
_plugin_id = "correspondence"
_plugin_label = _("Correspondence")
[docs]
@final
class Confirmation(ShorthandPluginBase, DuringLifeEventType):
"""
Someone's `confirmation <https://en.wikipedia.org/wiki/Confirmation>`_ took place.
"""
_plugin_id = "confirmation"
_plugin_label = _("Confirmation")
[docs]
@final
class Missing(ShorthandPluginBase, DuringLifeEventType):
"""
Someone went missing.
"""
_plugin_id = "missing"
_plugin_label = _("Missing")
[docs]
@final
class Conference(ShorthandPluginBase, DuringLifeEventType):
"""
A conference between people took place.
"""
_plugin_id = "conference"
_plugin_label = _("Conference")