Change to set logic for reduction in storage (no affect on runtime)
svn: r13190
This commit is contained in:
parent
e8033040bb
commit
d5e48cda06
@ -25,7 +25,7 @@
|
||||
"""
|
||||
Proxy class for the GRAMPS databases. Apply filter
|
||||
"""
|
||||
|
||||
import pdb
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS libraries
|
||||
@ -48,30 +48,29 @@ class FilterProxyDb(ProxyDbBase):
|
||||
"""
|
||||
ProxyDbBase.__init__(self, db)
|
||||
self.person_filter = person_filter
|
||||
|
||||
if person_filter:
|
||||
self.plist = dict((h, 1) for h in person_filter.apply(
|
||||
self.plist = set(h for h in person_filter.apply(
|
||||
self.db, self.db.iter_person_handles()))
|
||||
else:
|
||||
self.plist = dict((h, 1) for h in self.db.iter_person_handles())
|
||||
self.plist = set(self.db.iter_person_handles())
|
||||
|
||||
if event_filter:
|
||||
self.elist = dict((h, 1) for h in event_filter.apply(
|
||||
self.elist = set(h for h in event_filter.apply(
|
||||
self.db, self.db.iter_event_handles()))
|
||||
else:
|
||||
self.elist = dict((h, 1) for h in self.db.iter_event_handles())
|
||||
self.elist = set(self.db.iter_event_handles())
|
||||
|
||||
if note_filter:
|
||||
self.nlist = dict((h, 1) for h in note_filter.apply(
|
||||
self.nlist = set(h for h in note_filter.apply(
|
||||
self.db, self.db.iter_note_handles()))
|
||||
else:
|
||||
self.nlist = dict((h, 1) for h in self.db.iter_note_handles())
|
||||
self.nlist = set(self.db.iter_note_handles())
|
||||
|
||||
self.flist = {}
|
||||
for handle in list(self.plist):
|
||||
self.flist = set()
|
||||
for handle in self.plist:
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
for handle in person.get_family_handle_list():
|
||||
self.flist[handle] = 1
|
||||
self.flist.add(handle)
|
||||
|
||||
def get_person_from_handle(self, handle):
|
||||
"""
|
||||
@ -298,7 +297,6 @@ class FilterProxyDb(ProxyDbBase):
|
||||
Return an iterator over database handles, one handle for each Person in
|
||||
the database.
|
||||
"""
|
||||
# FIXME: plist is not a sorted list of handles
|
||||
return self.plist
|
||||
|
||||
def iter_people(self):
|
||||
@ -420,6 +418,7 @@ class FilterProxyDb(ProxyDbBase):
|
||||
@param notebase: NoteBase object to clean
|
||||
@type event: NoteBase
|
||||
"""
|
||||
|
||||
note_list = notebase.get_note_list()
|
||||
new_note_list = [ note for note in note_list if note in self.nlist ]
|
||||
notebase.set_note_list(new_note_list)
|
||||
|
@ -43,12 +43,12 @@ class ReferencedProxyDb(ProxyDbBase):
|
||||
Create a new ReferencedProxyDb instance.
|
||||
"""
|
||||
ProxyDbBase.__init__(self, dbase)
|
||||
self.unreferenced_events = {}
|
||||
self.unreferenced_places = {}
|
||||
self.unreferenced_sources = {}
|
||||
self.unreferenced_repositories = {}
|
||||
self.unreferenced_media_objects = {}
|
||||
self.unreferenced_notes = {}
|
||||
self.unreferenced_events = set()
|
||||
self.unreferenced_places = set()
|
||||
self.unreferenced_sources = set()
|
||||
self.unreferenced_repositories = set()
|
||||
self.unreferenced_media_objects = set()
|
||||
self.unreferenced_notes = set()
|
||||
|
||||
# Build lists of unreferenced objects
|
||||
self.__find_unreferenced_objects()
|
||||
@ -155,7 +155,7 @@ class ReferencedProxyDb(ProxyDbBase):
|
||||
for handle in handle_list:
|
||||
if (handle not in unref_list and
|
||||
not any(self.find_backlink_handles(handle)) ):
|
||||
unref_list[handle] = True
|
||||
unref_list.add(handle)
|
||||
current_count += len(unref_list)
|
||||
|
||||
if current_count == last_count:
|
||||
|
Loading…
Reference in New Issue
Block a user