Skip to content

Commit

Permalink
Remove GrampsLoader's ability to accept an Ancestry instead of a Project
Browse files Browse the repository at this point in the history
  • Loading branch information
bartfeenstra committed Jun 21, 2024
1 parent 4f4e092 commit e08d3cc
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions betty/gramps/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from betty.media_type import MediaType, InvalidMediaType
from betty.model import Entity, EntityGraphBuilder, AliasedEntity, AliasableEntity
from betty.model.ancestry import (
Ancestry,
Note,
File,
Source,
Expand Down Expand Up @@ -79,10 +78,9 @@
Conference,
)
from betty.path import rootname
from betty.project import Project
from betty.warnings import deprecate

if TYPE_CHECKING:
from betty.project import Project
from collections.abc import MutableMapping, Mapping


Expand Down Expand Up @@ -143,21 +141,12 @@ class GrampsLoader:

def __init__(
self,
project_or_ancestry: Project | Ancestry,
project: Project,
*,
localizer: Localizer,
):
super().__init__()
if isinstance(project_or_ancestry, Ancestry):
deprecate(
f"Initializing {type(self)} with {Ancestry} is deprecated as of Betty 0.3.2, and will be removed in Betty 0.4.x. Instead, provide {Project}.",
stacklevel=2,
)
self._ancestry = project_or_ancestry
self._project = None
else:
self._ancestry = project_or_ancestry.ancestry
self._project = project_or_ancestry
self._project = project
self._ancestry_builder = EntityGraphBuilder()
self._added_entity_counts: dict[type[Entity], int] = defaultdict(lambda: 0)
self._tree: ElementTree.ElementTree | None = None
Expand Down Expand Up @@ -345,7 +334,7 @@ async def load_tree(

self._load_families(database)

self._ancestry.add_unchecked_graph(*self._ancestry_builder.build())
self._project.ancestry.add_unchecked_graph(*self._ancestry_builder.build())

def add_entity(self, entity: AliasableEntity[Entity]) -> None:
"""
Expand Down Expand Up @@ -1096,7 +1085,7 @@ def _load_attributes(
) -> Mapping[str, str]:
prefixes = ["betty"]
hash(element)
if self._project is not None and self._project.configuration.name is not None:
if self._project.configuration.name is not None:
prefixes.append(f"betty-{self._project.configuration.name}")
attributes: MutableMapping[str, str] = {}
for prefix in prefixes:
Expand Down

0 comments on commit e08d3cc

Please sign in to comment.