Proxy databases:
1. Provide default methods in proxybase.py for get_<object>_handles and iter_<object>_handles 2. Implement callouts in iter_<object>_handles to determine if handles should be included or not 3. Added new methods to dbbase.py raising NotImplementedError for the new iter_<object>_handles methods 4. Implemented new methods in living.py, private.py and referenced.py 5. Changed filter.py to use iter_person_handles instead of get_person_handles 6. Removed duplicate methods from children of ProxyDbBase svn: r12783
This commit is contained in:
parent
01492a1974
commit
56c79b6fa4
@ -608,13 +608,20 @@ class DbBase(object):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def iter_person_handles(self):
|
def get_family_handles(self):
|
||||||
"""
|
"""
|
||||||
Return an iterator over database handles, one handle for each Person in
|
Return a list of database handles, one handle for each Family in
|
||||||
the database. If sort_handles is True, the list is sorted by surnames
|
the database.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def get_event_handles(self):
|
||||||
|
"""
|
||||||
|
Return a list of database handles, one handle for each Event in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_place_handles(self, sort_handles=True):
|
def get_place_handles(self, sort_handles=True):
|
||||||
"""
|
"""
|
||||||
Return a list of database handles, one handle for each Place in
|
Return a list of database handles, one handle for each Place in
|
||||||
@ -638,20 +645,6 @@ class DbBase(object):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_event_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Event in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
def get_family_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Family in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
def get_repository_handles(self):
|
def get_repository_handles(self):
|
||||||
"""
|
"""
|
||||||
Return a list of database handles, one handle for each Repository in
|
Return a list of database handles, one handle for each Repository in
|
||||||
@ -666,6 +659,62 @@ class DbBase(object):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def iter_person_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Person in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def iter_family_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Family in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def iter_event_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Event in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def iter_source_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Source in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def iter_place_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Place in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def iter_media_object_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Media
|
||||||
|
Object in the database.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def iter_repository_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each
|
||||||
|
Repository in the database.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def iter_note_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Note in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_gramps_ids(self, obj_key):
|
def get_gramps_ids(self, obj_key):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@ -51,21 +51,21 @@ class FilterProxyDb(ProxyDbBase):
|
|||||||
|
|
||||||
if person_filter:
|
if person_filter:
|
||||||
self.plist = set(person_filter.apply(
|
self.plist = set(person_filter.apply(
|
||||||
self.db, self.db.get_person_handles(sort_handles=False)))
|
self.db, self.db.iter_person_handles()))
|
||||||
else:
|
else:
|
||||||
self.plist = self.db.get_person_handles(sort_handles=False)
|
self.plist = self.db.iter_person_handles()
|
||||||
|
|
||||||
if event_filter:
|
if event_filter:
|
||||||
self.elist = set(event_filter.apply(
|
self.elist = set(event_filter.apply(
|
||||||
self.db, self.db.get_event_handles()))
|
self.db, self.db.iter_event_handles()))
|
||||||
else:
|
else:
|
||||||
self.elist = self.db.get_event_handles()
|
self.elist = self.db.iter_event_handles()
|
||||||
|
|
||||||
if note_filter:
|
if note_filter:
|
||||||
self.nlist = set(note_filter.apply(
|
self.nlist = set(note_filter.apply(
|
||||||
self.db, self.db.get_note_handles()))
|
self.db, self.db.iter_note_handles()))
|
||||||
else:
|
else:
|
||||||
self.nlist = self.db.get_note_handles()
|
self.nlist = self.db.iter_note_handles()
|
||||||
|
|
||||||
self.flist = set()
|
self.flist = set()
|
||||||
for handle in list(self.plist):
|
for handle in list(self.plist):
|
||||||
@ -284,40 +284,10 @@ class FilterProxyDb(ProxyDbBase):
|
|||||||
def iter_person_handles(self):
|
def iter_person_handles(self):
|
||||||
"""
|
"""
|
||||||
Return an iterator over database handles, one handle for each Person in
|
Return an iterator over database handles, one handle for each Person in
|
||||||
the database. If sort_handles is True, the list is sorted by surnames
|
the database.
|
||||||
"""
|
"""
|
||||||
# FIXME: plist is not a sorted list of handles
|
# FIXME: plist is not a sorted list of handles
|
||||||
return (h for h in self.plist)
|
return self.plist
|
||||||
|
|
||||||
def get_place_handles(self, sort_handles=True):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Place in
|
|
||||||
the database. If sort_handles is True, the list is sorted by
|
|
||||||
Place title.
|
|
||||||
"""
|
|
||||||
return self.db.get_place_handles(sort_handles)
|
|
||||||
|
|
||||||
def iter_place_handles(self):
|
|
||||||
"""
|
|
||||||
Return an iterator database handles, one handle for each Place in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
return self.db.iter_place_handles(sort_handles)
|
|
||||||
|
|
||||||
def get_source_handles(self, sort_handles=True):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Source in
|
|
||||||
the database. If sort_handles is True, the list is sorted by
|
|
||||||
Source title.
|
|
||||||
"""
|
|
||||||
return self.db.get_source_handles(sort_handles)
|
|
||||||
|
|
||||||
def get_media_object_handles(self, sort_handles=True):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each MediaObject in
|
|
||||||
the database. If sort_handles is True, the list is sorted by title.
|
|
||||||
"""
|
|
||||||
return self.db.get_media_object_handles(sort_handles)
|
|
||||||
|
|
||||||
def get_event_handles(self):
|
def get_event_handles(self):
|
||||||
"""
|
"""
|
||||||
@ -333,13 +303,6 @@ class FilterProxyDb(ProxyDbBase):
|
|||||||
"""
|
"""
|
||||||
return list(self.flist)
|
return list(self.flist)
|
||||||
|
|
||||||
def get_repository_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Repository in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
return self.db.get_repository_handles()
|
|
||||||
|
|
||||||
def get_note_handles(self):
|
def get_note_handles(self):
|
||||||
"""
|
"""
|
||||||
Return a list of database handles, one handle for each Note in
|
Return a list of database handles, one handle for each Note in
|
||||||
@ -347,11 +310,6 @@ class FilterProxyDb(ProxyDbBase):
|
|||||||
"""
|
"""
|
||||||
return list(self.nlist)
|
return list(self.nlist)
|
||||||
|
|
||||||
def get_researcher(self):
|
|
||||||
"""returns the Researcher instance, providing information about
|
|
||||||
the owner of the database"""
|
|
||||||
return self.db.get_researcher()
|
|
||||||
|
|
||||||
def get_default_person(self):
|
def get_default_person(self):
|
||||||
"""returns the default Person of the database"""
|
"""returns the default Person of the database"""
|
||||||
person = self.db.get_default_person()
|
person = self.db.get_default_person()
|
||||||
|
@ -212,105 +212,13 @@ class LivingProxyDb(ProxyDbBase):
|
|||||||
"""
|
"""
|
||||||
return self.db.get_note_from_gramps_id(val)
|
return self.db.get_note_from_gramps_id(val)
|
||||||
|
|
||||||
def get_person_handles(self, sort_handles=True):
|
def person_predicate(self, handle):
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Person in
|
|
||||||
the database. If sort_handles is True, the list is sorted by surnames
|
|
||||||
"""
|
|
||||||
handles = []
|
|
||||||
if self.mode == self.MODE_EXCLUDE_ALL:
|
if self.mode == self.MODE_EXCLUDE_ALL:
|
||||||
for handle in self.db.get_person_handles(sort_handles):
|
person = self.db.get_person_from_handle(handle)
|
||||||
person = self.db.get_person_from_handle(handle)
|
if self.__is_living(person):
|
||||||
if not self.__is_living(person):
|
return False
|
||||||
handles.append(handle)
|
return True
|
||||||
else:
|
|
||||||
handles = self.db.get_person_handles(sort_handles)
|
|
||||||
return handles
|
|
||||||
|
|
||||||
def iter_person_handles(self):
|
|
||||||
"""
|
|
||||||
Return an iterator over database handles, one handle for each Person in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
if self.mode == self.MODE_EXCLUDE_ALL:
|
|
||||||
for handle in self.db.iter_person_handles():
|
|
||||||
person = self.db.get_person_from_handle(handle)
|
|
||||||
if self.mode == self.MODE_EXCLUDE_ALL:
|
|
||||||
if not self.__is_living(person):
|
|
||||||
yield handle
|
|
||||||
else:
|
|
||||||
yield handle
|
|
||||||
|
|
||||||
def get_place_handles(self, sort_handles=True):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Place in
|
|
||||||
the database. If sort_handles is True, the list is sorted by
|
|
||||||
Place title.
|
|
||||||
"""
|
|
||||||
return self.db.get_place_handles(sort_handles)
|
|
||||||
|
|
||||||
def iter_place_handles(self):
|
|
||||||
"""
|
|
||||||
Return an iterator over database handles, one handle for each Place in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
return self.db.get_place_handles(sort_handles)
|
|
||||||
|
|
||||||
def get_source_handles(self, sort_handles=True):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Source in
|
|
||||||
the database. If sort_handles is True, the list is sorted by
|
|
||||||
Source title.
|
|
||||||
"""
|
|
||||||
return self.db.get_source_handles(sort_handles)
|
|
||||||
|
|
||||||
def get_media_object_handles(self, sort_handles=True):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each MediaObject in
|
|
||||||
the database. If sort_handles is True, the list is sorted by title.
|
|
||||||
"""
|
|
||||||
return self.db.get_media_object_handles(sort_handles)
|
|
||||||
|
|
||||||
def get_event_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Event in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
return self.db.get_event_handles()
|
|
||||||
|
|
||||||
def get_family_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Family in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
return self.db.get_family_handles()
|
|
||||||
|
|
||||||
def iter_family_handles(self):
|
|
||||||
"""
|
|
||||||
Return an iterator over database handles, one handle for each Family in
|
|
||||||
the database..
|
|
||||||
"""
|
|
||||||
return self.db.iter_family_handles()
|
|
||||||
|
|
||||||
def get_repository_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Repository in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
return self.db.get_repository_handles()
|
|
||||||
|
|
||||||
def get_note_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Note in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
return self.db.get_note_handles()
|
|
||||||
|
|
||||||
def get_researcher(self):
|
|
||||||
"""returns the Researcher instance, providing information about
|
|
||||||
the owner of the database"""
|
|
||||||
return self.db.get_researcher()
|
|
||||||
|
|
||||||
def get_default_person(self):
|
def get_default_person(self):
|
||||||
"""returns the default Person of the database"""
|
"""returns the default Person of the database"""
|
||||||
person_handle = self.db.get_default_handle()
|
person_handle = self.db.get_default_handle()
|
||||||
|
@ -206,138 +206,63 @@ class PrivateProxyDb(ProxyDbBase):
|
|||||||
return note
|
return note
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_person_handles(self, sort_handles=True):
|
# Define predicate functions for use by default iterator methods
|
||||||
|
|
||||||
|
def person_predicate(self, handle):
|
||||||
"""
|
"""
|
||||||
Return a list of database handles, one handle for each Person in
|
Predicate returning True if object is to be included, else False
|
||||||
the database. If sort_handles is True, the list is sorted by surnames
|
|
||||||
"""
|
"""
|
||||||
handles = []
|
obj = self.db.get_person_from_handle(handle)
|
||||||
for handle in self.db.get_person_handles(sort_handles):
|
return not obj.get_privacy()
|
||||||
person = self.db.get_person_from_handle(handle)
|
|
||||||
if not person.get_privacy():
|
def family_predicate(self, handle):
|
||||||
handles.append(handle)
|
|
||||||
return handles
|
|
||||||
|
|
||||||
def iter_person_handles(self):
|
|
||||||
"""
|
"""
|
||||||
Return an iterator over database handles, one handle for each Person in
|
Predicate returning True if object is to be included, else False
|
||||||
the database. If sort_handles is True, the list is sorted by surnames
|
"""
|
||||||
|
obj = self.db.get_family_from_handle(handle)
|
||||||
|
return not obj.get_privacy()
|
||||||
|
|
||||||
|
def event_predicate(self, handle):
|
||||||
"""
|
"""
|
||||||
for handle in self.db.iter_person_handles():
|
Predicate returning True if object is to be included, else False
|
||||||
person = self.db.get_person_from_handle(handle)
|
"""
|
||||||
if not person.get_privacy():
|
obj = self.db.get_event_from_handle(handle)
|
||||||
yield handle
|
return not obj.get_privacy()
|
||||||
|
|
||||||
def get_place_handles(self, sort_handles=True):
|
def source_predicate(self, handle):
|
||||||
"""
|
"""
|
||||||
Return a list of database handles, one handle for each Place in
|
Predicate returning True if object is to be included, else False
|
||||||
the database. If sort_handles is True, the list is sorted by
|
"""
|
||||||
Place title.
|
obj = self.db.get_source_from_handle(handle)
|
||||||
|
return not obj.get_privacy()
|
||||||
|
|
||||||
|
def place_predicate(self, handle):
|
||||||
"""
|
"""
|
||||||
handles = []
|
Predicate returning True if object is to be included, else False
|
||||||
for handle in self.db.get_place_handles(sort_handles):
|
"""
|
||||||
place = self.db.get_place_from_handle(handle)
|
obj = self.db.get_place_from_handle(handle)
|
||||||
if not place.get_privacy():
|
return not obj.get_privacy()
|
||||||
handles.append(handle)
|
|
||||||
return handles
|
def object_predicate(self, handle):
|
||||||
|
|
||||||
def iter_place_handles(self):
|
|
||||||
"""
|
"""
|
||||||
Return an iterator over database handles, one handle for each Place in
|
Predicate returning True if object is to be included, else False
|
||||||
the database.
|
"""
|
||||||
|
obj = self.db.get_object_from_handle(handle)
|
||||||
|
return not obj.get_privacy()
|
||||||
|
|
||||||
|
def repository_predicate(self, handle):
|
||||||
"""
|
"""
|
||||||
for handle in self.db.get_place_handles(sort_handles):
|
Predicate returning True if object is to be included, else False
|
||||||
place = self.db.get_place_from_handle(handle)
|
"""
|
||||||
if not place.get_privacy():
|
obj = self.db.get_repository_from_handle(handle)
|
||||||
yield handle
|
return not obj.get_privacy()
|
||||||
|
|
||||||
def get_source_handles(self, sort_handles=True):
|
def note_predicate(self, handle):
|
||||||
"""
|
"""
|
||||||
Return a list of database handles, one handle for each Source in
|
Predicate returning True if object is to be included, else False
|
||||||
the database. If sort_handles is True, the list is sorted by
|
"""
|
||||||
Source title.
|
obj = self.db.get_note_from_handle(handle)
|
||||||
"""
|
return not obj.get_privacy()
|
||||||
handles = []
|
|
||||||
for handle in self.db.get_source_handles(sort_handles):
|
|
||||||
source = self.db.get_source_from_handle(handle)
|
|
||||||
if not source.get_privacy():
|
|
||||||
handles.append(handle)
|
|
||||||
return handles
|
|
||||||
|
|
||||||
def get_media_object_handles(self, sort_handles=True):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each MediaObject in
|
|
||||||
the database. If sort_handles is True, the list is sorted by title.
|
|
||||||
"""
|
|
||||||
handles = []
|
|
||||||
for handle in self.db.get_media_object_handles(sort_handles):
|
|
||||||
object = self.db.get_object_from_handle(handle)
|
|
||||||
if not object.get_privacy():
|
|
||||||
handles.append(handle)
|
|
||||||
return handles
|
|
||||||
|
|
||||||
def get_event_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Event in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
handles = []
|
|
||||||
for handle in self.db.get_event_handles():
|
|
||||||
event = self.db.get_event_from_handle(handle)
|
|
||||||
if not event.get_privacy():
|
|
||||||
handles.append(handle)
|
|
||||||
return handles
|
|
||||||
|
|
||||||
def get_family_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Family in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
handles = []
|
|
||||||
for handle in self.db.iter_family_handles():
|
|
||||||
family = self.db.get_family_from_handle(handle)
|
|
||||||
if not family.get_privacy():
|
|
||||||
handles.append(handle)
|
|
||||||
return handles
|
|
||||||
|
|
||||||
def iter_family_handles(self):
|
|
||||||
"""
|
|
||||||
Return an iterator over database handles, one handle for each Family in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
for handle in self.db.iter_family_handles():
|
|
||||||
family = self.db.get_family_from_handle(handle)
|
|
||||||
if not family.get_privacy():
|
|
||||||
yield handle
|
|
||||||
|
|
||||||
def get_repository_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Repository in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
handles = []
|
|
||||||
for handle in self.db.get_repository_handles():
|
|
||||||
repository = self.db.get_repository_from_handle(handle)
|
|
||||||
if not repository.get_privacy():
|
|
||||||
handles.append(handle)
|
|
||||||
return handles
|
|
||||||
|
|
||||||
def get_note_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Note in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
handles = []
|
|
||||||
for handle in self.db.get_note_handles():
|
|
||||||
note = self.db.get_note_from_handle(handle)
|
|
||||||
if not note.get_privacy():
|
|
||||||
handles.append(handle)
|
|
||||||
return handles
|
|
||||||
|
|
||||||
def get_researcher(self):
|
|
||||||
"""returns the Researcher instance, providing information about
|
|
||||||
the owner of the database"""
|
|
||||||
return self.db.get_researcher()
|
|
||||||
|
|
||||||
def get_default_person(self):
|
def get_default_person(self):
|
||||||
"""returns the default Person of the database"""
|
"""returns the default Person of the database"""
|
||||||
|
@ -24,6 +24,13 @@
|
|||||||
Proxy class for the GRAMPS databases. Filter out all data marked private.
|
Proxy class for the GRAMPS databases. Filter out all data marked private.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Python modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
from itertools import ifilter
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# GRAMPS libraries
|
# GRAMPS libraries
|
||||||
@ -62,6 +69,165 @@ class ProxyDbBase(DbBase):
|
|||||||
Return 1 if the database has been opened.
|
Return 1 if the database has been opened.
|
||||||
"""
|
"""
|
||||||
return self.db.is_open
|
return self.db.is_open
|
||||||
|
|
||||||
|
def get_researcher(self):
|
||||||
|
"""returns the Researcher instance, providing information about
|
||||||
|
the owner of the database"""
|
||||||
|
return self.db.get_researcher()
|
||||||
|
|
||||||
|
def predicate(self, handle):
|
||||||
|
"""
|
||||||
|
Default predicate. Returns True
|
||||||
|
"""
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Define default predicates for each object type
|
||||||
|
|
||||||
|
person_predicate = \
|
||||||
|
family_predicate = \
|
||||||
|
event_predicate = \
|
||||||
|
source_predicate = \
|
||||||
|
place_predicate = \
|
||||||
|
object_predicate = \
|
||||||
|
repository_predicate = \
|
||||||
|
note_predicate = \
|
||||||
|
predicate
|
||||||
|
|
||||||
|
def get_person_handles(self, sort_handles=True):
|
||||||
|
"""
|
||||||
|
Return a list of database handles, one handle for each Person in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
if self.db.is_open:
|
||||||
|
return list(self.iter_person_handles())
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_family_handles(self, sort_handles=True):
|
||||||
|
"""
|
||||||
|
Return a list of database handles, one handle for each Family in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
if self.db.is_open:
|
||||||
|
return list(self.iter_family_handles())
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_event_handles(self, sort_handles=True):
|
||||||
|
"""
|
||||||
|
Return a list of database handles, one handle for each Event in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
if self.db.is_open:
|
||||||
|
return list(self.iter_event_handles())
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_source_handles(self, sort_handles=True):
|
||||||
|
"""
|
||||||
|
Return a list of database handles, one handle for each Source in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
if self.db.is_open:
|
||||||
|
return list(self.iter_source_handles())
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_place_handles(self, sort_handles=True):
|
||||||
|
"""
|
||||||
|
Return a list of database handles, one handle for each Place in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
if self.db.is_open:
|
||||||
|
return list(self.iter_place_handles())
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_media_object_handles(self, sort_handles=True):
|
||||||
|
"""
|
||||||
|
Return a list of database handles, one handle for each MediaObject in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
if self.db.is_open:
|
||||||
|
return list(self.iter_media_object_handles())
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_repository_handles(self, sort_handles=True):
|
||||||
|
"""
|
||||||
|
Return a list of database handles, one handle for each Repository in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
if self.db.is_open:
|
||||||
|
return list(self.iter_repository_handles())
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_note_handles(self, sort_handles=True):
|
||||||
|
"""
|
||||||
|
Return a list of database handles, one handle for each Note in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
if self.db.is_open:
|
||||||
|
return list(self.iter_note_handles())
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
def iter_person_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Person in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
return ifilter(self.person_predicate, self.db.iter_person_handles())
|
||||||
|
|
||||||
|
def iter_family_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Family in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
return ifilter(self.family_predicate, self.db.iter_family_handles())
|
||||||
|
|
||||||
|
def iter_event_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Event in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
return ifilter(self.event_predicate, self.db.iter_event_handles())
|
||||||
|
|
||||||
|
def iter_source_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Source in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
return ifilter(self.source_predicate, self.db.iter_source_handles())
|
||||||
|
|
||||||
|
def iter_place_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Place in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
return ifilter(self.place_predicate, self.db.iter_place_handles())
|
||||||
|
|
||||||
|
def iter_media_object_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Media
|
||||||
|
Object in the database.
|
||||||
|
"""
|
||||||
|
return ifilter(self.object_predicate, self.db.iter_media_object_handles())
|
||||||
|
|
||||||
|
def iter_repository_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each
|
||||||
|
Repository in the database.
|
||||||
|
"""
|
||||||
|
return ifilter(self.repository_predicate, self.db.iter_repository_handles())
|
||||||
|
|
||||||
|
def iter_note_handles(self):
|
||||||
|
"""
|
||||||
|
Return an iterator over database handles, one handle for each Note in
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
|
return ifilter(self.note_predicate, self.db.iter_note_handles())
|
||||||
|
|
||||||
def get_name_group_mapping(self, name):
|
def get_name_group_mapping(self, name):
|
||||||
"""
|
"""
|
||||||
@ -85,43 +251,43 @@ class ProxyDbBase(DbBase):
|
|||||||
"""
|
"""
|
||||||
Return the number of people currently in the databse.
|
Return the number of people currently in the databse.
|
||||||
"""
|
"""
|
||||||
return len(self.get_person_handles())
|
return self.db.get_number_of_people()
|
||||||
|
|
||||||
def get_number_of_families(self):
|
def get_number_of_families(self):
|
||||||
"""
|
"""
|
||||||
Return the number of families currently in the databse.
|
Return the number of families currently in the databse.
|
||||||
"""
|
"""
|
||||||
return len(self.get_family_handles())
|
return self.db.get_number_of_families()
|
||||||
|
|
||||||
def get_number_of_events(self):
|
def get_number_of_events(self):
|
||||||
"""
|
"""
|
||||||
Return the number of events currently in the databse.
|
Return the number of events currently in the databse.
|
||||||
"""
|
"""
|
||||||
return len(self.get_event_handles())
|
return self.db.get_number_of_events()
|
||||||
|
|
||||||
def get_number_of_places(self):
|
def get_number_of_places(self):
|
||||||
"""
|
"""
|
||||||
Return the number of places currently in the databse.
|
Return the number of places currently in the databse.
|
||||||
"""
|
"""
|
||||||
return len(self.get_place_handles())
|
return self.db.get_number_of_places()
|
||||||
|
|
||||||
def get_number_of_sources(self):
|
def get_number_of_sources(self):
|
||||||
"""
|
"""
|
||||||
Return the number of sources currently in the databse.
|
Return the number of sources currently in the databse.
|
||||||
"""
|
"""
|
||||||
return len(self.get_source_handles())
|
return self.db.get_number_of_sources()
|
||||||
|
|
||||||
def get_number_of_media_objects(self):
|
def get_number_of_media_objects(self):
|
||||||
"""
|
"""
|
||||||
Return the number of media objects currently in the databse.
|
Return the number of media objects currently in the databse.
|
||||||
"""
|
"""
|
||||||
return len(self.get_media_object_handles())
|
return self.db.get_number_of_media_objects()
|
||||||
|
|
||||||
def get_number_of_repositories(self):
|
def get_number_of_repositories(self):
|
||||||
"""
|
"""
|
||||||
Return the number of source repositories currently in the databse.
|
Return the number of source repositories currently in the databse.
|
||||||
"""
|
"""
|
||||||
return len(self.get_repository_handles())
|
return self.db.get_number_of_repositories()
|
||||||
|
|
||||||
def get_number_of_notes(self):
|
def get_number_of_notes(self):
|
||||||
"""
|
"""
|
||||||
|
@ -165,99 +165,21 @@ class ReferencedProxyDb(ProxyDbBase):
|
|||||||
"""
|
"""
|
||||||
return self.db.get_note_from_gramps_id(val)
|
return self.db.get_note_from_gramps_id(val)
|
||||||
|
|
||||||
def get_person_handles(self, sort_handles=True):
|
def place_predicate(self, handle):
|
||||||
"""
|
return handle not in self.unreferenced_places
|
||||||
Return a list of database handles, one handle for each Person in
|
|
||||||
the database. If sort_handles is True, the list is sorted by surnames
|
def object_predicate(self, handle):
|
||||||
"""
|
return handle not in self.unreferenced_media_objects
|
||||||
return self.db.get_person_handles(sort_handles)
|
|
||||||
|
def event_predicate(self, handle):
|
||||||
def iter_person_handles(self):
|
return handle not in self.unreferenced_events
|
||||||
"""
|
|
||||||
Return an iterator over database handles, one handle for each Person in
|
def repository_predicate(self, handle):
|
||||||
the database. If sort_handles is True, the list is sorted by surnames
|
return handle not in self.unreferenced_repositories
|
||||||
"""
|
|
||||||
return self.db.iter_person_handles()
|
def note_predicate(self, handle):
|
||||||
|
return handle not in self.unreferenced_notes
|
||||||
def get_place_handles(self, sort_handles=True):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Place still
|
|
||||||
referenced in the database. If sort_handles is True, the list is
|
|
||||||
sorted by Place title.
|
|
||||||
"""
|
|
||||||
return list(set(self.db.get_place_handles(sort_handles)) -
|
|
||||||
set(self.unreferenced_places))
|
|
||||||
|
|
||||||
def iter_place_handles(self):
|
|
||||||
"""
|
|
||||||
Return an iterator over database handles, one handle for each Place still
|
|
||||||
referenced in the database.
|
|
||||||
"""
|
|
||||||
for handle in self.db.iter_place_handles():
|
|
||||||
if handle not in self.unreferenced_places:
|
|
||||||
yield handle
|
|
||||||
|
|
||||||
def get_source_handles(self, sort_handles=True):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Source still
|
|
||||||
referenced in the database. If sort_handles is True, the list is
|
|
||||||
sorted by Source title.
|
|
||||||
"""
|
|
||||||
return list(set(self.db.get_source_handles(sort_handles)) -
|
|
||||||
set(self.unreferenced_sources))
|
|
||||||
|
|
||||||
def get_media_object_handles(self, sort_handles=True):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each MediaObject
|
|
||||||
still referenced in the database. If sort_handles is True, the list
|
|
||||||
is sorted by title.
|
|
||||||
"""
|
|
||||||
return list(set(self.db.get_media_object_handles(sort_handles)) -
|
|
||||||
set(self.unreferenced_media_objects))
|
|
||||||
|
|
||||||
def get_event_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Event
|
|
||||||
still referenced in the database.
|
|
||||||
"""
|
|
||||||
return list(set(self.db.get_event_handles()) -
|
|
||||||
set(self.unreferenced_events))
|
|
||||||
|
|
||||||
def get_family_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Family in
|
|
||||||
the database.
|
|
||||||
"""
|
|
||||||
return self.db.get_family_handles()
|
|
||||||
|
|
||||||
def iter_family_handles(self):
|
|
||||||
"""
|
|
||||||
Return an iterator over database handles, one handle for each Family in
|
|
||||||
the database..
|
|
||||||
"""
|
|
||||||
return self.db.iter_family_handles()
|
|
||||||
|
|
||||||
def get_repository_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Repository still
|
|
||||||
referenced in the database.
|
|
||||||
"""
|
|
||||||
return list(set(self.db.get_repository_handles()) -
|
|
||||||
set(self.unreferenced_repositories))
|
|
||||||
|
|
||||||
def get_note_handles(self):
|
|
||||||
"""
|
|
||||||
Return a list of database handles, one handle for each Note still
|
|
||||||
referenced in the database.
|
|
||||||
"""
|
|
||||||
return list(set(self.db.get_note_handles()) -
|
|
||||||
set(self.unreferenced_notes))
|
|
||||||
|
|
||||||
def get_researcher(self):
|
|
||||||
"""returns the Researcher instance, providing information about
|
|
||||||
the owner of the database"""
|
|
||||||
return self.db.get_researcher()
|
|
||||||
|
|
||||||
def get_default_person(self):
|
def get_default_person(self):
|
||||||
"""returns the default Person of the database"""
|
"""returns the default Person of the database"""
|
||||||
return self.db.get_default_person()
|
return self.db.get_default_person()
|
||||||
|
Loading…
Reference in New Issue
Block a user