betty.gramps.loader module - Betty documentation

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.

  Parameters:

    - entity_type (`betty.gramps.loader.GrampsEntityType`)

    - entity_id (`str`)

  __init__(entity_type: betty.gramps.loader.GrampsEntityType, entity_id: str) → None
    Parameters:

      - entity_type (`betty.gramps.loader.GrampsEntityType`)

      - entity_id (`str`)

  entity_id: `str`
  entity_type: `betty.gramps.loader.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.

  Parameters:

    message (`betty.locale.Localizable`)

exception betty.gramps.loader.GrampsLoadFileError

  Bases: `GrampsError`, `RuntimeError`

  An error occurred when loading a Gramps family tree file.

  Parameters:

    message (`betty.locale.Localizable`)

class betty.gramps.loader.GrampsLoader

  Bases: `object`

  Load Gramps family history data into a project.

  Parameters:

    - project_or_ancestry (`betty.project.Project` | `betty.model.ancestry.Ancestry`)

    - localizer (`betty.locale.Localizer`)

  __init__(project_or_ancestry: betty.project.Project | betty.model.ancestry.Ancestry, *, localizer: betty.locale.Localizer)
    Parameters:

      - project_or_ancestry (`betty.project.Project` | `betty.model.ancestry.Ancestry`)

      - localizer (`betty.locale.Localizer`)

  add_association(*args: Any, **kwargs: Any) → None

    Add an association between two entities to the ancestry.

    Parameters:

      - args (`typing.Any`)

      - kwargs (`typing.Any`)

    Return type:

      `None`

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

    Add entities to the ancestry.

    Parameters:

      entity (`typing.Union`[`betty.model.Entity`, `betty.model.AliasedEntity`[`betty.model.Entity`]])

    Return type:

      `None`

  async load_file(file_path: pathlib.Path) → None

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

    Parameters:

      file_path (`pathlib.Path`)

    Return type:

      `None`

  async load_gpkg(gpkg_path: pathlib.Path) → None

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

    Parameters:

      gpkg_path (`pathlib.Path`)

    Return type:

      `None`

  async load_gramps(gramps_path: pathlib.Path) → None

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

    Parameters:

      gramps_path (`pathlib.Path`)

    Return type:

      `None`

  async load_tree(tree: xml.etree.ElementTree.ElementTree, gramps_tree_directory_path: pathlib.Path) → None

    Load family history data from a Gramps XML tree.

    Parameters:

      - tree (`xml.etree.ElementTree.ElementTree`)

      - gramps_tree_directory_path (`pathlib.Path`)

    Return type:

      `None`

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

    Load family history data from XML.

    Parameters:

      - xml (`str` | `pathlib.Path`) – The raw XML or the path to an XML file.

      - gramps_tree_directory_path (`pathlib.Path`)

    Return type:

      `None`

exception betty.gramps.loader.XPathError

  Bases: `GrampsError`, `RuntimeError`

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

  Parameters:

    message (`betty.locale.Localizable`)