Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
61fd0be
Always return a GrampsID of the correct type
stevenyoungs Feb 6, 2025
47f28d0
Always return a generator for DummyDb.iter_<object> methods
stevenyoungs Feb 6, 2025
8fa04f4
Remove unneeded assignment to None
stevenyoungs Feb 6, 2025
59a625b
Explicit type hint not required once get_default_person has type hints
stevenyoungs Feb 6, 2025
eff6d70
Always return a generator from ProxyDbBase.iter_<object>_handles methods
stevenyoungs Feb 6, 2025
c8cc6c4
Cast object to the correct type
stevenyoungs Feb 6, 2025
b904813
Fix comment spelling
stevenyoungs Feb 6, 2025
3b70e1b
Rename the val parameter to gramps_id for consistency
stevenyoungs Feb 6, 2025
7ca418c
Rename the val parameter to name for clarity
stevenyoungs Feb 6, 2025
94942bb
get_<object>_from_handle now raises an error instead of returning None
stevenyoungs Feb 7, 2025
a974af1
return a generator from FilterProxyDb iter_<object>_handles and iter_…
stevenyoungs Feb 7, 2025
3fe2a9e
Define ProxyDbBase predicate methods with the correct type
stevenyoungs Feb 8, 2025
2408042
separate gfilter into two versions
stevenyoungs Feb 8, 2025
601ac7c
Use a consistent type for restricted_to
stevenyoungs Feb 8, 2025
631bda7
Use consistent return types from find_backlink_handles
stevenyoungs Feb 8, 2025
1aa1d03
cast result of find_backlink_handles as only Family classes are inclu…
stevenyoungs Feb 8, 2025
347086c
Adjust comment to match code
stevenyoungs Feb 8, 2025
be80836
DBAPI._get_raw_from_id_data: raise an error instead of returning None
stevenyoungs Feb 8, 2025
98cb987
PERFORMANCE: use has_citation_handle not get_raw_citation_data to che…
stevenyoungs Feb 8, 2025
03a9bc0
Check the handle is valid before trying to get the raw data
stevenyoungs Feb 8, 2025
6446e07
__find_primary_from_handle no longer uses get_raw_obj_from_handle to …
stevenyoungs Feb 9, 2025
39b5913
Fix typo in comment
stevenyoungs Feb 9, 2025
3cc4c95
Explictly return None from DummyDB.get_<object>_from_gramps_id
stevenyoungs Feb 9, 2025
961ec37
Add undo_reference and undo_data methods to DbGeneric
stevenyoungs Feb 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gramps/gen/db/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def close(self):

def db_has_bm_changes(self):
"""
Return whethere there were bookmark changes during the session.
Return whether there were bookmark changes during the session.
"""
raise NotImplementedError

Expand Down
70 changes: 40 additions & 30 deletions gramps/gen/db/dummydb.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def find_backlink_handles(self, handle, include_classes=None):
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle)
return []
yield from ()

def find_initial_person(self):
"""
Expand All @@ -252,7 +252,7 @@ def find_next_event_gramps_id(self):
"""
if not self.db_is_open:
LOG.debug("database is closed")
return ""
return EventGrampsID("")

def find_next_family_gramps_id(self):
"""
Expand All @@ -261,7 +261,7 @@ def find_next_family_gramps_id(self):
"""
if not self.db_is_open:
LOG.debug("database is closed")
return ""
return FamilyGrampsID("")

def find_next_note_gramps_id(self):
"""
Expand All @@ -270,7 +270,7 @@ def find_next_note_gramps_id(self):
"""
if not self.db_is_open:
LOG.debug("database is closed")
return ""
return NoteGrampsID("")

def find_next_media_gramps_id(self):
"""
Expand All @@ -279,7 +279,7 @@ def find_next_media_gramps_id(self):
"""
if not self.db_is_open:
LOG.debug("database is closed")
return ""
return MediaGrampsID("")

def find_next_person_gramps_id(self):
"""
Expand All @@ -288,7 +288,7 @@ def find_next_person_gramps_id(self):
"""
if not self.db_is_open:
LOG.debug("database is closed")
return ""
return PersonGrampsID("")

def find_next_place_gramps_id(self):
"""
Expand All @@ -297,7 +297,7 @@ def find_next_place_gramps_id(self):
"""
if not self.db_is_open:
LOG.debug("database is closed")
return ""
return PlaceGrampsID("")

def find_next_repository_gramps_id(self):
"""
Expand All @@ -306,7 +306,7 @@ def find_next_repository_gramps_id(self):
"""
if not self.db_is_open:
LOG.debug("database is closed")
return ""
return RepositoryGrampsID("")

def find_next_source_gramps_id(self):
"""
Expand All @@ -315,7 +315,7 @@ def find_next_source_gramps_id(self):
"""
if not self.db_is_open:
LOG.debug("database is closed")
return ""
return SourceGrampsID("")

def get_bookmarks(self):
"""
Expand Down Expand Up @@ -373,6 +373,7 @@ def get_event_from_gramps_id(self, gramps_id):
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("gramps_id %s does not exist in the dummy database", gramps_id)
return None

def get_event_from_handle(self, handle):
"""
Expand All @@ -383,6 +384,7 @@ def get_event_from_handle(self, handle):
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError(f"Handle {handle} not found")

