Pylint cleanup for the relationship calculator.

svn: r13421
This commit is contained in:
Brian Matherly 2009-10-26 02:10:14 +00:00
parent 7290694c43
commit 22693cfbad

View File

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