* src/plugins/FtmStyleAncestors.py: bring up to date with IDs

* src/plugins/AncestorReport.py: bring up to date with IDs


svn: r2956
This commit is contained in:
Don Allingham 2004-03-03 05:06:06 +00:00
parent 1cc879a776
commit 085b102a1f
2 changed files with 185 additions and 98 deletions

View File

@ -62,13 +62,15 @@ class AncestorReport(Report.Report):
else: else:
self.standalone = 0 self.standalone = 0
def filter(self,person,index,generation=1): def filter(self,person_id,index,generation=1):
if person == None or generation >= self.max_generations: if not person_id or generation >= self.max_generations:
return return
self.map[index] = person self.map[index] = person_id
family = person.get_main_parents_family_id() person = self.database.find_person_from_id(person_id)
if family != None: family_id = person.get_main_parents_family_id()
if family_id:
family = self.database.find_family_from_id(family_id)
self.filter(family.get_father_id(),index*2,generation+1) self.filter(family.get_father_id(),index*2,generation+1)
self.filter(family.get_mother_id(),(index*2)+1,generation+1) self.filter(family.get_mother_id(),(index*2)+1,generation+1)
@ -77,7 +79,9 @@ class AncestorReport(Report.Report):
if self.newpage: if self.newpage:
self.doc.page_break() self.doc.page_break()
self.filter(self.start,1) self.filter(self.start.get_id(),1)
print self.map
name = self.start.get_primary_name().get_regular_name() name = self.start.get_primary_name().get_regular_name()
self.doc.start_paragraph("AHN-Title") self.doc.start_paragraph("AHN-Title")
@ -100,7 +104,8 @@ class AncestorReport(Report.Report):
generation = generation + 1 generation = generation + 1
self.doc.start_paragraph("AHN-Entry","%s." % str(key)) self.doc.start_paragraph("AHN-Entry","%s." % str(key))
person = self.map[key] person_id = self.map[key]
person = self.database.find_person_from_id(person_id)
name = person.get_primary_name().get_regular_name() name = person.get_primary_name().get_regular_name()
self.doc.start_bold() self.doc.start_bold()
@ -113,13 +118,18 @@ class AncestorReport(Report.Report):
# Check birth record # Check birth record
birth = person.get_birth() birth_id = person.get_birth_id()
if birth: if birth_id:
birth = self.database.find_event_from_id(birth_id)
date = birth.get_date_object().get_start_date() date = birth.get_date_object().get_start_date()
place = birth.get_place_name() place_id = birth.get_place_id()
if place_id:
place = self.database.find_place_from_id(place_id).get_title()
else:
place = u''
if place[-1:] == '.': if place[-1:] == '.':
place = place[:-1] place = place[:-1]
if date.get_date() != "" or place != "": if date.get_date() != "" or place_id:
if date.get_date() != "": if date.get_date() != "":
if date.getDayValid() and date.getMonthValid(): if date.getDayValid() and date.getMonthValid():
if place != "": if place != "":
@ -137,18 +147,24 @@ class AncestorReport(Report.Report):
(name,date.get_date()) (name,date.get_date())
self.doc.write_text(t) self.doc.write_text(t)
death = person.get_death()
buried = None buried = None
for event in person.get_event_list(): for event_id in person.get_event_list():
event = self.database.find_event_from_id(event_id)
if string.lower(event.get_name()) == "burial": if string.lower(event.get_name()) == "burial":
buried = event buried = event
if death: death_id = person.get_death_id()
if death_id:
death = self.database.find_event_from_id(death_id)
date = death.get_date_object().get_start_date() date = death.get_date_object().get_start_date()
place = death.get_place_name() place_id = death.get_place_id()
if place_id:
place = self.database.find_place_from_id(place_id).get_title()
else:
place = u''
if place[-1:] == '.': if place[-1:] == '.':
place = place[:-1] place = place[:-1]
if date.get_date() != "" or place != "": if date.get_date() != "" or place_id:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
male = 1 male = 1
else: else:
@ -186,10 +202,14 @@ class AncestorReport(Report.Report):
if buried: if buried:
date = buried.get_date_object().get_start_date() date = buried.get_date_object().get_start_date()
place = buried.get_place_name() place_id = buried.get_place_id()
if place_id:
place = self.database.find_place_from_id(place_id).get_title()
else:
place = u''
if place[-1:] == '.': if place[-1:] == '.':
place = place[:-1] place = place[:-1]
if date.get_date() != "" or place != "": if date.get_date() != "" or place_id:
if date.get_date() != "": if date.get_date() != "":
if date.getDayValid() and date.getMonthValid(): if date.getDayValid() and date.getMonthValid():
if place != "": if place != "":

