Skip to content

Commit

Permalink
Added method for US19: no_marriage_to_cousin
Browse files Browse the repository at this point in the history
  • Loading branch information
Eamon18 authored Oct 30, 2018
1 parent cfb2ef2 commit 0bdd04c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion GedcomProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def __init__(self, ind_dict, fam_dict, errors, print_errors):
self.too_many_siblings() #US15
self.no_marriage_to_descendants()#US17
self.no_marriage_to_siblings() #US18
self.no_marriage_to_cousin() #US19
self.creepy_aunts_and_uncles() #US20
self.correct_gender_role() #US21
self.unique_names_and_bdays() #US23
Expand Down Expand Up @@ -429,7 +430,26 @@ def no_marriage_to_siblings(self):
self.all_errors +=["US18: {} cannot be married to their sibling {}".format(person.name, self.individuals[self.family[fam].husb].name)]
elif(tempWife in self.family[person.famc].chil and self.individuals[self.family[fam].wife] != person):
self.all_errors +=["US18: {} cannot be married to their sibling {}".format(person.name, self.individuals[self.family[fam].wife].name)]


def no_marriage_to_cousin(self):
"""US19: Tests to ensure that individuals do not marry their first cousins"""
couples = []
for fam in self.family.values():
mom = fam.wife
dad = fam.husb
for currIndi in fam.chil:
if self.individuals[mom].famc != None:
for auntUncle in self.family[self.individuals[mom].famc].chil: #mom's siblings
for cousin in self.get_childrenID(auntUncle): #cousin's on mom's side
if self.get_spouse(cousin) == currIndi and [currIndi,cousin] not in couples:
self.all_errors+=["US19: {} cannot be married to their cousin {}".format(self.individuals[currIndi].name, self.individuals[cousin].name)]
couples.append([cousin,currIndi])
if self.individuals[dad].famc != None:
for auntUncle in self.family[self.individuals[dad].famc].chil: #dad's siblings
for cousin in self.get_childrenID(auntUncle): #cousins on dad's side
if self.get_spouse(cousin) == currIndi and [currIndi,cousin] not in couples:
self.all_errors+=["US19: {} cannot be married to their cousin {}".format(self.individuals[currIndi].name, self.individuals[cousin].name)]
couples.append( [cousin,currIndi])

def get_childrenID(self, indi_ID):
"""returns a list of children IDs of the given individual ID"""
Expand Down

0 comments on commit 0bdd04c

Please sign in to comment.