Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.model.ancestry module

Provide Betty’s main data model.

final class betty.model.ancestry.Ancestry

  Bases: `MultipleTypesEntityCollection`[`Entity`]

  An ancestry contains all the entities of a single family tree/genealogical data set.

  __init__()
  add_unchecked_graph(*entities: Entity) → None

    Add entities to the ancestry but do not automatically add associates as well.

    It is the caller’s responsibility to ensure all associates are added to the ancestry. If this is done, calling this method is faster than the usual entity collection methods.

final class betty.model.ancestry.Citation

  Bases: `Dated`, `HasFileReferences`, `HasPrivacy`, `HasLinksEntity`, `UserFacingEntity`, `Entity`

  A citation (a reference to a source).

  __init__(*, id: str | None = None, facts: Iterable[HasCitations] | None = None, source: Source | None = None, location: Localizable | None = None, date: Date | DateRange | None = None, file_references: Iterable[FileReference] | None = None, privacy: Privacy | None = None, public: bool | None = None, private: bool | None = None)
  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  property facts: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

  property label: Localizable

    The entity’s human-readable label.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  classmethod plugin_id() → str

    Get the plugin ID.

    IDs are unique per plugin type:

    - A plugin repository MUST at most have a single plugin for any ID.

    - Different plugin repositories MAY each have a plugin with the same ID.

  classmethod plugin_label() → Localizable

    Get the human-readable short plugin label.

  classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

  property source: _AssociateT & Entity | None

    Get the associate from the given owner.

class betty.model.ancestry.Dated

  Bases: `LinkedDataDumpable`

  A resource with date information.

  __init__(*args: Any, date: Date | DateRange | None = None, **kwargs: Any)
  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

class betty.model.ancestry.Described

  Bases: `LinkedDataDumpable`

  A resource with a description.

  __init__(*args: Any, description: str | None = None, **kwargs: Any)
  description: str | None

    The human-readable description.

  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

final class betty.model.ancestry.Enclosure

  Bases: `Dated`, `HasCitations`, `Entity`

  The enclosure of one place by another.

  Enclosures describe the outer (``enclosed_by`) and inner(``encloses`) places, and their relationship.

  __init__(encloses: Place | None = None, enclosed_by: Place | None = None)
  property enclosed_by: _AssociateT & Entity | None

    The outer place.

  property encloses: _AssociateT & Entity | None

    The inner place.

  classmethod plugin_id() → str

    Get the plugin ID.

    IDs are unique per plugin type:

    - A plugin repository MUST at most have a single plugin for any ID.

    - Different plugin repositories MAY each have a plugin with the same ID.

  classmethod plugin_label() → Localizable

    Get the human-readable short plugin label.

  classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

final class betty.model.ancestry.Event

  Bases: `Dated`, `HasFileReferences`, `HasCitations`, `HasNotes`, `Described`, `HasPrivacy`, `HasLinksEntity`, `UserFacingEntity`, `Entity`

  An event that took place.

  __init__(*, id: str | None = None, event_type: EventType | None = None, date: Date | DateRange | None = None, file_references: Iterable[FileReference] | None = None, citations: Iterable[Citation] | None = None, notes: Iterable[Note] | None = None, privacy: Privacy | None = None, public: bool | None = None, private: bool | None = None, place: Place | None = None, description: str | None = None)
  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  property event_type: EventType

    The type of event.

  property label: Localizable

    The entity’s human-readable label.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  property place: _AssociateT & Entity | None

    The place the event happened.

  classmethod plugin_id() → str

    Get the plugin ID.

    IDs are unique per plugin type:

    - A plugin repository MUST at most have a single plugin for any ID.

    - Different plugin repositories MAY each have a plugin with the same ID.

  classmethod plugin_label() → Localizable

    Get the human-readable short plugin label.

  classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

  property presences: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

