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,6 +68,7 @@ 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)
if person:
self.flist.update(person.get_family_handle_list()) 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,6 +228,7 @@ 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)
if person:
return self.get_person_from_handle(person.get_handle()) 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,6 +237,7 @@ 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)
if family:
return self.get_family_from_handle(family.get_handle()) 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,6 +246,7 @@ 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)
if event:
return self.get_event_from_handle(event.get_handle()) 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,6 +255,7 @@ 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)
if place:
return self.get_place_from_handle(place.get_handle()) 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,6 +264,7 @@ 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)
if source:
return self.get_source_from_handle(source.get_handle()) 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,6 +273,7 @@ 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)
if media:
return self.get_object_from_handle(media.get_handle()) 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,6 +282,7 @@ 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)
if repository:
return self.get_repository_from_handle(repository.get_handle()) 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,6 +291,7 @@ 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)
if note:
return self.get_note_from_handle(note.get_handle()) 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,7 +428,7 @@ 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)
@ -427,11 +439,13 @@ class FilterProxyDb(ProxyDbBase):
@param event: SourceBase object to clean @param event: SourceBase object to clean
@type event: SourceBase @type event: SourceBase
""" """
if sourcebase:
sources = sourcebase.get_source_references() sources = sourcebase.get_source_references()
for source in sources: for source in sources:
self.sanitize_notebase(source) self.sanitize_notebase(source)
def sanitize_addressbase(self, addressbase): def sanitize_addressbase(self, addressbase):
if addressbase:
addresses = addressbase.get_address_list() addresses = addressbase.get_address_list()
for address in addresses: for address in addresses:
self.sanitize_notebase(address) self.sanitize_notebase(address)
@ -443,6 +457,7 @@ class FilterProxyDb(ProxyDbBase):
@param event: Person object to clean @param event: Person object to clean
@type event: Person @type event: Person
""" """
if person:
# Filter note references # Filter note references
self.sanitize_notebase(person) self.sanitize_notebase(person)
self.sanitize_sourcebase(person) self.sanitize_sourcebase(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