* src/plugins/IndivComplete.py: Convert to db interface.

* src/plugins/DescendReport.py: Convert to db interface.
* src/plugins/DetAncestralReport.py: Convert to db interface.


svn: r3110
This commit is contained in:
Alex Roitman 2004-04-26 04:17:01 +00:00
parent 7da6142e25
commit 65d5b97a2d
4 changed files with 354 additions and 391 deletions

View File

@ -1,3 +1,8 @@
2004-04-25 Alex Roitman <shura@alex.neuro.umn.edu>
* src/plugins/IndivComplete.py: Convert to db interface.
* src/plugins/DescendReport.py: Convert to db interface.
* src/plugins/DetAncestralReport.py: Convert to db interface.
2004-04-24 Alex Roitman <shura@alex.neuro.umn.edu>
* src/docgen/RTFDoc.py: Typo.
* src/Utils.py (get_xpm_image): Add function.

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2003 Donald N. Allingham
# Copyright (C) 2000-2004 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -18,6 +18,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
"Generate files/Descendant Report"
#------------------------------------------------------------------------
@ -36,7 +38,8 @@ import sort
import Report
import BaseDoc
import Errors
import Date
from Utils import get_xpm_image
from QuestionDialog import ErrorDialog
from gettext import gettext as _
@ -58,6 +61,7 @@ _DIED = _('d.')
class DescendantReport:
def __init__(self,database,person,max,pgbrk,doc,output,newpage=0):
self.database = database
self.creator = database.get_researcher().get_name()
self.name = output
self.person = person
@ -73,16 +77,28 @@ class DescendantReport:
self.standalone = 0
def dump_dates(self, person):
birth = person.get_birth().get_date_object().get_start_date()
death = person.get_death().get_date_object().get_start_date()
if birth.getYearValid() or death.getYearValid():
birth_id = person.get_birth_id()
if birth_id:
birth = self.database.find_event_from_id(birth_id).get_date_object().get_start_date()
birth_year_valid = birth.get_year_valid()
else:
birth_year_valid = 0
death_id = person.get_death_id()
if death_id:
death = self.database.find_event_from_id(death_id).get_date_object().get_start_date()
death_year_valid = death.get_year_valid()
else:
death_year_valid = 0
if birth_year_valid or death_year_valid:
self.doc.write_text(' (')
if birth.getYearValid():
self.doc.write_text("%s %d" % (_BORN,birth.getYear()))
if death.getYearValid():
if birth.getYearValid():
if birth_year_valid:
self.doc.write_text("%s %d" % (_BORN,birth.get_year()))
if death_year_valid:
if birth_year_valid:
self.doc.write_text(', ')
self.doc.write_text("%s %d" % (_DIED,death.getYear()))
self.doc.write_text("%s %d" % (_DIED,death.get_year()))
self.doc.write_text(')')
def write_report(self):
@ -110,14 +126,38 @@ class DescendantReport:
return
childlist = []
for family in person.get_family_id_list():
for child in family.get_child_id_list():
childlist.append(child)
for family_id in person.get_family_id_list():
family = self.database.find_family_from_id(family_id)
for child_id in family.get_child_id_list():
childlist.append(child_id)
childlist.sort(sort.by_birthdate)
for child in childlist:
childlist.sort(self.by_birthdate)
for child_id in childlist:
child = self.database.find_person_from_id(child_id)
self.dump(level+1,child)
def by_birthdate(self, first_id, second_id) :
"""Sort routine for comparing two people by birth dates.
If the birth dates are equal, sorts by name"""
first = self.database.find_person_from_id(first_id)
second = self.database.find_person_from_id(second_id)
birth1_id = first.get_birth_id()
if birth1_id:
date1 = self.database.find_event_from_id(birth1_id).get_date_object()
else:
date1 = Date.Date()
birth2_id = second.get_birth_id()
if birth2_id:
date2 = self.database.find_event_from_id(birth2_id).get_date_object()
else:
date2 = Date.Date()
val = Date.compare_dates(date1,date2)
if val == 0:
return sort.by_last_name(first,second)
return val
#------------------------------------------------------------------------
#
# DescendantReportDialog
@ -301,96 +341,6 @@ def _make_default_style(default_style):
p.set_description(_("The style used for the level %d display.") % i)
default_style.add_style("DR-Level%d" % i,p)
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
def get_xpm_image():
return [
"48 48 33 1",
" c None",
". c #1A1A1A",
"+ c #6A665E",
"@ c #A6A6A6",
"# c #BABAB6",
"$ c #E9D9C0",
"% c #E6E6E6",
"& c #7A7262",
"* c #867A6E",
"= c #C2C2BE",
"- c #5C5854",
"; c #898783",
"> c #EEEEEC",
", c #B2966E",
"' c #4E4E4E",
") c #BCA076",
"! c #FAFAFA",
"~ c #CECBC1",
"{ c #E2CBA5",
"] c #DAD6D1",
"^ c #D2D1D0",
"/ c #9E9286",
"( c #ECE1D1",
"_ c #423E3E",
": c #A29E96",
"< c #B7AC9A",
"[ c #DAD2C6",
"} c #E6E2E2",
"| c #E1DFDC",
"1 c #322E2A",
"2 c #E6D2B6",
"3 c #F5F2EF",
"4 c #F1EADE",
" ",
" ",
" ;*;*****&&&+&++++---+& ",
" *##############<#<:;--& ",
" *#!!!!!!!!!!!!!!4}^#;;/' ",
" ;#!!!!!!!!!!!!!!!3}^@&~/_ ",
" *#!!!!!!!!!!!!!!!!3}^-%~;1 ",
" *#!!!!@@@@@@@@@@@@@@@'!}~;1 ",
" *#!!!!!!!!!!!!!!!!3!3'!!}~;1 ",
" *#!!!!!!!!!!!!!!!!!!!'4!!|~;_ ",
" *#!!!!3!!!!!!!!!!!!!!'}4!!}~/' ",
" &#!!!!@@:@:@:@:@@@!!3'~}3!!}#/+ ",
" &#!!!!!!!!!!!!!!!!!!!'..1_'-&*+& ",
" *#!!!!!!!!@@@@@:@@@@%!3#@:;*+-_+ ",
" &#!!!!!!!!!!!!!!!!!!!!>|~=:;;*'_ ",
" &#!!!!!!!!@:@@@@:@@@^|>%^~#::;+_ ",
" &#!!!!!!!!!!!!!!!!!!!!3%>^~#@:&1 ",
" &#!!!!!!!!@@@@@@@@@@%>3%|~^~#@*1 ",
" &<!!!!!!!!!!!!!!!!!!33!3>>]=~<;1 ",
" +#!!!!@@@@@:@@@:@]%33>>>>>[~~~;1 ",
" +#!!!!!!!!!!!!!!!!!33333>}^[=#;1 ",
" +#!!!!!!!!@@@@@@:@@@]>>>44]2{[/1 ",
" +#!!!!!!!!!!!!!!!33333444}(([~/1 ",
" +#!!!!33!3@@@@@@:@::]}|}||[2^{:1 ",
" +#!!!!!!!!!!!!!!>3333>4}44$[2~,1 ",
" +#!!!!!!!!33!>@@@@@@@@@@^}|${[/1 ",
" +#!!!!!!!!!!!!33334444(((44$2[,1 ",
" -#!!!!3333333%:::::::::/]||$2^,1 ",
" +#!!!!!!!!!3333>>44|(((((4($2{:1 ",
" -#!!!!!!!!:@@:::::::~]}}|$$$22,1 ",
" +#!!!!!!!!33333(44}44(44((($22/1 ",
" -#!!!!@@@:@::::::]}|||$||$]222)1 ",
" -#!!!!!33333(>4}444((($$$22222,1 ",
" -#!!!!!!!!::::::/://]$$$$($2{2,1 ",
" -#!!!333333444|((((($$$$[2$22{)1 ",
" -#!!!33334::/:::////[[]$2$22{{)1 ",
" '#!33333334}(((((($$$2222$22{{,1 ",
" -#33333333:::///////{2[{2[{{{{)1 ",
" '#3333%44}4((4(($$$$2222222{{{,1 ",
" '#33334444(((((2$$222222{{{{{{,1 ",
" '<334444((((($$$2$222{{2{{{{{{,1 ",
" -@3444444((($4$$$$2222{{{{{{{{,1 ",
" '#4444(((4$($$$$2$2${2{{{{{{{{,1 ",
" '<##<<<<<<<)))<)))))),,,,,,,,,,1 ",
" 11111111111111111111111111.11111 ",
" ",
" ",
" "]
#------------------------------------------------------------------------
#
#