final class betty.model.ancestry.File

  Bases: `Described`, `HasPrivacy`, `HasLinksEntity`, `HasMediaType`, `HasNotes`, `HasCitations`, `UserFacingEntity`, `Entity`

  A file on disk.

  This includes but is not limited to:

  - images

  - video

  - audio

  - PDF documents

  __init__(path: Path, *, id: str | None = None, name: str | None = None, media_type: MediaType | None = None, description: str | None = None, notes: Iterable[Note] | None = None, citations: Iterable[Citation] | None = None, privacy: Privacy | None = None, public: bool | None = None, private: bool | None = None, links: MutableSequence[Link] | None = None)
  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  property label: Localizable

    The entity’s human-readable label.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  property name: str

    The file name.

  property path: Path

    The file’s path on disk.

  classmethod plugin_id() → str

    Get the plugin ID.

    IDs are unique per plugin type:

    - A plugin repository MUST at most have a single plugin for any ID.

    - Different plugin repositories MAY each have a plugin with the same ID.

  classmethod plugin_label() → Localizable

    Get the human-readable short plugin label.

  classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

  property referees: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

class betty.model.ancestry.FileReference

  Bases: `Entity`

  A reference between `betty.model.ancestry.HasFileReferences` and betty.model.ancestry.File.

  This reference holds additional information specific to the relationship between the two entities.

  __init__(referee: HasFileReferences & Entity | None = None, file: File | None = None, focus: FocusArea | None = None)
  property file: _AssociateT & Entity | None

    The referenced file.

  property focus: FocusArea | None

    The area within the 2-dimensional representation of the file to focus on.

    This can be used to locate where faces are in a photo, or a specific article in a newspaper scan, for example.

  classmethod plugin_id() → MachineName

    Get the plugin ID.

    IDs are unique per plugin type:

    - A plugin repository MUST at most have a single plugin for any ID.

    - Different plugin repositories MAY each have a plugin with the same ID.

  classmethod plugin_label() → Localizable

    Get the human-readable short plugin label.

  classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

  property referee: _AssociateT & Entity | None

    The entity that references the file.

class betty.model.ancestry.HasCitations

  Bases: `LinkedDataDumpable`

  An entity with citations that support it.

  __init__(*args: Any, citations: Iterable[Citation] | None = None, **kwargs: Any)
  property citations: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

class betty.model.ancestry.HasFileReferences

  Bases: `object`

  An entity that has associated `betty.model.ancestry.File` entities.

  __init__(*args: Any, file_references: Iterable[FileReference] | None = None, **kwargs: Any)
  property file_references: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

class betty.model.ancestry.HasLinks

  Bases: `LinkedDataDumpable`

  A resource that has external links.

  __init__(*args: Any, links: MutableSequence[Link] | None = None, **kwargs: Any)
  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  property links: MutableSequence[Link]

    The extenal links.

class betty.model.ancestry.HasLinksEntity

  Bases: `HasLinks`

  An entity that has external links.

  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

class betty.model.ancestry.HasMediaType

  Bases: `LinkedDataDumpable`

  A resource with an IANA media type.

  __init__(*args: Any, media_type: MediaType | None = None, **kwargs: Any)
  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

class betty.model.ancestry.HasNotes

  Bases: `LinkedDataDumpable`

  An entity that has notes associated with it.

  __init__(*args: Any, notes: Iterable[Note] | None = None, **kwargs: Any)
  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  property notes: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

class betty.model.ancestry.HasPrivacy

  Bases: `LinkedDataDumpable`

  A resource that has privacy.

  __init__(*args: Any, privacy: Privacy | None = None, public: bool | None = None, private: bool | None = None, **kwargs: Any)
  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  property own_privacy: Privacy

    The resource’s own privacy.

    This returns the value that was set for `betty.model.ancestry.HasPrivacy.privacy` and ignores computed privacies.

    For access control and permissions checking, use `betty.model.ancestry.HasPrivacy.privacy`.

  property privacy: Privacy

    The resource’s privacy.

  property private: bool

    Whether this resource is private.

  property public: bool

    Whether this resource is public.

final class betty.model.ancestry.Link

  Bases: `HasMediaType`, `Localized`, `Described`, `LinkedDataDumpable`

  An external link.

  __init__(url: str, *, relationship: str | None = None, label: str | None = None, description: str | None = None, media_type: MediaType | None = None, locale: str | None = None)
  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  label: str | None

    The link’s human-readable label.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  relationship: str | None

    The link’s IANA link relationship.

  url: str

    The link’s absolute URL

