"""
Provide Betty's ancestry event types.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
from betty.locale import Str, DEFAULT_LOCALIZER
if TYPE_CHECKING:
from betty.model.ancestry import Person
[docs]
class EventTypeProvider:
@property
def entity_types(self) -> set[type[EventType]]:
raise NotImplementedError(repr(self))
[docs]
class EventType:
def __new__(cls):
raise RuntimeError("Event types cannot be instantiated.")
[docs]
@classmethod
def name(cls) -> str:
raise NotImplementedError(repr(cls))
[docs]
@classmethod
def label(cls) -> Str:
raise NotImplementedError(repr(cls))
[docs]
@classmethod
def comes_before(cls) -> set[type[EventType]]:
return set()
[docs]
@classmethod
def comes_after(cls) -> set[type[EventType]]:
return set()
[docs]
class UnknownEventType(EventType):
[docs]
@classmethod
def name(cls) -> str:
return "unknown"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Unknown")
[docs]
class DerivableEventType(EventType):
pass
[docs]
class CreatableDerivableEventType(DerivableEventType):
[docs]
@classmethod
def may_create(cls, person: Person, lifetime_threshold: int) -> bool:
return True
[docs]
class PreBirthEventType(EventType):
[docs]
@classmethod
def comes_before(cls) -> set[type[EventType]]:
return {Birth}
[docs]
class StartOfLifeEventType(EventType):
pass
[docs]
class DuringLifeEventType(EventType):
[docs]
@classmethod
def comes_after(cls) -> set[type[EventType]]:
return {Birth}
[docs]
@classmethod
def comes_before(cls) -> set[type[EventType]]:
return {Death}
[docs]
class EndOfLifeEventType(EventType):
pass
[docs]
class PostDeathEventType(EventType):
[docs]
@classmethod
def comes_after(cls) -> set[type[EventType]]:
return {Death}
[docs]
class Birth(CreatableDerivableEventType, StartOfLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "birth"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Birth")
[docs]
@classmethod
def comes_before(cls) -> set[type[EventType]]:
return {DuringLifeEventType}
[docs]
class Baptism(DuringLifeEventType, StartOfLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "baptism"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Baptism")
[docs]
class Adoption(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "adoption"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Adoption")
[docs]
class Death(CreatableDerivableEventType, EndOfLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "death"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Death")
[docs]
@classmethod
def comes_after(cls) -> set[type[EventType]]:
return {DuringLifeEventType}
[docs]
@classmethod
def may_create(cls, person: Person, lifetime_threshold: int) -> bool:
from betty.privatizer import Privatizer
return Privatizer(lifetime_threshold, localizer=DEFAULT_LOCALIZER).has_expired(
person, 1
)
[docs]
class FinalDispositionEventType(
PostDeathEventType, DerivableEventType, EndOfLifeEventType
):
pass
[docs]
class Funeral(FinalDispositionEventType):
[docs]
@classmethod
def name(cls) -> str:
return "funeral"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Funeral")
[docs]
class Cremation(FinalDispositionEventType):
[docs]
@classmethod
def name(cls) -> str:
return "cremation"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Cremation")
[docs]
class Burial(FinalDispositionEventType):
[docs]
@classmethod
def name(cls) -> str:
return "burial"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Burial")
[docs]
class Will(PostDeathEventType):
[docs]
@classmethod
def name(cls) -> str:
return "will"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Will")
[docs]
class Engagement(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "engagement"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Engagement")
[docs]
@classmethod
def comes_before(cls) -> set[type[EventType]]:
return {Marriage}
[docs]
class Marriage(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "marriage"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Marriage")
[docs]
class MarriageAnnouncement(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "marriage-announcement"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Announcement of marriage")
[docs]
@classmethod
def comes_before(cls) -> set[type[EventType]]:
return {Marriage}
[docs]
class Divorce(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "divorce"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Divorce")
[docs]
@classmethod
def comes_after(cls) -> set[type[EventType]]:
return {Marriage}
[docs]
class DivorceAnnouncement(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "divorce-announcement"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Announcement of divorce")
[docs]
@classmethod
def comes_after(cls) -> set[type[EventType]]:
return {Marriage}
[docs]
@classmethod
def comes_before(cls) -> set[type[EventType]]:
return {Divorce}
[docs]
class Residence(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "residence"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Residence")
[docs]
class Immigration(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "immigration"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Immigration")
[docs]
class Emigration(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "emigration"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Emigration")
[docs]
class Occupation(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "occupation"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Occupation")
[docs]
class Retirement(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "retirement"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Retirement")
[docs]
class Correspondence(EventType):
[docs]
@classmethod
def name(cls) -> str:
return "correspondence"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Correspondence")
[docs]
class Confirmation(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "confirmation"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Confirmation")
[docs]
class Missing(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "missing"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Missing")
[docs]
class Conference(DuringLifeEventType):
[docs]
@classmethod
def name(cls) -> str:
return "conference"
[docs]
@classmethod
def label(cls) -> Str:
return Str._("Conference")