Remove db requirement from constructor and add get_plural_relationship_string to relationship class.
svn: r8831
This commit is contained in:
parent
32f3f2c129
commit
7a72009239
23
ChangeLog
23
ChangeLog
@ -1,3 +1,26 @@
|
||||
2007-08-18 Brian Matherly <brian@gramps-project.org>
|
||||
* src/ViewManager.py
|
||||
* src/plugins/rel_fr.py
|
||||
* src/plugins/rel_da.py
|
||||
* src/plugins/rel_de.py
|
||||
* src/plugins/rel_sv.py
|
||||
* src/plugins/rel_fi.py
|
||||
* src/plugins/rel_hu.py
|
||||
* src/plugins/rel_ru.py
|
||||
* src/plugins/rel_nl.py
|
||||
* src/plugins/rel_pl.py
|
||||
* src/plugins/rel_it.py
|
||||
* src/plugins/RelCalc.py
|
||||
* src/plugins/rel_cs.py
|
||||
* src/plugins/rel_es.py
|
||||
* src/plugins/rel_no.py
|
||||
* src/plugins/rel_sk.py
|
||||
* src/DisplayState.py
|
||||
* src/PluginUtils/_PluginMgr.py
|
||||
* src/Relationship.py:
|
||||
Remove db requirement from constructor and add
|
||||
get_plural_relationship_string to relationship class.
|
||||
|
||||
2007-08-18 Benny Malengier <bm@cage.ugent.be>
|
||||
* README: small changes, also bug #1164
|
||||
|
||||
|
@ -54,6 +54,7 @@ import Config
|
||||
from BasicUtils import name_displayer
|
||||
import const
|
||||
import ManagedWindow
|
||||
from PluginUtils import _PluginMgr
|
||||
|
||||
DISABLED = -1
|
||||
|
||||
@ -278,6 +279,7 @@ class DisplayState(GrampsDb.GrampsDBCallback):
|
||||
self.widget = None
|
||||
self.warnbtn = warnbtn
|
||||
self.last_bar = self.status.insert(min_width=15, ralign=True)
|
||||
self.relationship = _PluginMgr.relationship_class()
|
||||
|
||||
formatter = logging.Formatter('%(levelname)s %(name)s: %(message)s')
|
||||
self.rhandler = WarnHandler(capacity=400, button=warnbtn)
|
||||
@ -293,8 +295,6 @@ class DisplayState(GrampsDb.GrampsDBCallback):
|
||||
self.window.set_sensitive(state)
|
||||
|
||||
def db_changed(self, db):
|
||||
from PluginUtils import _PluginMgr
|
||||
self.relationship = _PluginMgr.relationship_class(db)
|
||||
db.connect('long-op-start', self.progress_monitor.add_op)
|
||||
|
||||
def display_relationship(self, dbstate):
|
||||
@ -305,7 +305,7 @@ class DisplayState(GrampsDb.GrampsDBCallback):
|
||||
|
||||
pname = name_displayer.display(default_person)
|
||||
(name, plist) = self.relationship.get_relationship(
|
||||
default_person,active)
|
||||
dbstate.db,default_person,active)
|
||||
|
||||
if name:
|
||||
if plist == None:
|
||||
|
@ -467,9 +467,9 @@ def register_relcalc(relclass, languages):
|
||||
except:
|
||||
pass
|
||||
|
||||
def relationship_class(db):
|
||||
def relationship_class():
|
||||
global _relcalc_class
|
||||
return _relcalc_class(db)
|
||||
return _relcalc_class()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -149,6 +149,47 @@ _niece_level = [ "", "niece", "grandniece", "great grandniece", "second great gr
|
||||
"seventeenth great grandniece", "eighteenth great grandniece",
|
||||
"nineteenth great grandniece", "twentieth great grandniece", ]
|
||||
|
||||
_children_level = [ "",
|
||||
"children", "grandchildren",
|
||||
"great grandchildren", "second great grandchildren",
|
||||
"third great grandchildren", "fourth great grandchildren",
|
||||
"fifth great grandchildren", "sixth great grandchildren",
|
||||
"seventh great grandchildren", "eighth great grandchildren",
|
||||
"ninth great grandchildren", "tenth great grandchildren",
|
||||
"eleventh great grandchildren", "twelfth great grandchildren",
|
||||
"thirteenth great grandchildren", "fourteenth great grandchildren",
|
||||
"fifteenth great grandchildren", "sixteenth great grandchildren",
|
||||
"seventeenth great grandchildren", "eighteenth great grandchildren",
|
||||
"nineteenth great grandchildren", "twentieth great grandchildren", ]
|
||||
|
||||
_siblings_level = [ "",
|
||||
"siblings", "uncles/aunts",
|
||||
"granduncles/aunts", "great granduncles/aunts",
|
||||
"second great granduncles/aunts", "third great granduncles/aunts",
|
||||
"fourth great granduncles/aunts", "fifth great granduncles/aunts",
|
||||
"sixth great granduncles/aunts", "seventh great granduncles/aunts",
|
||||
"eighth great granduncles/aunts", "ninth great granduncles/aunts",
|
||||
"tenth great granduncles/aunts", "eleventh great granduncles/aunts",
|
||||
"twelfth great granduncles/aunts", "thirteenth great granduncles/aunts",
|
||||
"fourteenth great granduncles/aunts", "fifteenth great granduncles/aunts",
|
||||
"sixteenth great granduncles/aunts", "seventeenth great granduncles/aunts",
|
||||
"eighteenth great granduncles/aunts", "nineteenth great granduncles/aunts",
|
||||
"twentieth great granduncles/aunts", ]
|
||||
|
||||
_nefews_nieces_level = [ "", "siblings",
|
||||
"nefews/nieces", "grandnefews/nieces",
|
||||
"great grandnefews/nieces", "second great grandnefews/nieces",
|
||||
"third great grandnefews/nieces", "fourth great grandnefews/nieces",
|
||||
"fifth great grandnefews/nieces", "sixth great grandnefews/nieces",
|
||||
"seventh great grandnefews/nieces", "eighth great grandnefews/nieces",
|
||||
"ninth great grandnefews/nieces", "tenth great grandnefews/nieces",
|
||||
"eleventh great grandnefews/nieces", "twelfth great grandnefews/nieces",
|
||||
"thirteenth great grandnefews/nieces", "fourteenth great grandnefews/nieces",
|
||||
"fifteenth great grandnefews/nieces", "sixteenth great grandnefews/nieces",
|
||||
"seventeenth great grandnefews/nieces", "eighteenth great grandnefews/nieces",
|
||||
"nineteenth great grandnefews/nieces", "twentieth great grandnefews/nieces", ]
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -159,31 +200,28 @@ MAX_DEPTH = 15
|
||||
|
||||
class RelationshipCalculator:
|
||||
|
||||
def __init__(self,db):
|
||||
self.db = db
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def set_db(self,db):
|
||||
self.db = db
|
||||
|
||||
def apply_filter(self,person,rel_str,plist,pmap,current_gen=1):
|
||||
if person == None or current_gen > MAX_DEPTH:
|
||||
def __apply_filter(self,db,person,rel_str,plist,pmap,gen=1):
|
||||
if person == None or gen > MAX_DEPTH:
|
||||
return
|
||||
current_gen += 1
|
||||
gen += 1
|
||||
plist.append(person.handle)
|
||||
pmap[person.handle] = rel_str
|
||||
|
||||
family_handle = person.get_main_parents_family_handle()
|
||||
try:
|
||||
if family_handle:
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
family = db.get_family_from_handle(family_handle)
|
||||
fhandle = family.father_handle
|
||||
if fhandle:
|
||||
father = self.db.get_person_from_handle(fhandle)
|
||||
self.apply_filter(father,rel_str+'f',plist,pmap,current_gen)
|
||||
father = db.get_person_from_handle(fhandle)
|
||||
self.__apply_filter(db,father,rel_str+'f',plist,pmap,gen)
|
||||
mhandle = family.mother_handle
|
||||
if mhandle:
|
||||
mother = self.db.get_person_from_handle(mhandle)
|
||||
self.apply_filter(mother,rel_str+'m',plist,pmap,current_gen)
|
||||
mother = db.get_person_from_handle(mhandle)
|
||||
self.__apply_filter(db,mother,rel_str+'m',plist,pmap,gen)
|
||||
except:
|
||||
return
|
||||
|
||||
@ -247,9 +285,9 @@ class RelationshipCalculator:
|
||||
else:
|
||||
return _niece_level[level]
|
||||
|
||||
def is_spouse(self,orig,other):
|
||||
def is_spouse(self,db,orig,other):
|
||||
for f in orig.get_family_handle_list():
|
||||
family = self.db.get_family_from_handle(f)
|
||||
family = db.get_family_from_handle(f)
|
||||
if family and other.get_handle() in [family.get_father_handle(),
|
||||
family.get_mother_handle()]:
|
||||
family_rel = family.get_relationship()
|
||||
@ -304,7 +342,7 @@ class RelationshipCalculator:
|
||||
return None
|
||||
return None
|
||||
|
||||
def get_relationship_distance(self,orig_person,other_person):
|
||||
def get_relationship_distance(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a tuple (firstRel,secondRel,common):
|
||||
|
||||
@ -328,8 +366,8 @@ class RelationshipCalculator:
|
||||
rank = 9999999
|
||||
|
||||
try:
|
||||
self.apply_filter(orig_person,'',firstList,firstMap)
|
||||
self.apply_filter(other_person,'',secondList,secondMap)
|
||||
self.__apply_filter(db,orig_person,'',firstList,firstMap)
|
||||
self.__apply_filter(db,other_person,'',secondList,secondMap)
|
||||
except RuntimeError:
|
||||
return (firstRel,secondRel,_("Relationship loop detected"))
|
||||
|
||||
@ -349,7 +387,7 @@ class RelationshipCalculator:
|
||||
|
||||
return (firstRel,secondRel,common)
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
returns a string representping the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -361,13 +399,15 @@ class RelationshipCalculator:
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
@ -406,7 +446,7 @@ class RelationshipCalculator:
|
||||
return (self.get_cousin(secondRel-1,firstRel-secondRel),common)
|
||||
|
||||
|
||||
def get_grandparents_string(self,orig_person,other_person):
|
||||
def get_grandparents_string(self,db,orig_person,other_person):
|
||||
"""
|
||||
returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -417,9 +457,11 @@ class RelationshipCalculator:
|
||||
if orig_person == other_person:
|
||||
return ('', [])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
@ -433,3 +475,74 @@ class RelationshipCalculator:
|
||||
return (self.get_parents(len(secondRel)),common)
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_plural_relationship_string(self,Ga,Gb):
|
||||
"""
|
||||
Provides a string that describes the relationsip between a person, and
|
||||
a group of people with the same relationship. E.g. "grandparents" or
|
||||
"children".
|
||||
|
||||
Ga and Gb can be used to mathematically calculate the relationship.
|
||||
See the Wikipedia entry for more information:
|
||||
http://en.wikipedia.org/wiki/Cousin#Mathematical_definitions
|
||||
|
||||
@param Ga: The number of generations between the main person and the
|
||||
common ancestor.
|
||||
@type Ga: int
|
||||
@param Gb: The number of generations between the group of people and the
|
||||
common ancestor
|
||||
@type Gb: int
|
||||
@returns: A string describing the relationship between the person and
|
||||
the group.
|
||||
@rtype: str
|
||||
"""
|
||||
rel_str = "distant relatives"
|
||||
if Ga == 0:
|
||||
# These are descendants
|
||||
if Gb < len(_children_level):
|
||||
rel_str = _children_level[Gb]
|
||||
else:
|
||||
rel_str = "distant descendants"
|
||||
elif Gb == 0:
|
||||
# These are parents/grand parents
|
||||
if Ga < len(_parents_level):
|
||||
rel_str = _parents_level[Ga]
|
||||
else:
|
||||
rel_str = "distant ancestors"
|
||||
elif Gb == 1:
|
||||
# These are siblings/aunts/uncles
|
||||
if Ga < len(_siblings_level):
|
||||
rel_str = _siblings_level[Ga]
|
||||
else:
|
||||
rel_str = "distant uncles/aunts"
|
||||
elif Ga == 1:
|
||||
# These are nieces/nefews
|
||||
if Ga < len(_nefews_nieces_level):
|
||||
rel_str = _nefews_nieces_level[Gb]
|
||||
else:
|
||||
rel_str = "distant nefews/nieces"
|
||||
elif Ga > 1 and Ga == Gb:
|
||||
# These are cousins in the same generation
|
||||
if Ga <= len(_level_name):
|
||||
rel_str = "%s cousins" % _level_name[Ga-1]
|
||||
else:
|
||||
rel_str = "distant cousins"
|
||||
elif Ga > 1 and Ga > Gb:
|
||||
# These are cousins in different generations with the second person
|
||||
# being in a higher generation from the common ancestor than the
|
||||
# first person.
|
||||
if Gb <= len(_level_name) and (Ga-Gb) < len(_removed_level):
|
||||
rel_str = "%s cousins%s (up)" % ( _level_name[Gb-1],
|
||||
_removed_level[Ga-Gb] )
|
||||
else:
|
||||
rel_str = "distant cousins"
|
||||
elif Gb > 1 and Gb > Ga:
|
||||
# These are cousins in different generations with the second person
|
||||
# being in a lower generation from the common ancestor than the
|
||||
# first person.
|
||||
if Ga <= len(_level_name) and (Gb-Ga) < len(_removed_level):
|
||||
rel_str = "%s cousins%s (down)" % ( _level_name[Ga-1],
|
||||
_removed_level[Gb-Ga] )
|
||||
else:
|
||||
rel_str = "distant cousins"
|
||||
return rel_str
|
||||
|
@ -1060,8 +1060,6 @@ class ViewManager:
|
||||
self.state.signal_change()
|
||||
|
||||
Config.set(Config.RECENT_FILE, filename)
|
||||
|
||||
self.relationship = self.RelClass(self.state.db)
|
||||
|
||||
try:
|
||||
self.state.change_active_person(self.state.db.find_initial_person())
|
||||
|
@ -86,8 +86,7 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
|
||||
'tool to work properly.'))
|
||||
return
|
||||
|
||||
self.RelClass = relationship_class
|
||||
self.relationship = self.RelClass(self.db)
|
||||
self.relationship = relationship_class()
|
||||
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = "%s/relcalc.glade" % base
|
||||
@ -147,7 +146,7 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
|
||||
|
||||
if other_person != None:
|
||||
(rel_string,common) = self.relationship.get_relationship(
|
||||
self.person,other_person)
|
||||
self.db,self.person,other_person)
|
||||
# A quick way to get unique list
|
||||
common = list(set(common))
|
||||
length = len(common)
|
||||
|
@ -72,8 +72,8 @@ _niece_level = [ "", "neteř", "praneteř", "prapraneteř", ]
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_male_cousin(self,level):
|
||||
if level>len(_level_name)-1:
|
||||
@ -141,7 +141,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
else:
|
||||
return _niece_level[level]
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -155,11 +155,12 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) in (str,unicode):
|
||||
return (common,[])
|
||||
|
@ -77,8 +77,8 @@ _niece_level = [ "", "niecen", "næstsøskendebarnet", "søsterens barnebarn", ]
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_parents(self,level):
|
||||
if level>len(_parents_level)-1:
|
||||
@ -159,7 +159,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
result.append('søster')
|
||||
return self.pair_up(result)
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -173,13 +173,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -245,8 +245,8 @@ _parents_level = [ "", "Eltern", "Großeltern", "Urgroßeltern",
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_parents(self,level):
|
||||
if level>len(_parents_level)-1:
|
||||
@ -318,7 +318,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
else:
|
||||
return "Cousine"+_removed_level[removed]
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -332,13 +332,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -120,8 +120,8 @@ _niece_level = [ "", "sobrina", "sobrina nieta", "sobrina bisnieta", ]
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_male_cousin(self,level):
|
||||
if level<len(_level_name_male):
|
||||
@ -250,7 +250,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
else:
|
||||
return "%d-ésima sobrina nieta" % (level-1)
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -262,13 +262,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -52,8 +52,8 @@ _parents_level = [ "", "vanhemmat", "isovanhemmat", "isoisovanhemmat",
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_cousin(self,level):
|
||||
if level == 0:
|
||||
@ -169,7 +169,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
return ' '.join(result)
|
||||
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -183,13 +183,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -72,8 +72,8 @@ _niece_level = [ "", "la nièce", "la petite-nièce", "l'arrière-petite-nièce"
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_male_cousin(self,level):
|
||||
if level>len(_level_name)-1:
|
||||
@ -141,7 +141,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
else:
|
||||
return _niece_level[level]
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -155,13 +155,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -56,8 +56,8 @@ _level =\
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
|
||||
def get_parents (self,level):
|
||||
@ -255,7 +255,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -267,7 +267,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
@ -296,9 +296,11 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
return ("sógora vagy sógornője",self.get_brothersister_in_law_common(orig_person,other_person))
|
||||
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -56,8 +56,8 @@ _level =\
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -139,7 +139,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -151,13 +151,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -124,8 +124,8 @@ _niece_level = [ "",
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_male_cousin(self,level):
|
||||
if level>len(_level_name)-1:
|
||||
@ -193,7 +193,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
else:
|
||||
return _niece_level[level]
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -207,13 +207,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -58,8 +58,8 @@ _cousin_terms = _cousin_level + ["fetter","kusine"]
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_parents(self,level):
|
||||
if level == 0:
|
||||
@ -219,7 +219,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
result.append('søster')
|
||||
return self.pair_up(result)
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -233,13 +233,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -268,8 +268,8 @@ _niece_level_of_sisters_daughter = [ "", "siostrzenica",
|
||||
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
# other_level+orig_level=stopień pokrewieństwa (degree of kinship)
|
||||
|
||||
@ -445,7 +445,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
else:
|
||||
return _niece_level_of_sisters_daughter[level]
|
||||
|
||||
def get_relationship_distance(self,orig_person,other_person):
|
||||
def get_relationship_distance(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a tuple (firstRel,secondRel,common):
|
||||
|
||||
@ -469,8 +469,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
rank = 9999999
|
||||
|
||||
try:
|
||||
self.apply_filter(orig_person,'',firstList,firstMap)
|
||||
self.apply_filter(other_person,'',secondList,secondMap)
|
||||
self.__apply_filter(db,orig_person,'',firstList,firstMap)
|
||||
self.__apply_filter(db,other_person,'',secondList,secondMap)
|
||||
except RuntimeError:
|
||||
return (firstRel,secondRel,_("Relationship loop detected"))
|
||||
|
||||
@ -490,7 +490,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
return (firstRel,secondRel,common,firstList,secondList)
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -504,13 +504,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common,firstList,secondList) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common,firstList,secondList) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
@ -534,32 +536,32 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
else:
|
||||
return (self.get_daughter(secondRel,firstRel),common)
|
||||
elif firstRel == 1:
|
||||
families1 = self.db.get_person_from_handle(common[0]).get_family_handle_list()
|
||||
families1 = db.get_person_from_handle(common[0]).get_family_handle_list()
|
||||
families2 = None
|
||||
if len(common) >1:
|
||||
families2 = self.db.get_person_from_handle(common[1]).get_family_handle_list()
|
||||
families2 = db.get_person_from_handle(common[1]).get_family_handle_list()
|
||||
for ancFamily_handle in families1:
|
||||
if families2:
|
||||
if ancFamily_handle in families2:
|
||||
ancFamily = self.db.get_family_from_handle(ancFamily_handle)
|
||||
ancFamily = db.get_family_from_handle(ancFamily_handle)
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
ancFamily = self.db.get_family_from_handle(ancFamily_handle)
|
||||
ancFamily = db.get_family_from_handle(ancFamily_handle)
|
||||
children = ancFamily.get_child_ref_list()
|
||||
for sibling in children:
|
||||
if sibling.ref in firstList:
|
||||
# discriminate between siblings/uncles etc. and stepsiblings/stepuncles etc.
|
||||
if other_person.get_main_parents_family_handle() == self.db.get_person_from_handle(sibling.ref).get_main_parents_family_handle():
|
||||
if other_person.get_main_parents_family_handle() == db.get_person_from_handle(sibling.ref).get_main_parents_family_handle():
|
||||
if other_person.get_gender() == RelLib.Person.MALE:
|
||||
if self.db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
if db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
# brat / stryj / (pra)dziadek stryjeczny
|
||||
return (self.get_uncle_of_male(secondRel,firstRel),common)
|
||||
else:
|
||||
# brat / wuj / (pra)dziadek cioteczny
|
||||
return (self.get_uncle_of_female(secondRel,firstRel),common)
|
||||
else:
|
||||
if self.db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
if db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
# siostra / ciotka / (pra)babcia stryjeczna
|
||||
return (self.get_aunt_of_male(secondRel,firstRel),common)
|
||||
else:
|
||||
@ -567,41 +569,41 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
return (self.get_aunt_of_female(secondRel,firstRel),common)
|
||||
else:
|
||||
if other_person.get_gender() == RelLib.Person.MALE:
|
||||
if self.db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
if db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
# brat / stryj / (pra)dziadek stryjeczny
|
||||
return (self.get_uncle_of_male(secondRel,firstRel)+" (przyrodni)",common)
|
||||
else:
|
||||
# brat / wuj / (pra)dziadek cioteczny
|
||||
return (self.get_uncle_of_female(secondRel,firstRel)+" (przyrodni)",common)
|
||||
else:
|
||||
if self.db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
if db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
# siostra / ciotka / (pra)babcia stryjeczna
|
||||
return (self.get_aunt_of_male(secondRel,firstRel)+" (przyrodnia)",common)
|
||||
else:
|
||||
# siostra / ciotka / (pra)babcia cioteczna
|
||||
return (self.get_aunt_of_female(secondRel,firstRel)+" (przyrodnia)",common)
|
||||
elif secondRel == 1:
|
||||
families1 = self.db.get_person_from_handle(common[0]).get_family_handle_list()
|
||||
families1 = db.get_person_from_handle(common[0]).get_family_handle_list()
|
||||
families2 = None
|
||||
if len(common) >1:
|
||||
families2 = self.db.get_person_from_handle(common[1]).get_family_handle_list()
|
||||
families2 = db.get_person_from_handle(common[1]).get_family_handle_list()
|
||||
for ancFamily_handle in families1:
|
||||
if families2:
|
||||
if ancFamily_handle in families2:
|
||||
ancFamily = self.db.get_family_from_handle(ancFamily_handle)
|
||||
ancFamily = db.get_family_from_handle(ancFamily_handle)
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
ancFamily = self.db.get_family_from_handle(ancFamily_handle)
|
||||
ancFamily = db.get_family_from_handle(ancFamily_handle)
|
||||
children = ancFamily.get_child_ref_list()
|
||||
for sibling_handle in children:
|
||||
if sibling_handle.ref in secondList:
|
||||
sibling = self.db.get_person_from_handle(sibling_handle.ref)
|
||||
sibling = db.get_person_from_handle(sibling_handle.ref)
|
||||
families = sibling.get_family_handle_list()
|
||||
for sibFamily in families:
|
||||
for child_handle in self.db.get_family_from_handle(sibFamily).get_child_ref_list():
|
||||
for child_handle in db.get_family_from_handle(sibFamily).get_child_ref_list():
|
||||
if child_handle.ref in secondList:
|
||||
child = self.db.get_person_from_handle(child_handle.ref)
|
||||
child = db.get_person_from_handle(child_handle.ref)
|
||||
if other_person.get_gender() == RelLib.Person.MALE:
|
||||
if sibling.get_gender() == RelLib.Person.MALE:
|
||||
if child.get_gender() == RelLib.Person.MALE:
|
||||
@ -633,52 +635,52 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
# siostrzenica / córka siostrzenicy
|
||||
return (self.get_niece_of_sisters_daughter(secondRel,firstRel),common)
|
||||
elif secondRel > firstRel:
|
||||
families1 = self.db.get_person_from_handle(common[0]).get_family_handle_list()
|
||||
families1 = db.get_person_from_handle(common[0]).get_family_handle_list()
|
||||
families2 = None
|
||||
if len(common) >1:
|
||||
families2 = self.db.get_person_from_handle(common[1]).get_family_handle_list()
|
||||
families2 = db.get_person_from_handle(common[1]).get_family_handle_list()
|
||||
for ancFamily_handle in families1:
|
||||
if families2:
|
||||
if ancFamily_handle in families2:
|
||||
ancFamily = self.db.get_family_from_handle(ancFamily_handle)
|
||||
ancFamily = db.get_family_from_handle(ancFamily_handle)
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
ancFamily = self.db.get_family_from_handle(ancFamily_handle)
|
||||
ancFamily = db.get_family_from_handle(ancFamily_handle)
|
||||
children = ancFamily.get_child_ref_list()
|
||||
for sibling in children:
|
||||
if sibling.ref in firstList:
|
||||
if other_person.get_gender() == RelLib.Person.MALE:
|
||||
if self.db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
if db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
return (self.get_senior_male_cousin_of_male(secondRel-firstRel+1,firstRel,secondRel),common)
|
||||
else:
|
||||
return (self.get_senior_male_cousin_of_female(secondRel-firstRel+1,firstRel,secondRel),common)
|
||||
else:
|
||||
if self.db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
if db.get_person_from_handle(sibling.ref).get_gender() == RelLib.Person.MALE:
|
||||
return (self.get_senior_female_cousin_of_male(secondRel-firstRel+1,firstRel,secondRel),common)
|
||||
else:
|
||||
return (self.get_senior_female_cousin_of_female(secondRel-firstRel+1,firstRel,secondRel),common)
|
||||
else:
|
||||
families1 = self.db.get_person_from_handle(common[0]).get_family_handle_list()
|
||||
families1 = db.get_person_from_handle(common[0]).get_family_handle_list()
|
||||
families2 = None
|
||||
if len(common) >1:
|
||||
families2 = self.db.get_person_from_handle(common[1]).get_family_handle_list()
|
||||
families2 = db.get_person_from_handle(common[1]).get_family_handle_list()
|
||||
for ancFamily_handle in families1:
|
||||
if families2:
|
||||
if ancFamily_handle in families2:
|
||||
ancFamily = self.db.get_family_from_handle(ancFamily_handle)
|
||||
ancFamily = db.get_family_from_handle(ancFamily_handle)
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
ancFamily = self.db.get_family_from_handle(ancFamily_handle)
|
||||
ancFamily = db.get_family_from_handle(ancFamily_handle)
|
||||
|
||||
children = ancFamily.get_child_ref_list()
|
||||
for sibling_handle in children:
|
||||
if sibling_handle.ref in firstList:
|
||||
for other_sibling_handle in children:
|
||||
if other_sibling_handle.ref in secondList:
|
||||
sibling = self.db.get_person_from_handle(sibling_handle.ref)
|
||||
other_sibling = self.db.get_person_from_handle(other_sibling_handle.ref)
|
||||
sibling = db.get_person_from_handle(sibling_handle.ref)
|
||||
other_sibling = db.get_person_from_handle(other_sibling_handle.ref)
|
||||
if other_person.get_gender() == RelLib.Person.MALE:
|
||||
if other_sibling.get_gender() == RelLib.Person.MALE:
|
||||
if sibling.get_gender() == RelLib.Person.MALE:
|
||||
|
@ -112,8 +112,8 @@ _niece_level = [
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_parents(self,level):
|
||||
if level>len(_parents_level)-1:
|
||||
@ -193,7 +193,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
else:
|
||||
return _niece_level[level]
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -207,13 +207,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -72,8 +72,8 @@ _niece_level = [ "", "neter", "praneter", "prapraneter", ]
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_male_cousin(self,level):
|
||||
if level>len(_level_name)-1:
|
||||
@ -141,7 +141,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
else:
|
||||
return _niece_level[level]
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -155,13 +155,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -57,8 +57,8 @@ _cousin_level = [ "", "kusin",
|
||||
#-------------------------------------------------------------------------
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
def __init__(self,db):
|
||||
Relationship.RelationshipCalculator.__init__(self,db)
|
||||
def __init__(self):
|
||||
Relationship.RelationshipCalculator.__init__(self)
|
||||
|
||||
def get_parents(self,level):
|
||||
if level == 1:
|
||||
@ -174,7 +174,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
result.append('syster')
|
||||
return self.pair_up(result)
|
||||
|
||||
def get_relationship(self,orig_person,other_person):
|
||||
def get_relationship(self,db,orig_person,other_person):
|
||||
"""
|
||||
Returns a string representing the relationshp between the two people,
|
||||
along with a list of common ancestors (typically father,mother)
|
||||
@ -188,13 +188,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
if orig_person.get_handle() == other_person.get_handle():
|
||||
return ('', [])
|
||||
|
||||
is_spouse = self.is_spouse(orig_person,other_person)
|
||||
is_spouse = self.is_spouse(db,orig_person,other_person)
|
||||
if is_spouse:
|
||||
return (is_spouse,[])
|
||||
|
||||
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||
(firstRel,secondRel,common) = \
|
||||
self.get_relationship_distance(db,orig_person,other_person)
|
||||
|
||||
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||
if type(common) == types.StringType or \
|
||||
type(common) == types.UnicodeType:
|
||||
return (common,[])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
Loading…
x
Reference in New Issue
Block a user