final class betty.model.ancestry.Note

  Bases: `UserFacingEntity`, `HasPrivacy`, `HasLinksEntity`, `Entity`

  A note is a bit of textual information that can be associated with another entity.

  __init__(text: str, *, id: str | None = None, entity: HasNotes | None = None, privacy: Privacy | None = None, public: bool | None = None, private: bool | None = None)
  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  property entity: _AssociateT & Entity | None

    The entity the note belongs to.

  property label: Localizable

    The entity’s human-readable label.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  classmethod plugin_id() → str

    Get the plugin ID.

    IDs are unique per plugin type:

    - A plugin repository MUST at most have a single plugin for any ID.

    - Different plugin repositories MAY each have a plugin with the same ID.

  classmethod plugin_label() → Localizable

    Get the human-readable short plugin label.

  classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

  property text: str

    The note’s human-readable text.

final class betty.model.ancestry.Person

  Bases: `HasFileReferences`, `HasCitations`, `HasNotes`, `HasLinksEntity`, `HasPrivacy`, `UserFacingEntity`, `Entity`

  A person.

  __init__(*, id: str | None = None, file_references: Iterable[FileReference] | None = None, citations: Iterable[Citation] | None = None, links: MutableSequence[Link] | None = None, notes: Iterable[Note] | None = None, privacy: Privacy | None = None, public: bool | None = None, private: bool | None = None, parents: Iterable[Person] | None = None, children: Iterable[Person] | None = None, presences: Iterable[Presence] | None = None, names: Iterable[PersonName] | None = None)
  property ancestors: Iterator[Person]

    All ancestors.

  property children: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

  property descendants: Iterator[Person]

    All descendants.

  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  property label: Localizable

    The entity’s human-readable label.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  property names: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

  property parents: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

  classmethod plugin_id() → str

    Get the plugin ID.

    IDs are unique per plugin type:

    - A plugin repository MUST at most have a single plugin for any ID.

    - Different plugin repositories MAY each have a plugin with the same ID.

  classmethod plugin_label() → Localizable

    Get the human-readable short plugin label.

  classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

  property presences: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

  property siblings: list[Person]

    All siblings.

final class betty.model.ancestry.PersonName

  Bases: `Localized`, `HasCitations`, `HasPrivacy`, `Entity`

  A name for a `betty.model.ancestry.Person`.

  __init__(*, id: str | None = None, person: Person | None = None, individual: str | None = None, affiliation: str | None = None, privacy: Privacy | None = None, public: bool | None = None, private: bool | None = None, locale: str | None = None)
  property affiliation: str | None

    The name’s affiliation, or family component.

    Also known as:

    - last name

    - surname

  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  property individual: str | None

    The name’s individual component.

    Also known as:

    - first name

    - given name

  property label: Localizable

    The entity’s human-readable label.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  property person: _AssociateT & Entity | None

    The person whose name this is.

  classmethod plugin_id() → str

    Get the plugin ID.

    IDs are unique per plugin type:

    - A plugin repository MUST at most have a single plugin for any ID.

    - Different plugin repositories MAY each have a plugin with the same ID.

  classmethod plugin_label() → Localizable

    Get the human-readable short plugin label.

  classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

final class betty.model.ancestry.Place

  Bases: `HasLinksEntity`, `HasFileReferences`, `HasNotes`, `HasPrivacy`, `UserFacingEntity`, `Entity`

  A place.

  A place is a physical location on earth. It may be identifiable by GPS coordinates only, or be a well-known city, with names in many languages, imagery, and its own Wikipedia page, or any type of place in between.

  __init__(*, id: str | None = None, names: list[PlaceName] | None = None, events: Iterable[Event] | None = None, enclosed_by: Iterable[Enclosure] | None = None, encloses: Iterable[Enclosure] | None = None, notes: Iterable[Note] | None = None, coordinates: Point | None = None, links: MutableSequence[Link] | None = None, privacy: Privacy | None = None, public: bool | None = None, private: bool | None = None)
  property coordinates: Point | None

    The place’s coordinates.

  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  property enclosed_by: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

  property encloses: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

  property events: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

  property label: Localizable

    The entity’s human-readable label.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  property names: list[PlaceName]

    The place’s names.

  classmethod plugin_id() → str

    Get the plugin ID.

    IDs are unique per plugin type:

    - A plugin repository MUST at most have a single plugin for any ID.

    - Different plugin repositories MAY each have a plugin with the same ID.

  classmethod plugin_label() → Localizable

    Get the human-readable short plugin label.

  classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

  property walk_encloses: Iterator[Enclosure]

    All enclosed places.

