* src/WriteGedcom.py: Some hardening against corrupt database.

svn: r4643
This commit is contained in:
Martin Hawlisch 2005-05-20 20:05:55 +00:00
parent 35bd104ca1
commit 38751bb5a8
2 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,7 @@
2005-05-20 Martin Hawlisch <Martin.Hawlisch@gmx.de> 2005-05-20 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/WriteXML.py: Remove unnecessary database reads, so it does no * src/WriteXML.py: Remove unnecessary database reads, so it does no
longer crash when exporting a corrupt database. longer crash when exporting a corrupt database.
* src/WriteGedcom.py: Some hardening against corrupt database.
2005-05-20 Alex Roitman <shura@gramps-project.org> 2005-05-20 Alex Roitman <shura@gramps-project.org>
* src/SelectObject.py (on_select_row): Properly get mime type. * src/SelectObject.py (on_select_row): Properly get mime type.

View File

@ -136,6 +136,8 @@ def add_persons_sources(db,person,slist,private):
for event_handle in elist: for event_handle in elist:
if event_handle: if event_handle:
event = db.get_event_from_handle(event_handle) event = db.get_event_from_handle(event_handle)
if not event:
continue
if private and event.get_privacy(): if private and event.get_privacy():
continue continue
for source_ref in event.get_source_references(): for source_ref in event.get_source_references():
@ -713,6 +715,8 @@ class GedcomWriter:
if not self.plist.has_key(person_handle): if not self.plist.has_key(person_handle):
continue continue
person = self.db.get_person_from_handle(person_handle) person = self.db.get_person_from_handle(person_handle)
if not person:
continue
self.writeln("1 CHIL @%s@" % person.get_gramps_id()) self.writeln("1 CHIL @%s@" % person.get_gramps_id())
if self.adopt == GedcomInfo.ADOPT_FTW: if self.adopt == GedcomInfo.ADOPT_FTW:
if person.get_main_parents_family_handle() == family.get_handle(): if person.get_main_parents_family_handle() == family.get_handle():
@ -737,6 +741,8 @@ class GedcomWriter:
sorted = [] sorted = []
for key in self.slist.keys(): for key in self.slist.keys():
source = self.db.get_source_from_handle(key) source = self.db.get_source_from_handle(key)
if not source:
continue
data = (self.sid (source.get_gramps_id ()), source) data = (self.sid (source.get_gramps_id ()), source)
sorted.append (data) sorted.append (data)
sorted.sort () sorted.sort ()
@ -791,7 +797,7 @@ class GedcomWriter:
if not restricted: if not restricted:
birth_handle = person.get_birth_handle() birth_handle = person.get_birth_handle()
birth = self.db.get_event_from_handle(birth_handle) birth = self.db.get_event_from_handle(birth_handle)
if birth_handle and not (self.private and birth.get_privacy()): if birth_handle and birth and not (self.private and birth.get_privacy()):
if not birth.get_date_object().is_empty() or birth.get_place_handle(): if not birth.get_date_object().is_empty() or birth.get_place_handle():
if birth.get_description() != "": if birth.get_description() != "":
self.writeln("1 BIRT %s" % birth.get_description()) self.writeln("1 BIRT %s" % birth.get_description())
@ -801,7 +807,7 @@ class GedcomWriter:
death_handle = person.get_death_handle() death_handle = person.get_death_handle()
death = self.db.get_event_from_handle(death_handle) death = self.db.get_event_from_handle(death_handle)
if death_handle and not (self.private and death.get_privacy()): if death_handle and death and not (self.private and death.get_privacy()):
if not death.get_date_object().is_empty() or death.get_place_handle(): if not death.get_date_object().is_empty() or death.get_place_handle():
if birth.get_description() != "": if birth.get_description() != "":
self.writeln("1 DEAT %s" % death.get_description()) self.writeln("1 DEAT %s" % death.get_description())
@ -819,6 +825,8 @@ class GedcomWriter:
if not event_handle: if not event_handle:
continue continue
event = self.db.get_event_from_handle(event_handle) event = self.db.get_event_from_handle(event_handle)
if not event:
continue
if self.private and event.get_privacy(): if self.private and event.get_privacy():
continue continue
name = event.get_name() name = event.get_name()