betty.ancestry package

Submodules

Module contents

Provide Betty’s main data model.

final class betty.ancestry.Ancestry[source]

Bases: MultipleTypesEntityCollection[Entity]

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

__init__()[source]
add_unchecked_graph(*entities: Entity) None[source]

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.ancestry.Citation[source]

Bases: Dated, HasFileReferences, HasPrivacy, HasLinks, UserFacingEntity

A citation (a reference to a source).

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

Dump this instance to JSON-LD.

facts

A bidirectional many-to-many entity type association.

property label: Localizable

The entity’s human-readable label.

async classmethod linked_data_schema(project: Project) Schema[source]

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

location

The human-readable citation location.

classmethod plugin_id() str[source]

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[source]

Get the human-readable short plugin label.

classmethod plugin_label_plural() Localizable[source]

The human-readable entity type label, plural.

source

A bidirectional many-to-one entity type association.

class betty.ancestry.Dated[source]

Bases: LinkedDataDumpable

A resource with date information.

__init__(*args: Any, date: Date | DateRange | None = None, **kwargs: Any)[source]
dated_linked_data_contexts() tuple[str | None, str | None, str | None][source]

Get the JSON-LD context term definition IRIs for the possible dates.

Returns:

A 3-tuple with the IRI for a single date, a start date, and an end date, respectively.

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

Dump this instance to JSON-LD.

async classmethod linked_data_schema(project: Project) Schema[source]

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

class betty.ancestry.Described[source]

Bases: LinkedDataDumpable

A resource with a description.

__init__(*args: Any, description: Mapping[str, str] | str | None = None, **kwargs: Any)[source]
description

The human-readable description.

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

Dump this instance to JSON-LD.

async classmethod linked_data_schema(project: Project) Schema[source]

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

final class betty.ancestry.Enclosure[source]

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)[source]
enclosed_by

The outer place.

encloses

The inner place.

classmethod plugin_id() str[source]

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[source]

Get the human-readable short plugin label.

classmethod plugin_label_plural() Localizable[source]

The human-readable entity type label, plural.

final class betty.ancestry.Event[source]

Bases: Dated, HasFileReferences, HasCitations, HasNotes, Described, HasPrivacy, HasLinks, UserFacingEntity

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: Mapping[str, str] | str | None = None)[source]
dated_linked_data_contexts() tuple[str | None, str | None, str | None][source]

Get the JSON-LD context term definition IRIs for the possible dates.

Returns:

A 3-tuple with the IRI for a single date, a start date, and an end date, respectively.

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

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) Schema[source]

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

place

The place the event happened.

classmethod plugin_id() str[source]

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[source]

Get the human-readable short plugin label.

classmethod plugin_label_plural() Localizable[source]

The human-readable entity type label, plural.

presences

A bidirectional one-to-many entity type association.

final class betty.ancestry.File[source]

Bases: Described, HasPrivacy, HasLinks, 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: ShorthandStaticTranslations | 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)[source]
async dump_linked_data(project: Project) DumpMapping[Dump][source]

Dump this instance to JSON-LD.

property label: Localizable

The entity’s human-readable label.

async classmethod linked_data_schema(project: Project) Schema[source]

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[source]

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[source]

Get the human-readable short plugin label.

classmethod plugin_label_plural() Localizable[source]

The human-readable entity type label, plural.

referees

A bidirectional one-to-many entity type association.

class betty.ancestry.FileReference[source]

Bases: Entity

A reference between betty.ancestry.HasFileReferences and betty.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)[source]
file

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[source]

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[source]

Get the human-readable short plugin label.

classmethod plugin_label_plural() Localizable[source]

The human-readable entity type label, plural.

referee

The entity that references the file.

class betty.ancestry.HasCitations[source]

Bases: Entity

An entity with citations that support it.

__init__(*args: Any, citations: Iterable[Citation] | None = None, **kwargs: Any)[source]
citations

A bidirectional many-to-many entity type association.

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

Dump this instance to JSON-LD.

async classmethod linked_data_schema(project: Project) Schema[source]

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

class betty.ancestry.HasFileReferences[source]

Bases: Entity

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

__init__(*args: Any, file_references: Iterable[FileReference] | None = None, **kwargs: Any)[source]
file_references

A bidirectional one-to-many entity type association.

Bases: Entity

A resource that has external links.

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

Dump this instance to JSON-LD.

async classmethod linked_data_schema(project: Project) Schema[source]

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

The extenal links.

class betty.ancestry.HasLocale[source]

Bases: Localized, LinkedDataDumpable

A resource that is localized, e.g. contains information in a specific locale.

__init__(*args: Any, locale: str = 'und', **kwargs: Any)[source]
async dump_linked_data(project: Project) DumpMapping[Dump][source]

Dump this instance to JSON-LD.

async classmethod linked_data_schema(project: Project) Schema[source]

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

property locale: str

The locale the data in this instance is in.

class betty.ancestry.HasMediaType[source]

Bases: LinkedDataDumpable

A resource with an IANA media type.

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

Dump this instance to JSON-LD.

async classmethod linked_data_schema(project: Project) Schema[source]

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

class betty.ancestry.HasNotes[source]

Bases: Entity

An entity that has notes associated with it.

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

Dump this instance to JSON-LD.

async classmethod linked_data_schema(project: Project) Schema[source]

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

notes

A bidirectional one-to-many entity type association.

class betty.ancestry.HasPrivacy[source]

Bases: LinkedDataDumpable

A resource that has privacy.

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

Dump this instance to JSON-LD.

async classmethod linked_data_schema(project: Project) Schema[source]

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.ancestry.HasPrivacy.privacy and ignores computed privacies.