final class betty.model.ancestry.PlaceName

  Bases: `Localized`, `Dated`, `LinkedDataDumpable`

  A place name.

  A name has a locale and a date during which the name was in use.

  __init__(name: str, *, locale: str | None = None, date: Date | DateRange | None = None)
  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  property name: str

    The human-readable name.

final class betty.model.ancestry.Presence

  Bases: `HasPrivacy`, `Entity`

  The presence of a `betty.model.ancestry.Person` at an `betty.model.ancestry.Event`.

  __init__(person: Person | None, role: PresenceRole, event: Event | None)
  property event: _AssociateT & Entity | None

    The event the person was present at.

  property label: Localizable

    The entity’s human-readable label.

  property person: _AssociateT & Entity | None

    The person whose presence is described.

  classmethod plugin_id() → str

    Get the plugin ID.

    IDs are unique per plugin type:

    - A plugin repository MUST at most have a single plugin for any ID.

    - Different plugin repositories MAY each have a plugin with the same ID.

  classmethod plugin_label() → Localizable

    Get the human-readable short plugin label.

  classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

  role: PresenceRole

    The role the person performed at the event.

class betty.model.ancestry.Privacy

  Bases: `Enum`

  The available privacy modes.

  PRIVATE = 2

    The resource is explicitly made private.

  PUBLIC = 1

    The resource is explicitly made public.

  UNDETERMINED = 3

    The resource has no explicit privacy. This means that:

    - it may be changed at will

    - when checking access, UNDETERMINED evaluates to PUBLIC.

final class betty.model.ancestry.Source

  Bases: `Dated`, `HasFileReferences`, `HasNotes`, `HasLinksEntity`, `HasPrivacy`, `UserFacingEntity`, `Entity`

  A source of information.

  __init__(name: str | None = None, *, id: str | None = None, author: str | None = None, publisher: str | None = None, contained_by: Source | None = None, contains: Iterable[Source] | None = None, notes: Iterable[Note] | None = None, date: Datey | None = None, file_references: Iterable[FileReference] | None = None, links: MutableSequence[Link] | None = None, privacy: Privacy | None = None, public: bool | None = None, private: bool | None = None)
  property citations: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

  property contained_by: _AssociateT & Entity | None

    The source this one is directly contained by.

  property contains: EntityCollection[_AssociateT & Entity]

    Get the associates from the given owner.

  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  property label: Localizable

    The entity’s human-readable label.

  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  classmethod plugin_id() → str

    Get the plugin ID.

    IDs are unique per plugin type:

    - A plugin repository MUST at most have a single plugin for any ID.

    - Different plugin repositories MAY each have a plugin with the same ID.

  classmethod plugin_label() → Localizable

    Get the human-readable short plugin label.

  classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

  property walk_contains: Iterator[Source]

    All directly and indirectly contained sources.

betty.model.ancestry.is_private(target: Any) → bool

  Check if the given target is private.

betty.model.ancestry.is_public(target: Any) → bool

  Check if the given target is public.

betty.model.ancestry.merge_privacies(*privacies: Privacy | HasPrivacy | None) → Privacy

  Merge multiple privacies into one.

async betty.model.ancestry.ref_link(root_schema: DumpMapping[Dump], project: Project) → DumpMapping[Dump]

  Reference the Link schema.

async betty.model.ancestry.ref_link_collection(root_schema: DumpMapping[Dump], project: Project) → DumpMapping[Dump]

  Reference the schema for a collection of Link instances.

betty.model.ancestry.ref_media_type(root_schema: MutableMapping[str, bool | int | float | str | None | MutableSequence[bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]] | MutableMapping[str, bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]]]) → MutableMapping[str, bool | int | float | str | None | MutableSequence[bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]] | MutableMapping[str, bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]]]

  Reference the MediaType schema.

betty.model.ancestry.resolve_privacy(privacy: Privacy | HasPrivacy | None) → Privacy

  Resolve the privacy of a value.