3878: Private option and filter on Exporter

svn: r15383
This commit is contained in:
Doug Blank 2010-05-10 00:00:15 +00:00
parent 0d588841d5
commit cda97348e8
2 changed files with 53 additions and 38 deletions

View File

@ -68,7 +68,8 @@ class FilterProxyDb(ProxyDbBase):
self.flist = set() self.flist = set()
for handle in self.plist: for handle in self.plist:
person = self.db.get_person_from_handle(handle) person = self.db.get_person_from_handle(handle)
self.flist.update(person.get_family_handle_list()) if person:
self.flist.update(person.get_family_handle_list())
def get_person_from_handle(self, handle): def get_person_from_handle(self, handle):
""" """
@ -77,7 +78,8 @@ class FilterProxyDb(ProxyDbBase):
""" """
if handle in self.plist: if handle in self.plist:
person = self.db.get_person_from_handle(handle) person = self.db.get_person_from_handle(handle)
if person is None:
return None
person.set_person_ref_list( person.set_person_ref_list(
[ ref for ref in person.get_person_ref_list() [ ref for ref in person.get_person_ref_list()
if ref.ref in self.plist ]) if ref.ref in self.plist ])
@ -129,6 +131,7 @@ class FilterProxyDb(ProxyDbBase):
""" """
source = self.db.get_source_from_handle(handle) source = self.db.get_source_from_handle(handle)
# Filter notes out # Filter notes out
self.sanitize_notebase(source) self.sanitize_notebase(source)
return source return source
@ -175,7 +178,8 @@ class FilterProxyDb(ProxyDbBase):
""" """
if handle in self.flist: if handle in self.flist:
family = self.db.get_family_from_handle(handle) family = self.db.get_family_from_handle(handle)
if family is None:
return None
eref_list = [ eref for eref in family.get_event_ref_list() eref_list = [ eref for eref in family.get_event_ref_list()
if eref.ref in self.elist ] if eref.ref in self.elist ]
family.set_event_ref_list(eref_list) family.set_event_ref_list(eref_list)
@ -224,7 +228,8 @@ class FilterProxyDb(ProxyDbBase):
If no such Person exists, None is returned. If no such Person exists, None is returned.
""" """
person = self.db.get_person_from_gramps_id(val) person = self.db.get_person_from_gramps_id(val)
return self.get_person_from_handle(person.get_handle()) if person:
return self.get_person_from_handle(person.get_handle())
def get_family_from_gramps_id(self, val): def get_family_from_gramps_id(self, val):
""" """
@ -232,7 +237,8 @@ class FilterProxyDb(ProxyDbBase):
If no such Family exists, None is returned. If no such Family exists, None is returned.
""" """
family = self.db.get_family_from_gramps_id(val) family = self.db.get_family_from_gramps_id(val)
return self.get_family_from_handle(family.get_handle()) if family:
return self.get_family_from_handle(family.get_handle())
def get_event_from_gramps_id(self, val): def get_event_from_gramps_id(self, val):
""" """
@ -240,7 +246,8 @@ class FilterProxyDb(ProxyDbBase):
If no such Event exists, None is returned. If no such Event exists, None is returned.
""" """
event = self.db.get_event_from_gramps_id(val) event = self.db.get_event_from_gramps_id(val)
return self.get_event_from_handle(event.get_handle()) if event:
return self.get_event_from_handle(event.get_handle())
def get_place_from_gramps_id(self, val): def get_place_from_gramps_id(self, val):
""" """
@ -248,7 +255,8 @@ class FilterProxyDb(ProxyDbBase):
If no such Place exists, None is returned. If no such Place exists, None is returned.
""" """
place = self.db.get_place_from_gramps_id(val) place = self.db.get_place_from_gramps_id(val)
return self.get_place_from_handle(place.get_handle()) if place:
return self.get_place_from_handle(place.get_handle())
def get_source_from_gramps_id(self, val): def get_source_from_gramps_id(self, val):
""" """
@ -256,7 +264,8 @@ class FilterProxyDb(ProxyDbBase):
If no such Source exists, None is returned. If no such Source exists, None is returned.
""" """
source = self.db.get_source_from_gramps_id(val) source = self.db.get_source_from_gramps_id(val)
return self.get_source_from_handle(source.get_handle()) if source:
return self.get_source_from_handle(source.get_handle())
def get_object_from_gramps_id(self, val): def get_object_from_gramps_id(self, val):
""" """
@ -264,7 +273,8 @@ class FilterProxyDb(ProxyDbBase):
If no such MediaObject exists, None is returned. If no such MediaObject exists, None is returned.
""" """
media = self.db.get_object_from_gramps_id(val) media = self.db.get_object_from_gramps_id(val)
return self.get_object_from_handle(media.get_handle()) if media:
return self.get_object_from_handle(media.get_handle())
def get_repository_from_gramps_id(self, val): def get_repository_from_gramps_id(self, val):
""" """
@ -272,7 +282,8 @@ class FilterProxyDb(ProxyDbBase):
If no such Repository exists, None is returned. If no such Repository exists, None is returned.
""" """
repository = self.db.get_repository_from_gramps_id(val) repository = self.db.get_repository_from_gramps_id(val)
return self.get_repository_from_handle(repository.get_handle()) if repository:
return self.get_repository_from_handle(repository.get_handle())
def get_note_from_gramps_id(self, val): def get_note_from_gramps_id(self, val):
""" """
@ -280,7 +291,8 @@ class FilterProxyDb(ProxyDbBase):
If no such Note exists, None is returned. If no such Note exists, None is returned.
""" """
note = self.db.get_note_from_gramps_id(val) note = self.db.get_note_from_gramps_id(val)
return self.get_note_from_handle(note.get_handle()) if note:
return self.get_note_from_handle(note.get_handle())
def get_person_handles(self, sort_handles=True): def get_person_handles(self, sort_handles=True):
""" """
@ -416,10 +428,10 @@ class FilterProxyDb(ProxyDbBase):
@param notebase: NoteBase object to clean @param notebase: NoteBase object to clean
@type event: NoteBase @type event: NoteBase
""" """
if notebase:
note_list = notebase.get_note_list() note_list = notebase.get_note_list()
new_note_list = [ note for note in note_list if note in self.nlist ] new_note_list = [ note for note in note_list if note in self.nlist ]
notebase.set_note_list(new_note_list) notebase.set_note_list(new_note_list)
def sanitize_sourcebase(self, sourcebase): def sanitize_sourcebase(self, sourcebase):
""" """
@ -427,15 +439,17 @@ class FilterProxyDb(ProxyDbBase):
@param event: SourceBase object to clean @param event: SourceBase object to clean
@type event: SourceBase @type event: SourceBase
""" """
sources = sourcebase.get_source_references() if sourcebase:
for source in sources: sources = sourcebase.get_source_references()
self.sanitize_notebase(source) for source in sources:
self.sanitize_notebase(source)
def sanitize_addressbase(self, addressbase): def sanitize_addressbase(self, addressbase):
addresses = addressbase.get_address_list() if addressbase:
for address in addresses: addresses = addressbase.get_address_list()
self.sanitize_notebase(address) for address in addresses:
self.sanitize_sourcebase(address) self.sanitize_notebase(address)
self.sanitize_sourcebase(address)
def sanitize_person(self, person): def sanitize_person(self, person):
""" """
@ -443,18 +457,19 @@ class FilterProxyDb(ProxyDbBase):
@param event: Person object to clean @param event: Person object to clean
@type event: Person @type event: Person
""" """
# Filter note references if person:
self.sanitize_notebase(person) # Filter note references
self.sanitize_sourcebase(person) self.sanitize_notebase(person)
self.sanitize_addressbase(person) self.sanitize_sourcebase(person)
self.sanitize_addressbase(person)
name = person.get_primary_name() name = person.get_primary_name()
self.sanitize_notebase(name)
self.sanitize_sourcebase(name)
altnames = person.get_alternate_names()
for name in altnames:
self.sanitize_notebase(name) self.sanitize_notebase(name)
self.sanitize_sourcebase(name) self.sanitize_sourcebase(name)
self.sanitize_addressbase(person) altnames = person.get_alternate_names()
for name in altnames:
self.sanitize_notebase(name)
self.sanitize_sourcebase(name)
self.sanitize_addressbase(person)