For access control and permissions checking, use betty.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.

Bases: HasMediaType, HasLocale, Described, LinkedDataDumpable

An external link.

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

Dump this instance to JSON-LD.

label

The link’s human-readable label.

async classmethod linked_data_schema(project: Project) Schema[source]

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

class betty.ancestry.LinkCollectionSchema[source]

Bases: ArraySchema

A JSON Schema for betty.ancestry.Link collections.

__init__()[source]
class betty.ancestry.LinkSchema[source]

Bases: Schema

A JSON Schema for betty.ancestry.Link.

__init__()[source]
final class betty.ancestry.Name[source]

Bases: Dated, StaticTranslationsLocalizable

A name.

A name can be translated, and have a date expressing the period the name was in use.

__init__(translations: Mapping[str, str] | str, *, date: Date | DateRange | None = None)[source]
Parameters:

translations – Keys are locales, values are translations.

final class betty.ancestry.Note[source]

Bases: UserFacingEntity, HasPrivacy, HasLinks, Entity

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

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

Dump this instance to JSON-LD.

entity

The entity the note belongs to.

property label: Localizable

The entity’s human-readable label.

async classmethod linked_data_schema(project: Project) Schema[source]

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

classmethod plugin_id() str[source]

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[source]

Get the human-readable short plugin label.

classmethod plugin_label_plural() Localizable[source]

The human-readable entity type label, plural.

text

The human-readable note text.

final class betty.ancestry.Person[source]

Bases: HasFileReferences, HasCitations, HasNotes, HasLinks, 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)[source]
property ancestors: Iterator[Person]

All ancestors.

children

A bidirectional many-to-many entity type association.

property descendants: Iterator[Person]

All descendants.

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

Dump this instance to JSON-LD.

property label: Localizable

The entity’s human-readable label.

async classmethod linked_data_schema(project: Project) Schema[source]

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

names

A bidirectional one-to-many entity type association.

parents

A bidirectional many-to-many entity type association.

classmethod plugin_id() str[source]

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[source]

Get the human-readable short plugin label.

classmethod plugin_label_plural() Localizable[source]

The human-readable entity type label, plural.

presences

A bidirectional one-to-many entity type association.

property siblings: Iterator[Person]

All siblings.

final class betty.ancestry.PersonName[source]

Bases: HasLocale, HasCitations, HasPrivacy, Entity

A name for a betty.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 = 'und')[source]
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][source]

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) Schema[source]

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

person

The person whose name this is.

classmethod plugin_id() str[source]

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[source]

Get the human-readable short plugin label.

classmethod plugin_label_plural() Localizable[source]

The human-readable entity type label, plural.

final class betty.ancestry.Place[source]

Bases: HasLinks, 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: MutableSequence[Name] | 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)[source]
property coordinates: Point | None

The place’s coordinates.

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

Dump this instance to JSON-LD.

enclosed_by

A bidirectional one-to-many entity type association.

encloses

A bidirectional one-to-many entity type association.

events

A bidirectional one-to-many entity type association.

property label: Localizable

The entity’s human-readable label.

async classmethod linked_data_schema(project: Project) Schema[source]

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

property names: MutableSequence[Name]

The place’s names.

The first name is considered the place label.

classmethod plugin_id() str[source]

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[source]

Get the human-readable short plugin label.

classmethod plugin_label_plural() Localizable[source]

The human-readable entity type label, plural.

property walk_encloses: Iterator[Enclosure]

All enclosed places.

final class betty.ancestry.Presence[source]

Bases: HasPrivacy, Entity

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

__init__(person: Person | None, role: PresenceRole, event: Event | None)[source]
event

The event the person was present at.

property label: Localizable

The entity’s human-readable label.

person

The person whose presence is described.

classmethod plugin_id() str[source]

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[source]

Get the human-readable short plugin label.

classmethod plugin_label_plural() Localizable[source]

The human-readable entity type label, plural.

role: PresenceRole

The role the person performed at the event.

class betty.ancestry.Privacy[source]

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.

class betty.ancestry.PrivacySchema[source]

Bases: Schema

A JSON Schema for privacy.

__init__()[source]
final class betty.ancestry.Source[source]

Bases: Dated, HasFileReferences, HasNotes, HasLinks, HasPrivacy, UserFacingEntity, Entity

A source of information.

__init__(name: ShorthandStaticTranslations | None = None, *, id: str | None = None, author: ShorthandStaticTranslations | None = None, publisher: ShorthandStaticTranslations | 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)[source]
author

The human-readable author.

citations

A bidirectional one-to-many entity type association.

contained_by

The source this one is directly contained by.

contains

A bidirectional one-to-many entity type association.

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

Dump this instance to JSON-LD.

property label: Localizable

The entity’s human-readable label.

async classmethod linked_data_schema(project: Project) Schema[source]

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

name

The human-readable source name.

classmethod plugin_id() str[source]

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[source]

Get the human-readable short plugin label.

classmethod plugin_label_plural() Localizable[source]

The human-readable entity type label, plural.

publisher

The human-readable publisher.

property walk_contains: Iterator[Source]

All directly and indirectly contained sources.

betty.ancestry.is_private(target: Any) bool[source]

Check if the given target is private.

betty.ancestry.is_public(target: Any) bool[source]

Check if the given target is public.

betty.ancestry.merge_privacies(*privacies: Privacy | HasPrivacy | None) Privacy[source]

Merge multiple privacies into one.

betty.ancestry.resolve_privacy(privacy: Privacy | HasPrivacy | None) Privacy[source]

Resolve the privacy of a value.