View File

@ -64,13 +64,15 @@ class FtmAncestorReport(Report.Report):
self.sref_map = {} self.sref_map = {}
self.sref_index = 0 self.sref_index = 0
def apply_filter(self,person,index,generation=1): def apply_filter(self,person_id,index,generation=1):
if person == None or generation > self.max_generations: if not person_id or generation >= self.max_generations:
return return
self.map[index] = (person,generation) self.map[index] = (person_id,generation)
family = person.get_main_parents_family_id() person = self.database.find_person_from_id(person_id)
if family != None: family_id = person.get_main_parents_family_id()
if family_id:
family = self.database.find_family_from_id(family_id)
self.apply_filter(family.get_father_id(),index*2,generation+1) self.apply_filter(family.get_father_id(),index*2,generation+1)
self.apply_filter(family.get_mother_id(),(index*2)+1,generation+1) self.apply_filter(family.get_mother_id(),(index*2)+1,generation+1)
@ -79,7 +81,7 @@ class FtmAncestorReport(Report.Report):
if self.newpage: if self.newpage:
self.doc.page_break() self.doc.page_break()
self.apply_filter(self.start,1) self.apply_filter(self.start.get_id(),1)
name = self.start.get_primary_name().get_regular_name() name = self.start.get_primary_name().get_regular_name()
self.doc.start_paragraph("FTA-Title") self.doc.start_paragraph("FTA-Title")
@ -91,7 +93,7 @@ class FtmAncestorReport(Report.Report):
keys.sort() keys.sort()
old_gen = 0 old_gen = 0
for key in keys : for key in keys :
(person,generation) = self.map[key] (person_id,generation) = self.map[key]
if old_gen != generation: if old_gen != generation:
if self.pgbrk and generation > 1: if self.pgbrk and generation > 1:
self.doc.page_break() self.doc.page_break()
@ -101,6 +103,7 @@ class FtmAncestorReport(Report.Report):
self.doc.end_paragraph() self.doc.end_paragraph()
old_gen = generation old_gen = generation
person = self.database.find_person_from_id(person_id)
pri_name = person.get_primary_name() pri_name = person.get_primary_name()
self.doc.start_paragraph("FTA-Entry","%d." % key) self.doc.start_paragraph("FTA-Entry","%d." % key)
name = pri_name.get_regular_name() name = pri_name.get_regular_name()
@ -110,16 +113,35 @@ class FtmAncestorReport(Report.Report):
# Check birth record # Check birth record
birth = person.get_birth() birth_id = person.get_birth_id()
bplace = birth.get_place_name() if birth_id:
birth_valid = 1
birth = self.database.find_event_from_id(birth_id)
place_id = birth.get_place_id()
if place_id:
bplace = self.database.find_place_from_id(place_id).get_title()
else:
bplace = u''
bdate = birth.get_date() bdate = birth.get_date()
else:
birth_valid = 0
bplace = u''
bdate = u''
death = person.get_death() death_id = person.get_death_id()
dplace = death.get_place_name() if death_id:
death_valid = 1
death = self.database.find_event_from_id(death_id)
place_id = death.get_place_id()
if place_id:
dplace = self.database.find_place_from_id(place_id).get_title()
else:
dplace = u''
ddate = death.get_date() ddate = death.get_date()
else:
birth_valid = bdate != "" or bplace != "" death_valid = 0
death_valid = ddate != "" or dplace != "" dplace = u''
ddate = u''
if birth_valid or death_valid: if birth_valid or death_valid:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
@ -426,12 +448,12 @@ class FtmAncestorReport(Report.Report):
keys.sort() keys.sort()
for key in keys: for key in keys:
srcref = self.sref_map[key] srcref = self.sref_map[key]
base = srcref.get_base_id() base = self.database.find_source_from_id(srcref.get_base_id())
self.doc.start_paragraph('FTA-Endnotes',"%d." % key) self.doc.start_paragraph('FTA-Endnotes',"%d." % key)
self.doc.write_text(base.get_title()) self.doc.write_text(base.get_title())
for item in [ base.get_author(), base.get_publication_info(), base.getAbbrev(), for item in [ base.get_author(), base.get_publication_info(), base.get_abbreviation(),
srcref.get_date().get_date(),]: srcref.get_date().get_date(),]:
if item: if item:
self.doc.write_text('; %s' % item) self.doc.write_text('; %s' % item)
@ -510,11 +532,16 @@ class FtmAncestorReport(Report.Report):
self.doc.end_paragraph() self.doc.end_paragraph()
ncount += 1 ncount += 1
for event in person.get_event_list(): for event_id in person.get_event_list():
event = self.database.find_event_from_id(event_id)
date = event.get_date() date = event.get_date()
place = event.get_place_id() place_id = event.get_place_id()
if place_id:
place = self.database.find_place_from_id(place_id).get_title()
else:
place = u''
if not date and not place: if not date and not place_id:
continue continue
if first: if first:
self.doc.start_paragraph('FTA-SubEntry') self.doc.start_paragraph('FTA-SubEntry')
@ -528,19 +555,19 @@ class FtmAncestorReport(Report.Report):
if date and place: if date and place:
self.doc.write_text(_('%(event_name)s: %(date)s, %(place)s%(endnotes)s. ') % { self.doc.write_text(_('%(event_name)s: %(date)s, %(place)s%(endnotes)s. ') % {
'event_name' : _(event.get_name()), 'event_name' : _(event.get_name()),
'date' : event.get_date(), 'date' : date,
'endnotes' : self.endnotes(event), 'endnotes' : self.endnotes(event),
'place' : event.get_place_name() }) 'place' : place })
elif date: elif date:
self.doc.write_text(_('%(event_name)s: %(date)s%(endnotes)s. ') % { self.doc.write_text(_('%(event_name)s: %(date)s%(endnotes)s. ') % {
'event_name' : _(event.get_name()), 'event_name' : _(event.get_name()),
'endnotes' : self.endnotes(event), 'endnotes' : self.endnotes(event),
'date' : event.get_date()}) 'date' : date})
else: else:
self.doc.write_text(_('%(event_name)s: %(place)s%(endnotes)s. ') % { self.doc.write_text(_('%(event_name)s: %(place)s%(endnotes)s. ') % {
'event_name' : _(event.get_name()), 'event_name' : _(event.get_name()),
'endnotes' : self.endnotes(event), 'endnotes' : self.endnotes(event),
'place' : event.get_place_name() }) 'place' : place })
if event.get_description(): if event.get_description():
self.doc.write_text(event.get_description()) self.doc.write_text(event.get_description())
self.doc.end_paragraph() self.doc.end_paragraph()
@ -549,77 +576,109 @@ class FtmAncestorReport(Report.Report):
family_list = person.get_family_id_list() family_list = person.get_family_id_list()
if not family_list: if not family_list:
return return
family = family_list[0] family_id = family_list[0]
if family.get_father_id() == person: family = self.database.find_family_from_id(family_id)
spouse = family.get_mother_id() if family.get_father_id() == person.get_id():
spouse_id = family.get_mother_id()
else: else:
spouse = family.get_father_id() spouse_id = family.get_father_id()
if not spouse: if not spouse_id:
return return
event = family.get_marriage() spouse = self.database.find_person_from_id(spouse_id)
if not event: spouse_name = spouse.get_primary_name().get_regular_name()
for event_id in family.get_event_list():
if event_id:
event = self.database.find_event_from_id(event_id)
if event.get_name() == "Marriage":
break
else:
return return
date = event.get_date() date = event.get_date()
place = event.get_place_name() place_id = event.get_place_id()
if place_id:
place = self.database.find_place_from_id(place_id).get_title()
else:
place = u''
if date and place: if date and place:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
self.doc.write_text(_('He married %(spouse)s %(date)s in %(place)s%(endnotes)s.') % { self.doc.write_text(_('He married %(spouse)s %(date)s in %(place)s%(endnotes)s.') % {
'spouse' : spouse.get_primary_name().get_regular_name(), 'spouse' : spouse_name,
'endnotes' : self.endnotes(event), 'endnotes' : self.endnotes(event),
'date' : date, 'date' : date,
'place' : place}) 'place' : place})
else: else:
self.doc.write_text(_('She married %(spouse)s %(date)s in %(place)s%(endnotes)s.') % { self.doc.write_text(_('She married %(spouse)s %(date)s in %(place)s%(endnotes)s.') % {
'spouse' : spouse.get_primary_name().get_regular_name(), 'spouse' : spouse_name,
'date' : date, 'date' : date,
'endnotes' : self.endnotes(event), 'endnotes' : self.endnotes(event),
'place' : place}) 'place' : place})
elif date: elif date:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
self.doc.write_text(_('He married %(spouse)s %(date)s%(endnotes)s.') % { self.doc.write_text(_('He married %(spouse)s %(date)s%(endnotes)s.') % {
'spouse' : spouse.get_primary_name().get_regular_name(), 'spouse' : spouse_name,
'endnotes' : self.endnotes(event), 'endnotes' : self.endnotes(event),
'date' : date,}) 'date' : date,})
else: else:
self.doc.write_text(_('She married %(spouse)s in %(place)s%(endnotes)s.') % { self.doc.write_text(_('She married %(spouse)s in %(place)s%(endnotes)s.') % {
'spouse' : spouse.get_primary_name().get_regular_name(), 'spouse' : spouse_name,
'endnotes' : self.endnotes(event), 'endnotes' : self.endnotes(event),
'place' : place,}) 'place' : place,})
elif place: elif place:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
self.doc.write_text(_('He married %(spouse)s in %(place)s%(endnotes)s.') % { self.doc.write_text(_('He married %(spouse)s in %(place)s%(endnotes)s.') % {
'spouse' : spouse.get_primary_name().get_regular_name(), 'spouse' : spouse_name,
'endnotes' : self.endnotes(event), 'endnotes' : self.endnotes(event),
'place' : place}) 'place' : place})
else: else:
self.doc.write_text(_('She married %(spouse)s in %(place)s%(endnotes)s.') % { self.doc.write_text(_('She married %(spouse)s in %(place)s%(endnotes)s.') % {
'spouse' : spouse.get_primary_name().get_regular_name(), 'spouse' : spouse_name,
'endnotes' : self.endnotes(event), 'endnotes' : self.endnotes(event),
'place' : place}) 'place' : place})
else: else:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
self.doc.write_text(_('He married %(spouse)s%(endnotes)s.') % { self.doc.write_text(_('He married %(spouse)s%(endnotes)s.') % {
'spouse' : spouse.get_primary_name().get_regular_name(), 'spouse' : spouse_name,
'endnotes' : self.endnotes(event), 'endnotes' : self.endnotes(event),
}) })
else: else:
self.doc.write_text(_('She married %(spouse)s%(endnotes)s.') % { self.doc.write_text(_('She married %(spouse)s%(endnotes)s.') % {
'spouse' : spouse.get_primary_name().get_regular_name(), 'spouse' : spouse_name,
'endnotes' : self.endnotes(event), 'endnotes' : self.endnotes(event),
}) })
self.doc.write_text(' ') self.doc.write_text(' ')
death = spouse.get_death() death_id = spouse.get_death_id()
dplace = death.get_place_name() if death_id:
death_valid = 1
death = self.database.find_event_from_id(death_id)
ddate = death.get_date() ddate = death.get_date()
place_id = death.get_place_id()
if place_id:
dplace = self.database.find_place_from_id(place_id).get_title()
else:
dplace = u''
else:
death_valid = 0
dplace = u''
ddate = u''
birth = spouse.get_birth() birth_id = spouse.get_birth_id()
bplace = birth.get_place_name() if birth_id:
birth_valid = 1
birth = self.database.find_event_from_id(birth_id)
bdate = birth.get_date() bdate = birth.get_date()
place_id = birth.get_place_id()
death_valid = ddate != "" or dplace != "" if place_id:
birth_valid = bdate != "" or bplace != "" bplace = self.database.find_place_from_id(place_id).get_title()
else:
bplace = u''
else:
birth_valid = 0
bplace = u''
bdate = u''
if birth_valid or death_valid: if birth_valid or death_valid:
if spouse.get_gender() == RelLib.Person.male: if spouse.get_gender() == RelLib.Person.male:
@ -897,58 +956,66 @@ class FtmAncestorReport(Report.Report):
def print_parents(self,person,dead): def print_parents(self,person,dead):
family = person.get_main_parents_family_id() family_id = person.get_main_parents_family_id()
if family: if family_id:
mother = family.get_mother_id() family = self.database.find_family_from_id(family_id)
father = family.get_father_id() mother_id = family.get_mother_id()
father_id = family.get_father_id()
if mother_id:
mother = self.database.find_person_from_id(mother_id)
mother_name = mother.get_primary_name().get_regular_name()
if father_id:
father = self.database.find_person_from_id(father_id)
father_name = father.get_primary_name().get_regular_name()
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
if mother and father: if mother_id and father_id:
if dead: if dead:
self.doc.write_text(_("He was the son of %(father)s and %(mother)s.") % { self.doc.write_text(_("He was the son of %(father)s and %(mother)s.") % {
'father' : father.get_primary_name().get_regular_name(), 'father' : father_name,
'mother' : mother.get_primary_name().get_regular_name(), }) 'mother' : mother_name, })
else: else:
self.doc.write_text(_("He is the son of %(father)s and %(mother)s.") % { self.doc.write_text(_("He is the son of %(father)s and %(mother)s.") % {
'father' : father.get_primary_name().get_regular_name(), 'father' : father_name,
'mother' : mother.get_primary_name().get_regular_name(), }) 'mother' : mother_name, })
elif mother: elif mother_id:
if dead: if dead:
self.doc.write_text(_("He was the son of %(mother)s.") % { self.doc.write_text(_("He was the son of %(mother)s.") % {
'mother' : mother.get_primary_name().get_regular_name(), }) 'mother' : mother_name, })
else: else:
self.doc.write_text(_("He is the son of %(mother)s.") % { self.doc.write_text(_("He is the son of %(mother)s.") % {
'mother' : mother.get_primary_name().get_regular_name(), }) 'mother' : mother_name, })
elif father: elif father_id:
if dead: if dead:
self.doc.write_text(_("He was the son of %(father)s.") % { self.doc.write_text(_("He was the son of %(father)s.") % {
'father' : father.get_primary_name().get_regular_name(), }) 'father' : father_name, })
else: else:
self.doc.write_text(_("He is the son of %(father)s.") % { self.doc.write_text(_("He is the son of %(father)s.") % {
'father' : father.get_primary_name().get_regular_name(), }) 'father' : father_name, })
else: else:
if mother and father: if mother_id and father_id:
if dead: if dead:
self.doc.write_text(_("She was the daughter of %(father)s and %(mother)s.") % { self.doc.write_text(_("She was the daughter of %(father)s and %(mother)s.") % {
'father' : father.get_primary_name().get_regular_name(), 'father' : father_name,
'mother' : mother.get_primary_name().get_regular_name(), }) 'mother' : mother_name, })
else: else:
self.doc.write_text(_("She is the daughter of %(father)s and %(mother)s.") % { self.doc.write_text(_("She is the daughter of %(father)s and %(mother)s.") % {
'father' : father.get_primary_name().get_regular_name(), 'father' : father_name,
'mother' : mother.get_primary_name().get_regular_name(), }) 'mother' : mother_name, })
elif mother: elif mother_id:
if dead: if dead:
self.doc.write_text(_("She was the daughter of %(mother)s.") % { self.doc.write_text(_("She was the daughter of %(mother)s.") % {
'mother' : mother.get_primary_name().get_regular_name(), }) 'mother' : mother_name, })
else: else:
self.doc.write_text(_("She is the daughter of %(mother)s.") % { self.doc.write_text(_("She is the daughter of %(mother)s.") % {
'mother' : mother.get_primary_name().get_regular_name(), }) 'mother' : mother_name, })
elif father: elif father_id:
if dead: if dead:
self.doc.write_text(_("She was the daughter of %(father)s.") % { self.doc.write_text(_("She was the daughter of %(father)s.") % {
'father' : father.get_primary_name().get_regular_name(), }) 'father' : father_name, })
else: else:
self.doc.write_text(_("She is the daughter of %(father)s.") % { self.doc.write_text(_("She is the daughter of %(father)s.") % {
'father' : father.get_primary_name().get_regular_name(), }) 'father' : father_name, })
self.doc.write_text(' '); self.doc.write_text(' ');