View File

@ -74,13 +74,15 @@ class DetAncestorReport(Report.Report):
#
#
#--------------------------------------------------------------------
def filter(self,person,index):
if person == None or index >= 2**self.max_generations:
def filter(self,person_id,index):
if (not person_id) or (index >= 2**self.max_generations):
return
self.map[index] = person
self.map[index] = person_id
family = person.get_main_parents_family_id()
if family != None:
person = self.database.find_person_from_id(person_id)
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)
self.filter(family.get_mother_id(),(index*2)+1)
@ -109,15 +111,23 @@ class DetAncestorReport(Report.Report):
NAME 0
"""
num_children= len(family.get_child_id_list())
num_children = len(family.get_child_id_list())
if num_children > 0:
self.doc.start_paragraph("DAR-ChildTitle")
if family.get_mother_id() != None:
mother= family.get_mother_id().get_primary_name().get_regular_name()
else: mother= "unknown"
if family.get_father_id() != None:
father= family.get_father_id().get_primary_name().get_regular_name()
else: father= "unknown"
mother_id = family.get_mother_id()
if mother_id:
mother_obj = self.database.find_person_from_id(mother_id)
mother = mother_obj.get_primary_name().get_regular_name()
else:
mother = "unknown"
father_id = family.get_father_id()
if father_id:
father_obj = self.database.find_person_from_id(father_id)
father = father_obj.get_primary_name().get_regular_name()
else:
father = "unknown"
self.doc.start_bold()
if num_children == 1:
self.doc.write_text(_("Child of %s and %s is:") % (mother, father))
@ -125,80 +135,106 @@ class DetAncestorReport(Report.Report):
self.doc.end_bold()
self.doc.end_paragraph()
for child in family.get_child_id_list():
for child_id in family.get_child_id_list():
self.doc.start_paragraph("DAR-ChildList")
name= child.get_primary_name().get_regular_name()
birth= child.get_birth()
death= child.get_death()
child = self.database.find_person_from_id(child_id)
name = child.get_primary_name().get_regular_name()
birth_id = child.get_birth_id()
death_id = child.get_death_id()
if rptOptions.childRef == reportOptions.Yes:
childID= child.get_id()
if self.prevGenIDs.get(childID) != None:
name= "[" + str(self.prevGenIDs.get(childID)) + "] "+ name
if birth.get_date() != "":
if birth.get_place_name() != "":
if death.get_date() != "":
if death.get_place_name() != "":
if self.prevGenIDs.get(child_id) != None:
name= "[" + str(self.prevGenIDs.get(child_id)) + "] "+ name
if birth_id:
birth = self.database.find_event_from_id(birth_id)
else:
birth = None
if death_id:
death = self.database.find_event_from_id(death_id)
else:
death = None
if birth and birth.get_date():
if birth.get_place_id():
bplace = self.database.find_place_from_id(birth.get_place_id()).get_title()
if death and death.get_date():
if death.get_place_id():
dplace = self.database.find_place_from_id(death.get_place_id()).get_title()
self.doc.write_text(_("- %s Born: %s %s Died: %s %s") % \
(name, birth.get_date(), birth.get_place_name(),
death.get_date(), death.get_place_name())) # f
(name, birth.get_date(), bplace,
death.get_date(), dplace)) # f
else:
self.doc.write_text(_("- %s Born: %s %s Died: %s") % \
(name, birth.get_date(), birth.get_place_name(),
(name, birth.get_date(), bplace,
death.get_date())) # e
elif death.get_place_name() != "":
elif death and death.get_place_id():
dplace = self.database.find_place_from_id(death.get_place_id()).get_title()
self.doc.write_text(_("- %s Born: %s %s Died: %s") % \
(name, birth.get_date(), birth.get_place_name(),
death.get_place_name())) # d
else: self.doc.write_text(_("- %s Born: %s %s") % \
(name, birth.get_date(), birth.get_place_name())) # c
(name, birth.get_date(), bplace,
dplace)) # d
else:
if death.get_date() != "":
if death.get_place_name() != "":
self.doc.write_text(_("- %s Born: %s %s") % \
(name, birth.get_date(), bplace)) # c
else:
if death and death.get_date():
if death.get_place_id():
dplace = self.database.find_place_from_id(death.get_place_id()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s %s") % \
(name, birth.get_date(), death.get_date(), \
death.get_place_name())) # b
dplace)) # b
else:
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, birth.get_date(), death.get_date())) # a
elif death.get_place_name() != "":
elif death and death.get_place_id():
dplace = self.database.find_place_from_id(death.get_place_id()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, birth.get_date(), death.get_place_name())) # 9
else: self.doc.write_text(_("- %s Born: %s") % \
(name, birth.get_date(), dplace)) # 9
else:
self.doc.write_text(_("- %s Born: %s") % \
(name, birth.get_date())) # 8
else:
if birth.get_place_name() != "":
if death.get_date() != "":
if death.get_place_name() != "":
if birth and birth.get_place_id():
bplace = self.database.find_place_from_id(birth.get_place_id()).get_title()
if death and death.get_date():
if death.get_place_id():
dplace = self.database.find_place_from_id(death.get_place_id()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s %s") % \
(name, birth.get_place_name(), \
death.get_date(), death.get_place_name())) # 7
(name, bplace, \
death.get_date(), dplace)) # 7
else:
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, birth.get_place_name(), death.get_date())) # 6
elif death.get_place_name() != "":
(name, bplace, death.get_date())) # 6
elif death and death.get_place_id():
dplace = self.database.find_place_from_id(death.get_place_id()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, birth.get_place_name(), death.get_place_name())) # 5
else: self.doc.write_text(_("- %s Born: %s") % \
(name, birth.get_place_name())) # 4
(name, bplace, dplace)) # 5
else:
if death.get_date() != "":
if death.get_place_name() != "":
self.doc.write_text(_("- %s Born: %s") % \
(name, bplace)) # 4
else:
if death and death.get_date():
if death.get_place_id():
dplace = self.database.find_place_from_id(death.get_place_id()).get_title()
self.doc.write_text(_("- %s Died: %s %s") % \
(name, death.get_date(), death.get_place_name())) # 3
(name, death.get_date(), dplace)) # 3
else:
self.doc.write_text(_("- %s Died: %s") % \
(name, death.get_date())) # 2
elif death.get_place_name() != "":
elif death.get_place_id():
dplace = self.database.find_place_from_id(death.get_place_id()).get_title()
self.doc.write_text(_("- %s Died: %s") % \
(name, death.get_place_name())) # 1
else: self.doc.write_text(_("- %s") % name) # 0
(name, dplace)) # 1
else:
self.doc.write_text(_("- %s") % name) # 0
self.doc.end_paragraph()
def write_person(self, key, rptOptions):
"""Output birth, death, parentage, marriage and notes information """
person = self.map[key]
person_id = self.map[key]
person = self.database.find_person_from_id(person_id)
if rptOptions.addImages == reportOptions.Yes:
self.insert_images(person)
@ -222,16 +258,18 @@ class DetAncestorReport(Report.Report):
keys = self.map.keys()
keys.sort()
for dkey in keys:
if dkey >= key: break
if self.map[key].get_id() == self.map[dkey].get_id():
if dkey >= key:
break
if self.map[key] == self.map[dkey]:
self.doc.write_text(_(" is the same person as [%s].") % str(dkey))
self.doc.end_paragraph()
return 1 # Duplicate person
# Check birth record
birth = person.get_birth()
if birth:
birth_id = person.get_birth_id()
if birth_id:
self.write_birth(person, rptOptions)
if person.get_death_id():
self.write_death(person, firstName, rptOptions)
self.write_parents(person, firstName)
self.write_marriage(person, rptOptions)
@ -262,11 +300,12 @@ class DetAncestorReport(Report.Report):
was born in ____________.
"""
birth = person.get_birth()
if birth:
birth_id = person.get_birth_id()
if birth_id:
birth = self.database.find_event_from_id(birth_id)
date = birth.get_date_object().get_start_date()
if birth.get_place_name() != "":
place = birth.get_place_name()
if birth.get_place_id():
place = self.database.find_place_from_id(birth.get_place_id()).get_title()
if place[-1:] == '.':
place = place[:-1]
elif rptOptions.blankDate == reportOptions.Yes:
@ -274,18 +313,18 @@ class DetAncestorReport(Report.Report):
else: place= ""
if date.get_date() != "":
if date.getDayValid() and date.getMonthValid() and \
if date.get_day_valid() and date.get_month_valid() and \
rptOptions.fullDate == reportOptions.Yes:
if place != "":
if place:
self.doc.write_text(_(" was born on %s in %s.") % (date.get_date(), place))
else:
self.doc.write_text(_(" was born on %s.") % date.get_date())
elif place != "":
elif place:
self.doc.write_text(_(" was born in the year %s in %s.") % \
(date.getYear(), place))
(date.get_year(), place))
else:
self.doc.write_text(_(" was born in the year %s.") % date.getYear())
elif place != "":
self.doc.write_text(_(" was born in the year %s.") % date.get_year())
elif place:
self.doc.write_text(_(" was born in %s.") % place)
else:
self.doc.write_text(_("."))
@ -320,35 +359,39 @@ class DetAncestorReport(Report.Report):
.
"""
t= ""
death = person.get_death()
if death != None:
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()
place = death.get_place_name()
if death.get_place_id():
place = self.database.find_place_from_id(death.get_place_id()).get_title()
if place[-1:] == '.':
place = place[:-1]
elif place == "" and rptOptions.blankPlace == reportOptions.Yes:
elif rptOptions.blankPlace == reportOptions.Yes:
place= "_____________"
else:
place = ""
if date.get_date() != "":
if date.getDay() and date.getMonth() and \
if date.get_date():
if date.get_day() and date.get_month() and \
rptOptions.fullDate == reportOptions.Yes:
fulldate= date.get_date()
elif date.getMonth() and rptOptions.fullDate == reportOptions.Yes:
fulldate= "%s %s" % (date.getMonth(), date.getYear())
elif date.get_month() and rptOptions.fullDate == reportOptions.Yes:
fulldate= "%s %s" % (date.get_month(), date.get_year())
else: fulldate= ""
elif rptOptions.blankDate == reportOptions.Yes:
fulldate= "_____________"
else: fulldate= ""
if fulldate != "":
if place != "":
if fulldate:
if place:
t= _(" %s died on %s in %s") % (firstName, fulldate, place)
else: t= _(" %s died on %s") % (firstName, fulldate)
elif date.getYear() > 0:
if place != "":
t= _(" %s died in %s in %s") % (firstName, date.getYear(), place)
else: t= _(" %s died in %s") % (firstName, date.getYear())
elif place != "":
elif date.get_year() > 0:
if place:
t= _(" %s died in %s in %s") % (firstName, date.get_year(), place)
else: t= _(" %s died in %s") % (firstName, date.get_year())
elif place:
t= _(" %s died in %s") % (firstName, place)
if rptOptions.calcAgeFlag == reportOptions.Yes:
@ -356,13 +399,15 @@ class DetAncestorReport(Report.Report):
if t != "":
self.doc.write_text(t)
else: return
else:
return
t= ""
famList= person.get_family_id_list()
famList = person.get_family_id_list()
if len(famList) > 0:
for fam in famList:
buried= None
for fam_id in famList:
fam = self.database.find_family_from_id(fam_id)
buried = None
if buried:
date = buried.get_date_object().get_start_date()
place = buried.get_place_name()
@ -398,19 +443,24 @@ class DetAncestorReport(Report.Report):
FIRSTNAME is the daughter of FATHER.
FIRSTNAME is the daughter of MOTHER.
"""
ext_family= person.get_main_parents_family_id()
if ext_family != None:
if ext_family.get_father_id() != None:
father= ext_family.get_father_id().get_primary_name().get_regular_name()
else: father= ""
if ext_family.get_mother_id() != None:
mother= ext_family.get_mother_id().get_primary_name().get_regular_name()
else: mother= ""
ext_family_id = person.get_main_parents_family_id()
if ext_family_id:
ext_family = self.database.find_family_from_id(ext_family_id)
if ext_family.get_father_id():
father_obj = self.database.find_person_from_id(ext_family.get_father_id())
father = father_obj.get_primary_name().get_regular_name()
else:
father= ""
if ext_family.get_mother_id():
mother_obj = self.database.find_person_from_id(ext_family.get_mother_id())
mother = mother_obj.get_primary_name().get_regular_name()
else:
mother= ""
if father != "" or mother != "":
if father or mother:
if person.get_gender() == RelLib.Person.male:
if father != "":
if mother != "":
if father:
if mother:
self.doc.write_text(_(" %s is the son of %s and %s.") % \
(firstName, father, mother))
else:
@ -420,8 +470,8 @@ class DetAncestorReport(Report.Report):
self.doc.write_text(_(" %s is the son of %s.") % \
(firstName, mother))
else:
if father != "":
if mother != "":
if father:
if mother:
self.doc.write_text(_(" %s is the daughter of %s and %s.") % \
(firstName, father, mother))
else:
@ -446,13 +496,15 @@ class DetAncestorReport(Report.Report):
if len(famList) > 0:
fam_num= 0
endOfSent= ""
for fam in famList:
for fam_id in famList:
fam = self.database.find_family_from_id(fam_id)
fam_num= fam_num + 1
spouse= ""
t= ""
if person.get_gender() == RelLib.Person.male:
if fam.get_mother_id() != None:
spouse= fam.get_mother_id().get_primary_name().get_regular_name()
if fam.get_mother_id():
mother = self.database.find_person_from_id(fam.get_mother_id())
spouse = mother.get_primary_name().get_regular_name()
if fam_num == 1:
heshe= _("He")
elif fam_num < len(famList):
@ -465,45 +517,54 @@ class DetAncestorReport(Report.Report):
heshe= _(",")
else: heshe= _("and she")
if fam.get_father_id() != None:
spouse= fam.get_father_id().get_primary_name().get_regular_name()
if fam.get_father_id():
father = self.database.find_person_from_id(fam.get_father_id())
spouse = father.get_primary_name().get_regular_name()
marriage= fam.get_marriage()
fulldate= ""
place= ""
if marriage != None:
if marriage.get_place_id() != None and \
marriage.get_place_name() != "":
place= marriage.get_place_name()
for event_id in fam.get_event_list():
if event_id:
event = self.database.find_event_from_id(event_id)
if event.get_name() == "Marriage":
marriage = event
break
else:
marriage = None
fulldate = ""
place = ""
if marriage:
if marriage.get_place_id():
place = self.database.find_place_from_id(marriage.get_place_id()).get_title()
elif rptOptions.blankPlace == reportOptions.Yes:
place= "____________"
date= marriage.get_date_object()
if date != None:
if date.getYearValid():
if date.getDayValid() and date.getMonthValid() and \
date = marriage.get_date_object()
if date:
if date.get_year_valid():
if date.get_day_valid() and date.get_month_valid() and \
rptOptions.fullDate == reportOptions.Yes:
fulldate= date.get_date()
elif rptOptions.blankDate == reportOptions.Yes:
fulldate= "__________"
if spouse != "":
if fulldate == "" and place == "":
if spouse:
if not fulldate and not place:
t= _(" %s married %s") % (heshe, spouse)
elif fulldate == "" and place != "":
elif not fulldate and place:
t= _(" %s married %s in %s") % (heshe, spouse, place)
elif fulldate != "" and place == "":
elif fulldate and not place:
t= _(" %s married %s on %s") % (heshe, spouse, fulldate)
else: t= _(" %s married %s on %s in %s") % \
else:
t= _(" %s married %s on %s in %s") % \
(heshe, spouse, fulldate, place)
else:
if fulldate == "" and place == "":
if not fulldate and not place:
t= _(" %s married") % heshe
elif fulldate == "" and place != "":
elif not fulldate and place:
t= _(" %s married in %s") % (heshe, place)
elif fulldate != "" and place == "":
elif fulldate and not place:
t= _(" %s married on %s") % (heshe, fulldate)
elif fulldate != "" and place != "":
elif fulldate and place:
t= _(" %s married on %s in %s") % \
(heshe, fulldate, place)
@ -515,24 +576,27 @@ class DetAncestorReport(Report.Report):
def write_mate(self, mate, rptOptions):
"""Output birth, death, parentage, marriage and notes information """
famList= mate.get_family_id_list()
famList = mate.get_family_id_list()
if len(famList) > 0:
for fam in famList:
for fam_id in famList:
fam = self.database.find_family_from_id(fam_id)
person= ""
if mate.get_gender() == RelLib.Person.male:
if fam.get_mother_id() != None:
ind= fam.get_mother_id()
person= fam.get_mother_id().get_primary_name().get_regular_name()
firstName= fam.get_mother_id().get_primary_name().get_first_name()
heshe= _("She")
if fam.get_mother_id():
ind_id= fam.get_mother_id()
ind = self.database.find_person_from_id(ind_id)
person = ind.get_primary_name().get_regular_name()
firstName = ind.get_primary_name().get_first_name()
heshe = _("She")
else:
heshe= _("He")
if fam.get_father_id() != None:
ind= fam.get_father_id()
person= fam.get_father_id().get_primary_name().get_regular_name()
firstName= fam.get_father_id().get_primary_name().get_first_name()
if fam.get_father_id():
ind_id = fam.get_father_id()
ind = self.database.find_person_from_id(ind_id)
person = ind.get_primary_name().get_regular_name()
firstName = ind.get_primary_name().get_first_name()
if person != "":
if person:
if rptOptions.addImages == reportOptions.Yes:
self.insert_images(ind)
@ -579,7 +643,7 @@ class DetAncestorReport(Report.Report):
if self.newpage:
self.doc.page_break()
self.filter(self.start,1)
self.filter(self.start.get_id(),1)
#rptOpt= reportOptions()
rptOpt = self.rptOpt
@ -607,14 +671,16 @@ class DetAncestorReport(Report.Report):
self.prevGenIDs= self.genIDs.copy()
self.genIDs.clear()
person = self.map[key]
self.genIDs[person.get_id()]= key
person_id = self.map[key]
person = self.database.find_person_from_id(person_id)
self.genIDs[person_id]= key
dupPerson= self.write_person(key, rptOpt)
if dupPerson == 0: # Is this a duplicate ind record
if person.get_gender() == RelLib.Person.female and \
rptOpt.listChildren == reportOptions.Yes and \
len(person.get_family_id_list()) > 0:
family= person.get_family_id_list()[0]
family_id = person.get_family_id_list()[0]
family = self.database.find_family_from_id(family_id)
self.write_children(family, rptOpt)
#if rptOpt.addImages == reportOptions.Yes:
@ -691,6 +757,7 @@ class DetAncestorReportDialog(Report.TextReportDialog):
def __init__(self,database,person):
Report.TextReportDialog.__init__(self,database,person,self.report_options)
self.database = database
#------------------------------------------------------------------------
#
@ -862,7 +929,7 @@ class DetAncestorReportDialog(Report.TextReportDialog):
else:
self.addImages = reportOptions.No
rptOpt = reportOptions()
rptOpt = reportOptions(self.database)
rptOpt.firstName= self.firstName
rptOpt.fullDate= self.fullDate
rptOpt.listChildren= self.listChildren
@ -1114,7 +1181,7 @@ def write_book_item(database,person,doc,options,newpage=0):
person = database.get_person(options[0])
max_gen = int(options[1])
pg_brk = int(options[2])
rptOpt = reportOptions()
rptOpt = reportOptions(database)
rptOpt.firstName = int(options[3])
rptOpt.fullDate = int(options[4])
rptOpt.listChildren = int(options[5])
@ -1236,7 +1303,8 @@ class reportOptions:
Yes = 1
No = 0
def __init__(self):
def __init__(self,database):
self.database = database
### Initialize report options###
#Use first name in place of he or she in text
@ -1304,26 +1372,36 @@ class reportOptions:
null
"""
birth= ind.get_birth().get_date_object().get_start_date()
death= ind.get_death().get_date_object().get_start_date()
birth_id = ind.get_birth_id()
if birth_id:
birth = self.database.find_event_from_id(birth_id).get_date_object().get_start_date()
birth_year_valid = birth.get_year_valid()
else:
birth_year_valid = None
death_id = ind.get_death_id()
if death_id:
death = self.database.find_event_from_id(death_id).get_date_object().get_start_date()
death_year_valid = death.get_year_valid()
else:
death_year_valid = None
self.t= ""
if birth.getYearValid() and death.getYearValid():
self.age= death.getYear() - birth.getYear()
if birth_year_valid and death_year_valid:
self.age = death.get_year() - birth.get_year()
self.units= 3 # year
if birth.getMonthValid() and death.getMonthValid():
if birth.getMonth() > death.getMonth():
self.age= self.age -1
if birth.getDayValid() and death.getDayValid():
if birth.getMonth() == death.getMonth() and birth.getDay() > death.getDay():
self.age= self.age -1
if birth.get_month_valid() and death.get_month_valid():
if birth.get_month() > death.get_month():
self.age = self.age -1
if birth.get_day_valid() and death.get_day_valid():
if birth.get_month() == death.get_month() and birth.get_day() > death.get_day():
self.age = self.age -1
if self.age == 0:
self.age= death.getMonth() - birth.getMonth() # calc age in months
if birth.getDay() > death.getDay():
self.age= self.age - 1
self.age = death.get_month() - birth.get_month() # calc age in months
if birth.get_day() > death.get_day():
self.age = self.age - 1
self.units= 2 # month
if self.age == 0:
self.age= death.getDay() + 31 - birth.getDay() # calc age in days
self.units= 1 # day
self.age = death.get-day() + 31 - birth.get_day() # calc age in days
self.units = 1 # day
if self.age > 1:
if self.units == 1:
self.t= _(" at the age of %d days") % self.age

View File

@ -39,6 +39,7 @@ import StyleEditor
import Report
import GenericFilter
import Errors
from Utils import get_xpm_image
from QuestionDialog import ErrorDialog
from gettext import gettext as _
@ -122,7 +123,11 @@ class IndivComplete(Report.Report):
return
name = _(event.get_name())
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 = ""
description = event.get_description()
if date == "":
if place == "":
@ -141,7 +146,9 @@ class IndivComplete(Report.Report):
self.normal_cell(name)
if self.use_srcs:
for s in event.get_source_references():
text = "%s [%s]" % (text,s.get_base_id().get_id())
#src_id = s.get_base_id()
#src = self.database.find_source_from_id(src_id)
text = "%s [%s]" % (text,s.get_base_id())
self.slist.append(s)
self.normal_cell(text)
self.d.end_row()
@ -262,15 +269,17 @@ class IndivComplete(Report.Report):
self.d.end_cell()
self.d.end_row()
for family in self.person.get_family_id_list():
if self.person == family.get_father_id():
spouse = family.get_mother_id()
for family_id in self.person.get_family_id_list():
family = self.database.find_family_from_id(family_id)
if self.person.get_id() == family.get_father_id():
spouse_id = family.get_mother_id()
else:
spouse = family.get_father_id()
spouse_id = family.get_father_id()
self.d.start_row()
self.d.start_cell("IDS-NormalCell",2)
self.d.start_paragraph("IDS-Spouse")
if spouse:
if spouse_id:
spouse = self.database.find_person_from_id(spouse_id)
text = spouse.get_primary_name().get_regular_name()
else:
text = _("unknown")
@ -279,11 +288,13 @@ class IndivComplete(Report.Report):
self.d.end_cell()
self.d.end_row()
for event in family.get_event_list():
for event_id in family.get_event_list():
if event_id:
event = self.database.find_event_from_id(event_id)
self.write_fact(event)
child_list = family.get_child_id_list()
if len(child_list) > 0:
child_id_list = family.get_child_id_list()
if len(child_id_list) > 0:
self.d.start_row()
self.normal_cell(_("Children"))
@ -291,11 +302,12 @@ class IndivComplete(Report.Report):
self.d.start_paragraph("IDS-Normal")
first = 1
for child in family.get_child_id_list():
for child_id in child_id_list:
if first == 1:
first = 0
else:
self.d.write_text('\n')
child = self.database.find_person_from_id(child_id)
self.d.write_text(child.get_primary_name().get_regular_name())
self.d.end_paragraph()
self.d.end_cell()
@ -320,9 +332,10 @@ class IndivComplete(Report.Report):
for source in self.slist:
self.d.start_row()
sname = source.get_base_id()
self.normal_cell(sname.get_id())
self.normal_cell(sname.get_title())
s_id = source.get_base_id()
self.normal_cell(s_id)
src = self.database.find_source_from_id(s_id)
self.normal_cell(src.get_title())
self.d.end_row()
self.d.end_table()
@ -336,9 +349,11 @@ class IndivComplete(Report.Report):
self.d.end_cell()
self.d.end_row()
event_list = [ self.person.get_birth(), self.person.get_death() ]
event_list = event_list + self.person.get_event_list()
for event in event_list:
event_id_list = [ self.person.get_birth_id(), self.person.get_death_id() ]
event_id_list = event_id_list + self.person.get_event_list()
for event_id in event_id_list:
if event_id:
event = self.database.find_event_from_id(event_id)
self.write_fact(event)
self.d.end_table()
self.d.start_paragraph("IDS-Normal")
@ -355,14 +370,16 @@ class IndivComplete(Report.Report):
if self.newpage:
self.d.page_break()
plist = self.database.get_person_id_map().values()
#plist = self.database.get_person_id_map().values()
plist = self.database.get_person_keys()
if self.filter:
ind_list = self.filter.apply(self.database,plist)
else:
ind_list = plist
count = 0
for self.person in ind_list:
for person_id in ind_list:
self.person = self.database.find_person_from_id(person_id)
self.write_person(count)
count = count + 1
self.end()
@ -399,7 +416,7 @@ class IndivComplete(Report.Report):
if self.use_srcs:
for s in name.get_source_references():
self.slist.append(s)
text = "%s [%s]" % (text,s.get_base_id().get_id())
text = "%s [%s]" % (text,s.get_base_id())
self.normal_cell(text)
self.d.end_row()
@ -411,15 +428,18 @@ class IndivComplete(Report.Report):
self.normal_cell(_("Female"))
self.d.end_row()
family = self.person.get_main_parents_family_id()
if family:
father_inst = family.get_father_id()
if father_inst:
family_id = self.person.get_main_parents_family_id()
if family_id:
family = self.database.find_family_from_id(family_id)
father_inst_id = family.get_father_id()
if father_inst_id:
father_inst = self.database.find_person_from_id(father_inst_id)
father = father_inst.get_primary_name().get_regular_name()
else:
father = ""
mother_inst = family.get_mother_id()
if mother_inst:
mother_inst_id = family.get_mother_id()
if mother_inst_id:
mother_inst = self.database.find_person_from_id(mother_inst_id)
mother = mother_inst.get_primary_name().get_regular_name()
else:
mother = ""
@ -719,96 +739,6 @@ def _get_report_filters(person):
return [filt_id,des,ans,all]
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
def get_xpm_image():
return [
"48 48 33 1",
" c None",
". c #312D2A",
"+ c #4773AA",
"@ c #A8A7A5",
"# c #BABAB6",
"$ c #CECECE",
"% c #ECDECB",
"& c #5C5C60",
"* c #7C7262",
"= c #F2EADE",
"- c #867A6F",
"; c #8E887E",
"> c #E2CAA2",
", c #565354",
"' c #4C4E51",
") c #6D655E",
"! c #B69970",
"~ c #F6F2EE",
"{ c #9E9286",
"] c #416CA3",
"^ c #3D4557",
"/ c #A29E96",
"( c #FAFAFA",
"_ c #BA7458",
": c #C67C5E",
"< c #BDA37E",
"[ c #CECABE",
"} c #A26E62",
"| c #E6E2E2",
"1 c #423E43",
"2 c #966A60",
"3 c #D2D2D2",
"4 c #E5D2B8",
" ",
" ",
" ;-;-----***)*))))&,&)* ",
" -##############@#@/;&,* ",
" -#((((((((((((((=|$#;;{, ",
" ;#(((((((((((((((~|3/*[{1 ",
" -#((((((((((((((((~|3,|[;. ",
" -#((((((((@/@@@@@@/@/'(|[;. ",
" -#((((((((((((((((((~'((|[;. ",
" -#(((((((((((]+]+]]+('=((|[;1 ",
" -#(((((((((((]+]}2&+('|=((|[{, ",
" *#(((((((((((]+}<:-+('[|~((|#{) ",
" *#(((((((((((+]2_:)+('...1'&*-)* ",
" -#(((((((((((]&1(_&+(3@#//--)&1) ",
" *#~((((((((((+]1}/^]((|$##/;--'1 ",
" *#(((((((((((]]^)11,(((|$[#@/;)1 ",
" *#(((((((((((]^.^^&&((~=|$[#@/*. ",
" *#(((((((((((((~(((((((|$[$[#/-. ",
" *#~(((((((((((((((((~~~~||$[[@;. ",
" )#((((@@@@@@/@@/@/@@@@///{;[[[;. ",
" )#(((((((((((((((((~~~~==|$$[#;. ",
" )#((((@/@@/@@@@@@@@@//////{4>3{. ",
" )#(((((((((((((((~~~~==|=||%$[{. ",
" )#((((@@@@@/@@@///////////{43>/. ",
" )#((((((((((((((~~~~~==|||%>4[!. ",
" )#((((@/@@@@@//~~~~======%%%43{. ",
" )#((((((((((((~~~~=|==||=%%%44!. ",
" ,#((((@@/@@/@/@////////{/{{%4$!. ",
" )#~((((((((~~~~~~==||%=%=%%44>/. ",
" ,#((((/@@//@///////////{{{{%4>!. ",
" )#((((((((~~~=~||=|%%%%%4%%%44{. ",
" ,#((((@@@/@/////////{{{{{{{444!. ",
" &#(((((~~~~~|~|||%%|%%%%44444%!. ",
" ,#(((~/@//////////{{{{{{;{;4>4!. ",
" ,#(((~~~~=~|==|%|=%%%4%%44444>!. ",
" &#(((~//////////{{{{{{{;{;{4>><. ",
" ,#(~~~~~~==||%|%%%%%%44444>4>>!. ",
" '#~~~~///////{{{{{{{;!;{;;;>>>!. ",
" ,#~~~~||=||%|%=%%4%444>44>>>>>!. ",
" '#~~~~====%=%=%4%%444444>>>>>>!. ",
" '@~~====|%=%%%%%4%444>>4>>>>>>!. ",
" ,@~======%%%%%%>%%4444>>>>>>>>!. ",
" '#====||=%%%%4%44444>4>>>>>>>>!. ",
" ,@##@<#<<#@<<<<<<<<<<!<!!:!!!!!. ",
" ................................ ",
" ",
" ",
" "]
#------------------------------------------------------------------------
#
#