View File

@ -210,7 +210,7 @@ class LivingProxyDb(ProxyDbBase):
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if father_handle: if father_handle:
father = self.db.get_person_from_handle(father_handle) father = self.db.get_person_from_handle(father_handle)
if self.__is_living(father): if father and self.__is_living(father):
parent_is_living = True parent_is_living = True
if self.mode == self.MODE_EXCLUDE_ALL: if self.mode == self.MODE_EXCLUDE_ALL:
family.set_father_handle(None) family.set_father_handle(None)
@ -218,7 +218,7 @@ class LivingProxyDb(ProxyDbBase):
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
if mother_handle: if mother_handle:
mother = self.db.get_person_from_handle(mother_handle) mother = self.db.get_person_from_handle(mother_handle)
if self.__is_living(mother): if mother and self.__is_living(mother):
parent_is_living = True parent_is_living = True
if self.mode == self.MODE_EXCLUDE_ALL: if self.mode == self.MODE_EXCLUDE_ALL:
family.set_mother_handle(None) family.set_mother_handle(None)
@ -231,7 +231,7 @@ class LivingProxyDb(ProxyDbBase):
for child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
child_handle = child_ref.get_reference_handle() child_handle = child_ref.get_reference_handle()
child = self.db.get_person_from_handle(child_handle) child = self.db.get_person_from_handle(child_handle)
if self.__is_living(child): if child and self.__is_living(child):
family.remove_child_ref(child_ref) family.remove_child_ref(child_ref)
return family return family