def get_event_handles(self):
"""
Expand Down Expand Up @@ -462,6 +464,7 @@ def get_family_from_gramps_id(self, gramps_id):
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("gramps_id %s does not exist in the dummy database", gramps_id)
return None

def get_family_from_handle(self, handle):
"""
Expand Down Expand Up @@ -603,6 +606,7 @@ def get_note_from_gramps_id(self, gramps_id):
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("gramps_id %s does not exist in the dummy database", gramps_id)
return None

def get_note_from_handle(self, handle):
"""
Expand Down Expand Up @@ -722,6 +726,7 @@ def get_media_from_gramps_id(self, gramps_id):
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("gramps_id %s does not exist in the dummy database", gramps_id)
return None

def get_media_from_handle(self, handle):
"""
Expand Down Expand Up @@ -768,6 +773,7 @@ def get_person_from_gramps_id(self, gramps_id):
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("gramps_id %s does not exist in the dummy database", gramps_id)
return None

def get_person_from_handle(self, handle):
"""
Expand Down Expand Up @@ -828,6 +834,7 @@ def get_place_from_gramps_id(self, gramps_id):
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("gramps_id %s does not exist in the dummy database", gramps_id)
return None

def get_place_from_handle(self, handle):
"""
Expand Down Expand Up @@ -969,6 +976,7 @@ def get_repository_from_gramps_id(self, gramps_id):
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("gramps_id %s does not exist in the dummy database", gramps_id)
return None

def get_repository_from_handle(self, handle):
"""
Expand Down Expand Up @@ -1039,6 +1047,7 @@ def get_source_from_gramps_id(self, gramps_id):
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("gramps_id %s does not exist in the dummy database", gramps_id)
return None

def get_source_from_handle(self, handle):
"""
Expand Down Expand Up @@ -1099,6 +1108,7 @@ def get_citation_from_gramps_id(self, gramps_id):
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("gramps_id %s does not exist in the dummy database", gramps_id)
return None

def get_citation_from_handle(self, handle):
"""
Expand Down Expand Up @@ -1152,15 +1162,15 @@ def get_tag_from_handle(self, handle):
LOG.warning("handle %s does not exist in the dummy database", handle)
raise HandleError(f"Handle {handle} not found")

def get_tag_from_name(self, val):
def get_tag_from_name(self, name):
"""
Find a Tag in the database from the passed Tag name.

If no such Tag exists, None is returned.
"""
if not self.db_is_open:
LOG.debug("database is closed")
LOG.warning("tag name %s does not exist in the dummy database", val)
LOG.warning("tag name %s does not exist in the dummy database", name)

def get_tag_handles(self, sort_handles=False, locale=glocale):
"""
Expand Down Expand Up @@ -1286,151 +1296,151 @@ def iter_citations(self):
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_event_handles(self):
"""
Return an iterator over handles for Events in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_events(self):
"""
Return an iterator over objects for Events in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_families(self):
"""
Return an iterator over objects for Families in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_family_handles(self):
"""
Return an iterator over handles for Families in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_media_handles(self):
"""
Return an iterator over handles for Media in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_media(self):
"""
Return an iterator over objects for Medias in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_note_handles(self):
"""
Return an iterator over handles for Notes in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_notes(self):
"""
Return an iterator over objects for Notes in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_people(self):
"""
Return an iterator over objects for Persons in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_person_handles(self):
"""
Return an iterator over handles for Persons in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_place_handles(self):
"""
Return an iterator over handles for Places in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_places(self):
"""
Return an iterator over objects for Places in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_repositories(self):
"""
Return an iterator over objects for Repositories in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_repository_handles(self):
"""
Return an iterator over handles for Repositories in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_source_handles(self):
"""
Return an iterator over handles for Sources in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_sources(self):
"""
Return an iterator over objects for Sources in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_tag_handles(self):
"""
Return an iterator over handles for Tags in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def iter_tags(self):
"""
Return an iterator over objects for Tags in the database
"""
if not self.db_is_open:
LOG.debug("database is closed")
return []
yield from ()

def load(
self,
Expand Down
16 changes: 14 additions & 2 deletions gramps/gen/db/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,7 @@ def commit_person(self, person, transaction, change_time=None):
self.origin_types.update(
[str(surn.origintype) for surn in all_surn if surn.origintype.is_custom()]
)
all_surn = None

self.url_types.update(
[str(url.type) for url in person.urls if url.type.is_custom()]
)
Expand Down Expand Up @@ -2684,7 +2684,19 @@ def db_has_bm_changes(self):
def get_undodb(self):
return self.undodb

def undo(self, update_history=True):
def undo_reference(self, data, handle: AnyHandle):
"""
Helper method to undo a reference map entry
"""
raise NotImplementedError

def undo_data(self, data, handle: AnyHandle, obj_key):
"""
Helper method to undo/redo the changes made
"""
raise NotImplementedError

def undo(self, update_history: bool = True):
return self.undodb.undo(update_history)

def redo(self, update_history=True):
Expand Down
Loading