Relcal changes for plugins
svn: r1479
This commit is contained in:
parent
bc4128ba77
commit
5d09a26cd2
3
NEWS
3
NEWS
@ -1,3 +1,6 @@
|
||||
Version 0.9.2
|
||||
* Fixed duplicate place problem.
|
||||
|
||||
Version 0.9.1
|
||||
* Custom paper sizes may be set for reports
|
||||
* Witnesses may be added to an event. The witnesses do not have to be in
|
||||
|
@ -79,6 +79,19 @@ _textdoc = []
|
||||
_drawdoc = []
|
||||
_failmsg = []
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Default relationship calculator
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Relationship
|
||||
|
||||
_relcalc_task = Relationship.get_relationship
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
_unavailable = _("No description was provided"),
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -453,9 +466,13 @@ def register_tool(task, name,
|
||||
del_index = i
|
||||
if del_index != -1:
|
||||
del _tools[del_index]
|
||||
_tools.append((task, category, name, description, xpm, status, author_name, author_email))
|
||||
|
||||
_tools.append((task, category, name, description, xpm, status, author_name, author_name))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Text document registration
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def register_text_doc(name,classref, table, paper, style, ext):
|
||||
"""Register a text document generator"""
|
||||
for n in _textdoc:
|
||||
@ -463,6 +480,11 @@ def register_text_doc(name,classref, table, paper, style, ext):
|
||||
return
|
||||
_textdoc.append((name,classref,table,paper,style,ext))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Drawing document registration
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def register_draw_doc(name,classref,paper,style, ext):
|
||||
"""Register a drawing document generator"""
|
||||
for n in _drawdoc:
|
||||
@ -470,6 +492,23 @@ def register_draw_doc(name,classref,paper,style, ext):
|
||||
return
|
||||
_drawdoc.append((name,classref,paper,style,ext))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Relationchip calculator registration
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def register_relcalc(func, languages):
|
||||
"""Register a relationshp calculator"""
|
||||
import sys
|
||||
global _relcal_task
|
||||
|
||||
if sys.environ.get('LANG') in languages:
|
||||
_relcalc_task = func
|
||||
|
||||
def relationship_function():
|
||||
global _relcal_task
|
||||
return _relcalc_task
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Image attributes
|
||||
|
@ -33,148 +33,150 @@ import GrampsCfg
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
level_name = [ "", "First", "Second", "Third", "Fourth", "Fifth", "Sixth",
|
||||
"Seventh", "Eighth", "Ninth", "Tenth", "Eleventh", "Twelfth",
|
||||
"Thirteenth", "Fourteenth", "Fifteenth", "Sixteenth",
|
||||
"Seventeenth", "Eigthteenth", "Nineteenth", "Twentieth" ]
|
||||
_level_name = [ "", "first", "second", "third", "fourth", "fifth", "sixth",
|
||||
"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth",
|
||||
"thirteenth", "fourteenth", "fifteenth", "sixteenth",
|
||||
"seventeenth", "eigthteenth", "nineteenth", "twentieth" ]
|
||||
|
||||
removed_level = [ "", " once removed", " twice removed", " three times removed",
|
||||
" four times removed", " five times removed", " six times removed",
|
||||
" sevent times removed", " eight times removed", " nine times removed",
|
||||
" ten times removed", " eleven times removed", " twelve times removed",
|
||||
" thirteen times removed", " fourteen times removed", " fifteen times removed",
|
||||
" sixteen times removed", " seventeen times removed", " eighteen times removed",
|
||||
" nineteen times removed", " twenty times removed" ]
|
||||
_removed_level = [ "", " once removed", " twice removed", " three times removed",
|
||||
" four times removed", " five times removed", " six times removed",
|
||||
" sevent times removed", " eight times removed", " nine times removed",
|
||||
" ten times removed", " eleven times removed", " twelve times removed",
|
||||
" thirteen times removed", " fourteen times removed", " fifteen times removed",
|
||||
" sixteen times removed", " seventeen times removed", " eighteen times removed",
|
||||
" nineteen times removed", " twenty times removed" ]
|
||||
|
||||
father_level = [ "", "Father", "Grandfather", "Great Grandfather", "Second Great Grandfather",
|
||||
"Third Great Grandfather", "Fourth Great Grandfather",
|
||||
"Fifth Great Grandfather", "Sixth Great Grandfather",
|
||||
"Seventh Great Grandfather", "Eighth Great Grandfather",
|
||||
"Ninth Great Grandfather", "Tenth Great Grandfather",
|
||||
"Eleventh Great Grandfather", "Twelefth Great Grandfather",
|
||||
"Thirteenth Great Grandfather", "Fourteenth Great Grandfather",
|
||||
"Fifteenth Great Grandfather", "Sixteenth Great Grandfather",
|
||||
"Seventeenth Great Grandfather", "Eightteenth Great Grandfather",
|
||||
"Ninetheen Great Grandfather", "Twentieth Great Grandfather", ]
|
||||
_father_level = [ "", "father", "grandfather", "great grandfather", "second great grandfather",
|
||||
"third great grandfather", "fourth great grandfather",
|
||||
"fifth great grandfather", "sixth great grandfather",
|
||||
"seventh great grandfather", "eighth great grandfather",
|
||||
"ninth great grandfather", "tenth great grandfather",
|
||||
"eleventh great grandfather", "twelefth great grandfather",
|
||||
"thirteenth great grandfather", "fourteenth great grandfather",
|
||||
"fifteenth great grandfather", "sixteenth great grandfather",
|
||||
"seventeenth great grandfather", "eightteenth great grandfather",
|
||||
"ninetheen great grandfather", "twentieth great grandfather", ]
|
||||
|
||||
mother_level = [ "", "Mother", "Grandmother", "Great Grandmother", "Second Great Grandmother",
|
||||
"Third Great Grandmother", "Fourth Great Grandmother",
|
||||
"Fifth Great Grandmother", "Sixth Great Grandmother",
|
||||
"Seventh Great Grandmother", "Eighth Great Grandmother",
|
||||
"Ninth Great Grandmother", "Tenth Great Grandmother",
|
||||
"Eleventh Great Grandmother", "Twelefth Great Grandmother",
|
||||
"Thirteenth Great Grandmother", "Fourteenth Great Grandmother",
|
||||
"Fifteenth Great Grandmother", "Sixteenth Great Grandmother",
|
||||
"Seventeenth Great Grandmother", "Eightteenth Great Grandmother",
|
||||
"Ninetheen Great Grandmother", "Twentieth Great Grandmother", ]
|
||||
_mother_level = [ "", "mother", "grandmother", "great grandmother", "second great grandmother",
|
||||
"third great grandmother", "fourth great grandmother",
|
||||
"fifth great grandmother", "sixth great grandmother",
|
||||
"seventh great grandmother", "eighth great grandmother",
|
||||
"ninth great grandmother", "tenth great grandmother",
|
||||
"eleventh great grandmother", "twelefth great grandmother",
|
||||
"thirteenth great grandmother", "fourteenth great grandmother",
|
||||
"fifteenth great grandmother", "sixteenth great grandmother",
|
||||
"seventeenth great grandmother", "eightteenth great grandmother",
|
||||
"ninetheen great grandmother", "twentieth great grandmother", ]
|
||||
|
||||
son_level = [ "", "Son", "Grandson", "Great Grandson", "Second Great Grandson",
|
||||
"Third Great Grandson", "Fourth Great Grandson",
|
||||
"Fifth Great Grandson", "Sixth Great Grandson",
|
||||
"Seventh Great Grandson", "Eighth Great Grandson",
|
||||
"Ninth Great Grandson", "Tenth Great Grandson",
|
||||
"Eleventh Great Grandson", "Twelefth Great Grandson",
|
||||
"Thirteenth Great Grandson", "Fourteenth Great Grandson",
|
||||
"Fifteenth Great Grandson", "Sixteenth Great Grandson",
|
||||
"Seventeenth Great Grandson", "Eightteenth Great Grandson",
|
||||
"Ninetheen Great Grandson", "Twentieth Great Grandson", ]
|
||||
_son_level = [ "", "son", "grandson", "great grandson", "second great grandson",
|
||||
"third great grandson", "fourth great grandson",
|
||||
"fifth great grandson", "sixth great grandson",
|
||||
"seventh great grandson", "eighth great grandson",
|
||||
"ninth great grandson", "tenth great grandson",
|
||||
"eleventh great grandson", "twelefth great grandson",
|
||||
"thirteenth great grandson", "fourteenth great grandson",
|
||||
"fifteenth great grandson", "sixteenth great grandson",
|
||||
"seventeenth great grandson", "eightteenth great grandson",
|
||||
"ninetheen great grandson", "twentieth great grandson", ]
|
||||
|
||||
daughter_level = [ "", "Daughter", "Granddaughter", "Great Granddaughter", "Second Great Granddaughter",
|
||||
"Third Great Granddaughter", "Fourth Great Granddaughter",
|
||||
"Fifth Great Granddaughter", "Sixth Great Granddaughter",
|
||||
"Seventh Great Granddaughter", "Eighth Great Granddaughter",
|
||||
"Ninth Great Granddaughter", "Tenth Great Granddaughter",
|
||||
"Eleventh Great Granddaughter", "Twelefth Great Granddaughter",
|
||||
"Thirteenth Great Granddaughter", "Fourteenth Great Granddaughter",
|
||||
"Fifteenth Great Granddaughter", "Sixteenth Great Granddaughter",
|
||||
"Seventeenth Great Granddaughter", "Eightteenth Great Granddaughter",
|
||||
"Ninetheen Great Granddaughter", "Twentieth Great Granddaughter", ]
|
||||
_daughter_level = [ "", "daughter", "granddaughter", "great granddaughter",
|
||||
"second great granddaughter",
|
||||
"third great granddaughter", "fourth great granddaughter",
|
||||
"fifth great granddaughter", "sixth great granddaughter",
|
||||
"seventh great granddaughter", "eighth great granddaughter",
|
||||
"ninth great granddaughter", "tenth great granddaughter",
|
||||
"eleventh great granddaughter", "twelefth great granddaughter",
|
||||
"thirteenth great granddaughter", "fourteenth great granddaughter",
|
||||
"fifteenth great granddaughter", "sixteenth great granddaughter",
|
||||
"seventeenth great granddaughter", "eightteenth great granddaughter",
|
||||
"ninetheen great granddaughter", "twentieth great granddaughter", ]
|
||||
|
||||
sister_level = [ "", "Sister", "Aunt", "Grandaunt", "Great Grandaunt", "Second Great Grandaunt",
|
||||
"Third Great Grandaunt", "Fourth Great Grandaunt",
|
||||
"Fifth Great Grandaunt", "Sixth Great Grandaunt",
|
||||
"Seventh Great Grandaunt", "Eighth Great Grandaunt",
|
||||
"Ninth Great Grandaunt", "Tenth Great Grandaunt",
|
||||
"Eleventh Great Grandaunt", "Twelefth Great Grandaunt",
|
||||
"Thirteenth Great Grandaunt", "Fourteenth Great Grandaunt",
|
||||
"Fifteenth Great Grandaunt", "Sixteenth Great Grandaunt",
|
||||
"Seventeenth Great Grandaunt", "Eightteenth Great Grandaunt",
|
||||
"Ninetheen Great Grandaunt", "Twentieth Great Grandaunt", ]
|
||||
_sister_level = [ "", "sister", "aunt", "grandaunt", "great grandaunt", "second great grandaunt",
|
||||
"third great grandaunt", "fourth great grandaunt",
|
||||
"fifth great grandaunt", "sixth great grandaunt",
|
||||
"seventh great grandaunt", "eighth great grandaunt",
|
||||
"ninth great grandaunt", "tenth great grandaunt",
|
||||
"eleventh great grandaunt", "twelefth great grandaunt",
|
||||
"thirteenth great grandaunt", "fourteenth great grandaunt",
|
||||
"fifteenth great grandaunt", "sixteenth great grandaunt",
|
||||
"seventeenth great grandaunt", "eightteenth great grandaunt",
|
||||
"ninetheen great grandaunt", "twentieth great grandaunt", ]
|
||||
|
||||
brother_level = [ "", "Brother", "Uncle", "Granduncle", "Great Granduncle", "Second Great Granduncle",
|
||||
"Third Great Granduncle", "Fourth Great Granduncle",
|
||||
"Fifth Great Granduncle", "Sixth Great Granduncle",
|
||||
"Seventh Great Granduncle", "Eighth Great Granduncle",
|
||||
"Ninth Great Granduncle", "Tenth Great Granduncle",
|
||||
"Eleventh Great Granduncle", "Twelefth Great Granduncle",
|
||||
"Thirteenth Great Granduncle", "Fourteenth Great Granduncle",
|
||||
"Fifteenth Great Granduncle", "Sixteenth Great Granduncle",
|
||||
"Seventeenth Great Granduncle", "Eightteenth Great Granduncle",
|
||||
"Ninetheen Great Granduncle", "Twentieth Great Granduncle", ]
|
||||
_brother_level = [ "", "brother", "uncle", "granduncle", "great granduncle", "second great granduncle",
|
||||
"third great granduncle", "fourth great granduncle",
|
||||
"fifth great granduncle", "sixth great granduncle",
|
||||
"seventh great granduncle", "eighth great granduncle",
|
||||
"ninth great granduncle", "tenth great granduncle",
|
||||
"eleventh great granduncle", "twelefth great granduncle",
|
||||
"thirteenth great granduncle", "fourteenth great granduncle",
|
||||
"fifteenth great granduncle", "sixteenth great granduncle",
|
||||
"seventeenth great granduncle", "eightteenth great granduncle",
|
||||
"ninetheen great granduncle", "twentieth great granduncle", ]
|
||||
|
||||
nephew_level = [ "", "Nephew", "Grandnephew", "Great Grandnephew", "Second Great Grandnephew",
|
||||
"Third Great Grandnephew", "Fourth Great Grandnephew",
|
||||
"Fifth Great Grandnephew", "Sixth Great Grandnephew",
|
||||
"Seventh Great Grandnephew", "Eighth Great Grandnephew",
|
||||
"Ninth Great Grandnephew", "Tenth Great Grandnephew",
|
||||
"Eleventh Great Grandnephew", "Twelefth Great Grandnephew",
|
||||
"Thirteenth Great Grandnephew", "Fourteenth Great Grandnephew",
|
||||
"Fifteenth Great Grandnephew", "Sixteenth Great Grandnephew",
|
||||
"Seventeenth Great Grandnephew", "Eightteenth Great Grandnephew",
|
||||
"Ninetheen Great Grandnephew", "Twentieth Great Grandnephew", ]
|
||||
niece_level = [ "", "Niece", "Grandniece", "Great Grandniece", "Second Great Grandniece",
|
||||
"Third Great Grandniece", "Fourth Great Grandniece",
|
||||
"Fifth Great Grandniece", "Sixth Great Grandniece",
|
||||
"Seventh Great Grandniece", "Eighth Great Grandniece",
|
||||
"Ninth Great Grandniece", "Tenth Great Grandniece",
|
||||
"Eleventh Great Grandniece", "Twelefth Great Grandniece",
|
||||
"Thirteenth Great Grandniece", "Fourteenth Great Grandniece",
|
||||
"Fifteenth Great Grandniece", "Sixteenth Great Grandniece",
|
||||
"Seventeenth Great Grandniece", "Eightteenth Great Grandniece",
|
||||
"Ninetheen Great Grandniece", "Twentieth Great Grandniece", ]
|
||||
_nephew_level = [ "", "nephew", "grandnephew", "great grandnephew", "second great grandnephew",
|
||||
"third great grandnephew", "fourth great grandnephew",
|
||||
"fifth great grandnephew", "sixth great grandnephew",
|
||||
"seventh great grandnephew", "eighth great grandnephew",
|
||||
"ninth great grandnephew", "tenth great grandnephew",
|
||||
"eleventh great grandnephew", "twelefth great grandnephew",
|
||||
"thirteenth great grandnephew", "fourteenth great grandnephew",
|
||||
"fifteenth great grandnephew", "sixteenth great grandnephew",
|
||||
"seventeenth great grandnephew", "eightteenth great grandnephew",
|
||||
"ninetheen great grandnephew", "twentieth great grandnephew", ]
|
||||
|
||||
_niece_level = [ "", "niece", "grandniece", "great grandniece", "second great grandniece",
|
||||
"third great grandniece", "fourth great grandniece",
|
||||
"fifth great grandniece", "sixth great grandniece",
|
||||
"seventh great grandniece", "eighth great grandniece",
|
||||
"ninth great grandniece", "tenth great grandniece",
|
||||
"eleventh great grandniece", "twelefth great grandniece",
|
||||
"thirteenth great grandniece", "fourteenth great grandniece",
|
||||
"fifteenth great grandniece", "sixteenth great grandniece",
|
||||
"seventeenth great grandniece", "eightteenth great grandniece",
|
||||
"ninetheen great grandniece", "twentieth great grandniece", ]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def filter(person,index,list,map):
|
||||
def apply_filter(person,index,plist,pmap):
|
||||
if person == None:
|
||||
return
|
||||
list.append(person)
|
||||
map[person.getId()] = index
|
||||
plist.append(person)
|
||||
pmap[person.getId()] = index
|
||||
|
||||
family = person.getMainParents()
|
||||
if family != None:
|
||||
filter(family.getFather(),index+1,list,map)
|
||||
filter(family.getMother(),index+1,list,map)
|
||||
apply_filter(family.getFather(),index+1,plist,pmap)
|
||||
apply_filter(family.getMother(),index+1,plist,pmap)
|
||||
|
||||
def get_cousin(f,s,level,removed):
|
||||
return "%s cousin%s of %s" % (level_name[level],removed_level[removed],f)
|
||||
def get_cousin(level,removed):
|
||||
return "%s cousin%s" % (_level_name[level],_removed_level[removed])
|
||||
|
||||
def get_father(f,s,level):
|
||||
return "%s of %s" % (father_level[level],f)
|
||||
def get_father(level):
|
||||
return _father_level[level]
|
||||
|
||||
def get_son(f,s,level):
|
||||
return "%s of %s" % (son_level[level],f)
|
||||
def get_son(level):
|
||||
return _son_level[level]
|
||||
|
||||
def get_mother(f,s,level):
|
||||
return "%s of %s" % (mother_level[level],f)
|
||||
def get_mother(level):
|
||||
return _mother_level[level]
|
||||
|
||||
def get_daughter(f,s,level):
|
||||
return "%s of %s" % (daughter_level[level],f)
|
||||
def get_daughter(level):
|
||||
return _daughter_level[level]
|
||||
|
||||
def get_aunt(f,s,level):
|
||||
return "%s of %s" % (sister_level[level],f)
|
||||
def get_aunt(level):
|
||||
return _sister_level[level]
|
||||
|
||||
def get_uncle(f,s,level):
|
||||
return "%s of %s" % (brother_level[level],f)
|
||||
def get_uncle(level):
|
||||
return _brother_level[level]
|
||||
|
||||
def get_nephew(f,s,level):
|
||||
return "%s of %s" % (nephew_level[level],f)
|
||||
def get_nephew(level):
|
||||
return _nephew_level[level]
|
||||
|
||||
def get_niece(f,s,level):
|
||||
return "%s of %s" % (niece_level[level],f)
|
||||
def get_niece(level):
|
||||
return _niece_level[level],f
|
||||
|
||||
def is_spouse(orig,other):
|
||||
for f in orig.getFamilyList():
|
||||
@ -183,6 +185,10 @@ def is_spouse(orig,other):
|
||||
return 0
|
||||
|
||||
def get_relationship(orig_person,other_person):
|
||||
"""
|
||||
returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
"""
|
||||
firstMap = {}
|
||||
firstList = []
|
||||
secondMap = {}
|
||||
@ -191,18 +197,18 @@ def get_relationship(orig_person,other_person):
|
||||
rank = 9999999
|
||||
|
||||
if orig_person == None:
|
||||
return "No Home Person has been defined"
|
||||
return "undefined"
|
||||
|
||||
firstName = orig_person.getPrimaryName().getRegularName()
|
||||
secondName = other_person.getPrimaryName().getRegularName()
|
||||
|
||||
if orig_person == other_person:
|
||||
return firstName
|
||||
return ('', [])
|
||||
if is_spouse(orig_person,other_person):
|
||||
return "Spouse of %s" % (firstName)
|
||||
return ("spouse",[])
|
||||
|
||||
filter(orig_person,0,firstList,firstMap)
|
||||
filter(other_person,0,secondList,secondMap)
|
||||
apply_filter(orig_person,0,firstList,firstMap)
|
||||
apply_filter(other_person,0,secondList,secondMap)
|
||||
|
||||
for person in firstList:
|
||||
if person in secondList:
|
||||
@ -232,32 +238,32 @@ def get_relationship(orig_person,other_person):
|
||||
firstRel = secondMap[person.getId()]
|
||||
|
||||
if firstRel == -1:
|
||||
return "No relationship to %s" % firstName
|
||||
return ("",[])
|
||||
elif firstRel == 0:
|
||||
if secondRel == 0:
|
||||
return firstName
|
||||
return ('',common)
|
||||
elif other_person.getGender() == RelLib.Person.male:
|
||||
return get_father(firstName,secondName,secondRel)
|
||||
return (get_father(secondRel),common)
|
||||
else:
|
||||
return get_mother(firstName,secondName,secondRel)
|
||||
return (get_mother(secondRel),common)
|
||||
elif secondRel == 0:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
return get_son(firstName,secondName,firstRel)
|
||||
return (get_son(firstRel),common)
|
||||
else:
|
||||
return get_daughter(firstName,secondName,firstRel)
|
||||
return (get_daughter(firstRel),common)
|
||||
elif firstRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
return get_uncle(firstName,secondName,secondRel)
|
||||
return (get_uncle(secondRel),common)
|
||||
else:
|
||||
return get_aunt(firstName,secondName,secondRel)
|
||||
return (get_aunt(secondRel),common)
|
||||
elif secondRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
return get_nephew(firstName,secondName,firstRel-1)
|
||||
return (get_nephew(firstRel-1),common)
|
||||
else:
|
||||
return get_niece(firstName,secondName,firstRel-1)
|
||||
return (get_niece(firstRel-1),common)
|
||||
else:
|
||||
if secondRel > firstRel:
|
||||
return get_cousin(firstName,secondName,firstRel-1,secondRel-firstRel)
|
||||
return (get_cousin(firstRel-1,secondRel-firstRel),common)
|
||||
else:
|
||||
return get_cousin(firstName,secondName,secondRel-1,firstRel-secondRel)
|
||||
return (get_cousin(secondRel-1,firstRel-secondRel),common)
|
||||
|
||||
|
@ -279,7 +279,8 @@ class PdfDoc(TextDoc.TextDoc):
|
||||
def write_text(self,text):
|
||||
text = text.replace('&','&'); # Must be first
|
||||
text = text.replace('<','<');
|
||||
self.text = self.text + text.replace('>','>');
|
||||
text = text.replace('>','>');
|
||||
self.text = self.text + text.replace('\n','<br>');
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -301,5 +302,5 @@ Plugins.register_text_doc(
|
||||
table=1,
|
||||
paper=1,
|
||||
style=1,
|
||||
ext="pdf"
|
||||
ext=".pdf"
|
||||
)
|
||||
|
@ -72,7 +72,6 @@ import VersionControl
|
||||
import ReadXML
|
||||
import ListModel
|
||||
import GrampsXML
|
||||
import Relationship
|
||||
|
||||
try:
|
||||
import GrampsZODB
|
||||
@ -138,6 +137,7 @@ class Gramps:
|
||||
self.db.set_pprefix(GrampsCfg.pprefix)
|
||||
|
||||
GrampsCfg.loadConfig(self.full_update)
|
||||
self.relationship = Plugins.relationship_function()
|
||||
self.init_interface()
|
||||
|
||||
if arg != None:
|
||||
@ -1027,11 +1027,25 @@ class Gramps:
|
||||
pname = GrampsCfg.nameof(self.active_person)
|
||||
name = "[%s] %s" % (self.active_person.getId(),pname)
|
||||
else:
|
||||
name = Relationship.get_relationship(self.db.getDefaultPerson(),
|
||||
self.active_person)
|
||||
name = self.display_relationship()
|
||||
self.status_text(name)
|
||||
return 0
|
||||
|
||||
def display_relationship(self):
|
||||
try:
|
||||
pname = GrampsCfg.nameof(self.db.getDefaultPerson())
|
||||
(name,plist) = self.relationship(self.db.getDefaultPerson(),
|
||||
self.active_person)
|
||||
|
||||
if name:
|
||||
return _("%(relationship)s of %(person)s") % {
|
||||
'relationship' : name, 'person' : pname }
|
||||
else:
|
||||
return ""
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
||||
def on_open_activate(self,obj):
|
||||
wFs = gtk.glade.XML(const.revisionFile, "dbopen")
|
||||
wFs.signal_autoconnect({
|
||||
|
@ -45,249 +45,9 @@ import gtk.glade
|
||||
import RelLib
|
||||
import Utils
|
||||
import ListModel
|
||||
import Plugins
|
||||
from intl import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def filter(person,index,list,map):
|
||||
if person == None:
|
||||
return
|
||||
list.append(person)
|
||||
map[person.getId()] = index
|
||||
|
||||
family = person.getMainParents()
|
||||
if family != None:
|
||||
filter(family.getFather(),index+1,list,map)
|
||||
filter(family.getMother(),index+1,list,map)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def get_cousin(f,s,level,removed):
|
||||
if level == 1:
|
||||
if removed == 0:
|
||||
return _("%(p1)s is the first cousin of %(p2)s.") % {
|
||||
'p1' : f, 'p2' : s}
|
||||
elif removed == 1:
|
||||
return _("%(p1)s is the first cousin once removed of %(p2)s.") % {
|
||||
'p1' : f, 'p2' : s}
|
||||
elif removed == 2:
|
||||
return _("%(p1)s is the first cousin twice removed of %(p2)s.") % {
|
||||
'p1' : f,'p2' : s}
|
||||
else:
|
||||
return _("%(p1)s is the first cousin %(removed)d times removed of %(p2)s.") % {
|
||||
'p1' :f, 'p2' :s, 'removed' : removed}
|
||||
elif level == 2:
|
||||
if removed == 0:
|
||||
return _("%(p1)s is the second cousin of %(p2)s.") % {
|
||||
'p1' : f, 'p2' : s }
|
||||
elif removed == 1:
|
||||
return _("%(p1)s is the second cousin once removed of %(p2)s.") % {
|
||||
'p1' : f, 'p2' : s }
|
||||
elif removed == 2:
|
||||
return _("%(p1)s is the second cousin twice removed of %(p2)s.") % {
|
||||
'p1' : f, 'p2' : s }
|
||||
else:
|
||||
return _("%(p1)s is the second cousin %(removed)d times removed of %(p2)s.") % {
|
||||
'p1' : f, 'p2' : s, 'removed' : removed }
|
||||
elif level == 3:
|
||||
if removed == 0:
|
||||
return _("%(p1)s is the third cousin of %(p2)s.") % {
|
||||
'p1' : f, 'p2' : s }
|
||||
elif removed == 1:
|
||||
return _("%(p1)s is the third cousin once removed of %(p2)s.") % {
|
||||
'p1' : f, 'p2' : s }
|
||||
elif removed == 2:
|
||||
return _("%(p1)s is the third cousin twice removed of %(p2)s.") % {
|
||||
'p1' : f, 'p2' : s }
|
||||
else:
|
||||
return _("%(p1)s is the third cousin %(removed)d times removed of %(p2)s.") % {
|
||||
'p1' : f, 'p2' : s, 'removed' : removed }
|
||||
else:
|
||||
if removed == 0:
|
||||
return _("%(p1)s is the %(level)dth cousin of %(p2)s.") % {
|
||||
'p1': f, 'level': level, 'p2' : s }
|
||||
elif removed == 1:
|
||||
return _("%(p1)s is the %(level)dth cousin once removed of %(p2)s.") % {
|
||||
'p1': f, 'level': level, 'p2' : s }
|
||||
elif removed == 2:
|
||||
return _("%(p1)s is the %(level)dth cousin twice removed of %(p2)s.") % {
|
||||
'p1': f, 'level': level, 'p2' : s }
|
||||
else:
|
||||
return _("%(p1)s is the %(level)dth cousin %(removed)d times removed of %(p2)s.") % {
|
||||
'p1': f, 'level': level, 'removed' : removed, 'p2' : s }
|
||||
|
||||
def get_father(f,s,level):
|
||||
if level == 1:
|
||||
return _("%(p1)s is the father of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 2:
|
||||
return _("%(p1)s is the grandfather of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 3:
|
||||
return _("%(p1)s is the great grandfather of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 4:
|
||||
return _("%(p1)s is the second great grandfather of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 5:
|
||||
return _("%(p1)s is the third great grandfather of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
else:
|
||||
return _("%(p1)s is the %(level)dth great grandfather of %(p2)s.") % {
|
||||
'p1': s, 'level' : level-2, 'p2': f }
|
||||
|
||||
def get_son(f,s,level):
|
||||
if level == 1:
|
||||
return _("%(p1)s is the son of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 2:
|
||||
return _("%(p1)s is the grandson of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 3:
|
||||
return _("%(p1)s is the great grandson of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 4:
|
||||
return _("%(p1)s is the second great grandson of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 5:
|
||||
return _("%(p1)s is the third great grandson of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
else:
|
||||
return _("%(p1)s is the %(level)dth great grandson of %(p2)s.") % {
|
||||
'p1': s, 'level' : level-2, 'p2': f }
|
||||
|
||||
def get_mother(f,s,level):
|
||||
if level == 1:
|
||||
return _("%(p1)s is the mother of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 2:
|
||||
return _("%(p1)s is the grandmother of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 3:
|
||||
return _("%(p1)s is the great grandmother of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 4:
|
||||
return _("%(p1)s is the second great grandmother of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 5:
|
||||
return _("%(p1)s is the third great grandmother of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
else:
|
||||
return _("%(p1)s is the %(level)dth great grandmother of %(p2)s.") % {
|
||||
'p1': s, 'level' : level-2, 'p2': f }
|
||||
|
||||
def get_daughter(f,s,level):
|
||||
if level == 1:
|
||||
return _("%(p1)s is the daughter of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 2:
|
||||
return _("%(p1)s is the granddaughter of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 3:
|
||||
return _("%(p1)s is the great granddaughter of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 4:
|
||||
return _("%(p1)s is the second great granddaughter of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 5:
|
||||
return _("%(p1)s is the third great granddaughter of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
else:
|
||||
return _("%(p1)s is the %(level)dth great granddaughter of %(p2)s.") % {
|
||||
'p1': s, 'level' : level-2, 'p2': f }
|
||||
|
||||
def get_aunt(f,s,level):
|
||||
if level == 1:
|
||||
return _("%(p1)s is the sister of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 2:
|
||||
return _("%(p1)s is the aunt of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 3:
|
||||
return _("%(p1)s is the grandaunt of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 4:
|
||||
return _("%(p1)s is the great grandaunt of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 5:
|
||||
return _("%(p1)s is the second great grandaunt of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 6:
|
||||
return _("%(p1)s is the third great grandaunt of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
else:
|
||||
return _("%(p1)s is the %(level)dth great grandaunt of %(p2)s.") % {
|
||||
'p1': s, 'level' : level-3, 'p2': f }
|
||||
|
||||
def get_uncle(f,s,level):
|
||||
if level == 1:
|
||||
return _("%(p1)s is the brother of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 2:
|
||||
return _("%(p1)s is the uncle of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 3:
|
||||
return _("%(p1)s is the granduncle of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 4:
|
||||
return _("%(p1)s is the great granduncle of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 5:
|
||||
return _("%(p1)s is the second great granduncle of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 6:
|
||||
return _("%(p1)s is the third great granduncle of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
else:
|
||||
return _("%(p1)s is the %(level)dth great granduncle of %(p2)s.") % {
|
||||
'p1': s, 'level' : level-3, 'p2': f }
|
||||
|
||||
def get_nephew(f,s,level):
|
||||
if level == 1:
|
||||
return _("%(p1)s is the nephew of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 2:
|
||||
return _("%(p1)s is the grandnephew of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 3:
|
||||
return _("%(p1)s is the great grandnephew of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 4:
|
||||
return _("%(p1)s is the second great grandnephew of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 5:
|
||||
return _("%(p1)s is the third great grandnephew of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
else:
|
||||
return _("%(p1)s is the %(level)dth great grandnephew of %(p2)s.") % {
|
||||
'p1': s, 'level' : level-2, 'p2': f }
|
||||
|
||||
def get_niece(f,s,level):
|
||||
if level == 1:
|
||||
return _("%(p1)s is the niece of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 2:
|
||||
return _("%(p1)s is the grandniece of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 3:
|
||||
return _("%(p1)s is the great grandniece of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 4:
|
||||
return _("%(p1)s is the second great grandniece of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
elif level == 5:
|
||||
return _("%(p1)s is the third great grandniece of %(p2)s.") % {
|
||||
'p1': s, 'p2': f }
|
||||
else:
|
||||
return _("%(p1)s is the %(level)dth great grandniece of %(p2)s.") % {
|
||||
'p1': s, 'level' : level-2, 'p2': f }
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -309,6 +69,7 @@ class RelCalc:
|
||||
def __init__(self,database,person):
|
||||
self.person = person
|
||||
self.db = database
|
||||
self.relationship = Plugins.relationship_function()
|
||||
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = "%s/relcalc.glade" % base
|
||||
@ -341,50 +102,23 @@ class RelCalc:
|
||||
})
|
||||
|
||||
def on_apply_clicked(self,obj):
|
||||
firstMap = {}
|
||||
firstList = []
|
||||
secondMap = {}
|
||||
secondList = []
|
||||
common = []
|
||||
rank = 9999999
|
||||
|
||||
model,iter = self.clist.get_selected()
|
||||
if not iter:
|
||||
return
|
||||
|
||||
id = self.clist.get_object(iter)
|
||||
other_person = self.db.getPerson(id)
|
||||
filter(self.person,0,firstList,firstMap)
|
||||
filter(other_person,0,secondList,secondMap)
|
||||
|
||||
for person in firstList:
|
||||
if person in secondList:
|
||||
new_rank = firstMap[person.getId()]
|
||||
if new_rank < rank:
|
||||
rank = new_rank
|
||||
common = [ person ]
|
||||
elif new_rank == rank:
|
||||
common.append(person)
|
||||
|
||||
firstRel = -1
|
||||
secondRel = -1
|
||||
|
||||
firstName = self.person.getPrimaryName().getRegularName()
|
||||
secondName = other_person.getPrimaryName().getRegularName()
|
||||
|
||||
(rel_string,common) = self.relationship(self.person,other_person)
|
||||
length = len(common)
|
||||
|
||||
if length == 1:
|
||||
person = common[0]
|
||||
secondRel = firstMap[person.getId()]
|
||||
firstRel = secondMap[person.getId()]
|
||||
name = person.getPrimaryName().getRegularName()
|
||||
commontext = " " + _("Their common ancestor is %s.") % name
|
||||
elif length == 2:
|
||||
p1 = common[0]
|
||||
p2 = common[1]
|
||||
secondRel = firstMap[p1.getId()]
|
||||
firstRel = secondMap[p1.getId()]
|
||||
commontext = " " + _("Their common ancestors are %s and %s.") % \
|
||||
(p1.getPrimaryName().getRegularName(),\
|
||||
p2.getPrimaryName().getRegularName())
|
||||
@ -392,8 +126,6 @@ class RelCalc:
|
||||
index = 0
|
||||
commontext = " " + _("Their common ancestors are : ")
|
||||
for person in common:
|
||||
secondRel = firstMap[person.getId()]
|
||||
firstRel = secondMap[person.getId()]
|
||||
if index != 0:
|
||||
commontext = commontext + ", "
|
||||
commontext = commontext + person.getPrimaryName().getRegularName()
|
||||
@ -402,42 +134,18 @@ class RelCalc:
|
||||
else:
|
||||
commontext = ""
|
||||
|
||||
if firstRel == -1:
|
||||
msg = _("There is no relationship between %s and %s.")
|
||||
text = msg % (firstName,secondName)
|
||||
elif firstRel == 0:
|
||||
if secondRel == 0:
|
||||
text = _("%s and %s are the same person.") % (firstName,secondName)
|
||||
elif other_person.getGender() == RelLib.Person.male:
|
||||
text = get_father(firstName,secondName,secondRel)
|
||||
else:
|
||||
text = get_mother(firstName,secondName,secondRel)
|
||||
elif secondRel == 0:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = get_son(firstName,secondName,firstRel)
|
||||
else:
|
||||
text = get_daughter(firstName,secondName,firstRel)
|
||||
elif firstRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = get_uncle(firstName,secondName,secondRel)
|
||||
else:
|
||||
text = get_aunt(firstName,secondName,secondRel)
|
||||
elif secondRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = get_nephew(firstName,secondName,firstRel-1)
|
||||
else:
|
||||
text = get_niece(firstName,secondName,firstRel-1)
|
||||
else:
|
||||
if secondRel > firstRel:
|
||||
text = get_cousin(firstName,secondName,firstRel-1,secondRel-firstRel)
|
||||
else:
|
||||
text = get_cousin(firstName,secondName,secondRel-1,firstRel-secondRel)
|
||||
|
||||
text1 = self.glade.get_widget("text1").get_buffer()
|
||||
if firstRel == 0 or secondRel == 0:
|
||||
text1.set_text(text)
|
||||
p1 = self.person.getPrimaryName().getName()
|
||||
p2 = other_person.getPrimaryName().getName()
|
||||
|
||||
if rel_string == "":
|
||||
rstr = _("%(person)s and %(active_person)s are not related.") % {
|
||||
'person' : p2, 'active_person' : p1 }
|
||||
else:
|
||||
text1.set_text(text + commontext)
|
||||
rstr = _("%(person)s is the %(relationship)s of %(active_person)s.") % {
|
||||
'person' : p2, 'relationship' : rel_string, 'active_person' : p1 }
|
||||
|
||||
text1.set_text("%s %s" % (rstr, commontext))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user