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

# betty.gramps.loader module

Provide an API to load Gramps family trees into Betty ancestries.

class betty.gramps.loader.GrampsEntityReference

  Bases: `object`

  A reference to an entity in a Gramps family tree.

  __init__(entity_type: GrampsEntityType, entity_id: str) → None
  entity_id: str
  entity_type: GrampsEntityType

class betty.gramps.loader.GrampsEntityType

  Bases: `Enum`

  The supported Gramps entity types.

  CITATION = 'citation'
  EVENT = 'event'
  OBJECT = 'object'
  PERSON = 'person'
  SOURCE = 'source'

exception betty.gramps.loader.GrampsFileNotFoundError

  Bases: `GrampsError`, `FileNotFoundError`

  A Gramps family tree file could not be file.

exception betty.gramps.loader.GrampsLoadFileError

  Bases: `GrampsError`, `RuntimeError`

  An error occurred when loading a Gramps family tree file.

class betty.gramps.loader.GrampsLoader

  Bases: `object`

  Load Gramps family history data into a project.

  __init__(project: Project, *, localizer: Localizer)
  add_association(*args: Any, **kwargs: Any) → None

    Add an association between two entities to the ancestry.

  add_entity(entity: Entity | AliasedEntity[Entity]) → None

    Add entities to the ancestry.

  async load_file(file_path: Path) → None

    Load family history data from any of the supported Gramps file types.

  async load_gpkg(gpkg_path: Path) → None

    Load family history data from a Gramps *.gpkg file.

  async load_gramps(gramps_path: Path) → None

    Load family history data from a Gramps *.gramps file.

  async load_tree(tree: ElementTree, gramps_tree_directory_path: Path) → None

    Load family history data from a Gramps XML tree.

  async load_xml(xml: str | Path, gramps_tree_directory_path: Path) → None

    Load family history data from XML.

    Parameters:

      xml – The raw XML or the path to an XML file.

exception betty.gramps.loader.XPathError

  Bases: `GrampsError`, `RuntimeError`

  An error occurred when evaluating an XPath selector on Gramps XML.