Pylint cleanup for the relationship calculator.
svn: r13421
This commit is contained in:
parent
7290694c43
commit
22693cfbad
@ -342,13 +342,14 @@ _nephews_nieces_level = [ "",
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
# RelationshipCalculator
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class RelationshipCalculator(object):
|
||||
|
||||
"""
|
||||
The relationship calculator helps to determine the relationship between
|
||||
two people.
|
||||
"""
|
||||
REL_MOTHER = 'm' # going up to mother
|
||||
REL_FATHER = 'f' # going up to father
|
||||
REL_MOTHER_NOTBIRTH = 'M' # going up to mother, not birth relation
|
||||
@ -413,7 +414,6 @@ class RelationshipCalculator(object):
|
||||
"""
|
||||
return self.depth
|
||||
|
||||
|
||||
DIST_FATHER = "distant %(step)sancestor%(inlaw)s (%(level)d generations)"
|
||||
|
||||
def _get_father(self, level, step='', inlaw=''):
|
||||
@ -635,7 +635,7 @@ class RelationshipCalculator(object):
|
||||
#make every person appear only once:
|
||||
return list(set(nb_parents))
|
||||
|
||||
def get_spouse_type(self, db, orig, other, all_rel = False):
|
||||
def _get_spouse_type(self, db, orig, other, all_rel = False):
|
||||
""" Translation free determination if orig and other are partners.
|
||||
The procedure returns partner types, these can be passed to
|
||||
get_partner_relationship_string.
|
||||
@ -643,8 +643,8 @@ class RelationshipCalculator(object):
|
||||
If all_rel=True, returns a list, empty if no partner
|
||||
"""
|
||||
val = []
|
||||
for f in orig.get_family_handle_list():
|
||||
family = db.get_family_from_handle(f)
|
||||
for family_handle in orig.get_family_handle_list():
|
||||
family = db.get_family_from_handle(family_handle)
|
||||
# return first found spouse type
|
||||
if family and other.get_handle() in [family.get_father_handle(),
|
||||
family.get_mother_handle()]:
|
||||
@ -690,9 +690,9 @@ class RelationshipCalculator(object):
|
||||
def is_spouse(self, db, orig, other, all_rel=False):
|
||||
""" determine the spouse relation
|
||||
"""
|
||||
type = self.get_spouse_type(db, orig, other, all_rel)
|
||||
if type:
|
||||
return self.get_partner_relationship_string(type,
|
||||
spouse_type = self._get_spouse_type(db, orig, other, all_rel)
|
||||
if spouse_type:
|
||||
return self.get_partner_relationship_string(spouse_type,
|
||||
orig.get_gender(), other.get_gender())
|
||||
else:
|
||||
return None
|
||||
@ -764,15 +764,11 @@ class RelationshipCalculator(object):
|
||||
|
||||
firstRel = -1
|
||||
secondRel = -1
|
||||
common_str = []
|
||||
common_fam = []
|
||||
self.__msg = []
|
||||
|
||||
common = []
|
||||
firstMap = {}
|
||||
firstList = []
|
||||
secondMap = {}
|
||||
secondList = []
|
||||
rank = 9999999
|
||||
|
||||
try:
|
||||
@ -1090,15 +1086,17 @@ class RelationshipCalculator(object):
|
||||
# first time we see this family path
|
||||
if (posfam is not None and relstrfirst is not None and
|
||||
relstrsec is not None):
|
||||
#we already have a common ancestor of this family, just add the
|
||||
#other, setting correct family relation
|
||||
# We already have a common ancestor of this family, just
|
||||
# add the other, setting correct family relation.
|
||||
tmp = commonnew[posfam]
|
||||
frstcomstr = rela2[-1]
|
||||
scndcomstr = tmp[2][-1]
|
||||
newcomstra = self.famrel_from_persrel(frstcomstr, scndcomstr)
|
||||
newcomstra = self._famrel_from_persrel(frstcomstr,
|
||||
scndcomstr)
|
||||
frstcomstr = rela4[-1]
|
||||
scndcomstr = tmp[4][-1]
|
||||
newcomstrb = self.famrel_from_persrel(frstcomstr, scndcomstr)
|
||||
newcomstrb = self._famrel_from_persrel(frstcomstr,
|
||||
scndcomstr)
|
||||
|
||||
commonnew[posfam] = (tmp[0], tmp[1]+commonhandle,
|
||||
rela2[:-1]+newcomstra,
|
||||
@ -1142,7 +1140,7 @@ class RelationshipCalculator(object):
|
||||
|
||||
return collapsed
|
||||
|
||||
def famrel_from_persrel(self, persrela, persrelb):
|
||||
def _famrel_from_persrel(self, persrela, persrelb):
|
||||
""" Conversion from eg 'f' and 'm' to 'a', so relation to the two
|
||||
persons of a common family is converted to a family relation
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user