Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions models/Family.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def marriage_before_divorce(self):
if timedelta.days < 0:
return True
else:
self.get_lineNum()['MARR'] if "MARR" in self.get_lineNum() else "N/A"
raise Error('ERROR', 'FAMILY', 'US04', self.get_lineNum()["MARR"],
f"Family marriage date {marriage} is after divorce date {divorce}")

Expand All @@ -170,6 +171,7 @@ def marriage_after_14(self) -> bool:
if (husbandMarryAge > 14 and wifeMarryAge > 14):
return True
else:
self.get_lineNum()['MARR'] if "MARR" in self.get_lineNum() else "N/A"
raise Error('ERROR', 'FAMILY', 'US10', self.get_lineNum()["MARR"],
f"Family marriage date {self.get_marriedDate()} is not 14 years after"
f"Husband birthday {self._husband.get_birthDate()} or Wife birthday {self._wife.get_birthDate()}")
Expand Down Expand Up @@ -198,6 +200,7 @@ def marriage_before_death(self):
if timedelta.days <= 0:
return True
else:
self.get_lineNum()['MARR'] if "MARR" in self.get_lineNum() else "N/A"
raise Error('ERROR', 'FAMILY', 'US05', self.get_lineNum()["MARR"],
f"Family marriage date {marriage} is after death date of husband {self._husband.get_deathDate()} or wife {self._wife.get_deathDate()}")

Expand All @@ -222,6 +225,7 @@ def divorce_before_death(self) -> bool:
if deathdays < 0:
return True
else:
self.get_lineNum()['DIV'] if "DIV" in self.get_lineNum() else "N/A"
raise Error('ERROR', 'FAMILY', 'US05', self.get_lineNum()["DIV"],
f"Family divorce date {self.get_divorcedDate()} is after death date of husband {self._husband.get_deathDate()} or wife {self._wife.get_deathDate()}")

Expand All @@ -234,6 +238,7 @@ def birth_before_marriage_of_parents(self):
if not c.get_birthDate(): raise AttributeError("Missing child birthDate")
if c.get_birthDate() <= self.get_marriedDate():
# return False
c.get_lineNum()['BIRT'] if "BIRT" in c.get_lineNum() else "N/A"
raise Error('ANOMALY', 'FAMILY', 'US08', c.get_lineNum()["BIRT"],
f"Child birthday {c.get_birthDate()} is after marriage date of Family {self.get_marriedDate()}")
return True
Expand All @@ -249,6 +254,7 @@ def birth_before_death_of_parents(self):
for c in self._children:
if c.get_birthDate() > death:
# return False
c.get_lineNum()['BIRT'] if "BIRT" in c.get_lineNum() else "N/A"
raise Error('ERROR', 'FAMILY', 'US09', c.get_lineNum()["BIRT"],
f"Child birthday {c.get_birthDate()} is after death date of mother {death}")
return True
Expand Down Expand Up @@ -307,7 +313,9 @@ def fewer_than_15_siblings(self):
"""
if len(self._children) < 15:
return True
else: raise Error('ERROR', 'FAMILY', 'US15', self.get_lineNum()["FAM ID"],
else:
self.get_lineNum()['FAM ID'] if "FAM ID" in self.get_lineNum() else "N/A"
raise Error('ERROR', 'FAMILY', 'US15', self.get_lineNum()["FAM ID"],
f"The siblings of the family is more than 15.")

#US21 Husband in family should be male and wife in family should be female
Expand All @@ -321,7 +329,9 @@ def correct_gender_for_role(self):
"missing gender of husband or wife")
if self._husband.get_gender() == "M" and self._wife.get_gender() == "F":
return True
else:raise Error ('ERROR', 'FAMILY', 'US21', self.get_lineNum()["FAM ID"],
else:
self.get_lineNum()['FAM ID'] if "FAM ID" in self.get_lineNum() else "N/A"
raise Error ('ERROR', 'FAMILY', 'US21', self.get_lineNum()["FAM ID"],
f"Family {self.get_id()} 's husband {self.get_husband().get_id()} 's gender {self.get_husband().get_gender()} is incorrect "
f"or wife {self.get_wife().get_id()} 's gender {self.get_wife().get_gender()} is incorrect.")

Expand Down Expand Up @@ -354,7 +364,9 @@ def siblings_should_not_marry(self):
"Missing husband and wife parent")
if not self._husband.get_parent_family().get_id() == self._wife.get_parent_family().get_id():
return True
else:raise Error('ERROR', 'FAMILY', 'US18', self.get_lineNum()['FAM ID'], f"Siblings in family {self.get_id()} are married.")
else:
self.get_lineNum()['FAM ID'] if "FAM ID" in self.get_lineNum() else "N/A"
raise Error('ERROR', 'FAMILY', 'US18', self.get_lineNum()['FAM ID'], f"Siblings in family {self.get_id()} are married.")

#US28 List siblings in families by decreasing age, i.e. oldest siblings first
def order_siblings_by_age(self):
Expand Down
3 changes: 3 additions & 0 deletions models/Gedcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def unique_name_and_birth_date(self):
dic.add(indi)
else:
#return False
indi.get_lineNum()['INDI ID'] if "INDI ID" in indi.get_lineNum() else "N/A"
raise Error('ANOMALY', 'GEDCOM', 'US023', indi.get_lineNum()['INDI ID'],
f"Individual {indi.get_id()} appears multiple times in the GEDCOM file")
return True
Expand All @@ -266,6 +267,7 @@ def unique_families_by_spouses(self):
this_fam_info = [family.get_husband().get_name(), family.get_wife.get_name(), family.get_marriedDate()]
if this_fam_info in check_list:
# return False
family.get_lineNum()['FAM ID'] if "FAM ID" in family.get_lineNum() else "N/A"
raise Error('ANOMALY', 'GEDCOM', 'US024', family.get_lineNum()['FAM ID'],
f"Family {family.get_id()} has repeated marriage date {family.get_marriedDate()} or spouse name {family._wife.get_name()}")
check_list.append(this_fam_info)
Expand All @@ -282,6 +284,7 @@ def unique_first_names_in_families(self):
child_info = [child.get_name(), child.get_birthDate()]
if child_info in check_list:
# return False
child.get_lineNum()['INDI ID'] if "INDI ID" in child.get_lineNum() else "N/A"
raise Error('ERROR', 'GEDCOM', 'US025', child.get_lineNum()['INDI ID'],
f"Child {child.get_id()} 's birthday {child.get_birthDate()} or name {child.get_name()} is repeated in a family")
check_list.append(child_info)
Expand Down
11 changes: 10 additions & 1 deletion models/Individual.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def birth_before_death(self):
#US07 Death should be less than 150 years after birth for dead people, and current date should be less than 150 years after birth for all living people
def less_then_150_years_old(self):
if self.get_age() < 150: return True
else: raise Error('ANOMALY', 'INDIVIDUAL', 'US07', self.get_lineNum()['BIRT'], f" Individual's Age {self.get_age()} is greater than 150")
else:
self.get_lineNum()['BIRT'] if "BIRT" in self.get_lineNum() else "N/A"
raise Error('ANOMALY', 'INDIVIDUAL', 'US07', self.get_lineNum()['BIRT'], f" Individual's Age {self.get_age()} is greater than 150")

#US11 Marriage should not occur during marriage to another spouse //EXPLAIN CASE
def no_bigamy(self):
Expand All @@ -155,26 +157,31 @@ def no_bigamy(self):
for Age_range in marrageAgeList:
if (Age_range[1] == devorceAge and devorceAge == None):
#return False
self.get_lineNum()['INDI ID'] if "INDI ID" in self.get_lineNum() else "N/A"
raise Error('ERROR', 'INDIVIDUAL', 'US11', self.get_lineNum()['INDI ID'],
f" Individual {self.get_id()} has committed bigamy")

elif ((not Age_range[1] == devorceAge) and devorceAge == None):
if (not (Age_range[0] < marrageAge and Age_range[1] < marrageAge)):
#return False
self.get_lineNum()['INDI ID'] if "INDI ID" in self.get_lineNum() else "N/A"
raise Error('ERROR', 'INDIVIDUAL', 'US11', self.get_lineNum()['INDI ID'],
f" Individual {self.get_id()} has committed bigamy")
elif ((not Age_range[1] == devorceAge) and Age_range[1] == None):
if (not (marrageAge < Age_range[0] and devorceAge < Age_range[0])):
#return False
self.get_lineNum()['INDI ID'] if "INDI ID" in self.get_lineNum() else "N/A"
raise Error('ERROR', 'INDIVIDUAL', 'US11', self.get_lineNum()['INDI ID'],
f" Individual {self.get_id()} has committed bigamy")
else:
if (marrageAge > Age_range[0] and marrageAge < Age_range[1]):
#return False
self.get_lineNum()['INDI ID'] if "INDI ID" in self.get_lineNum() else "N/A"
raise Error('ERROR', 'INDIVIDUAL', 'US11', self.get_lineNum()['INDI ID'],
f" Individual {self.get_id()} has committed bigamy")
elif (devorceAge > Age_range[0] and devorceAge < Age_range[1]):
#return False
self.get_lineNum()['INDI ID'] if "INDI ID" in self.get_lineNum() else "N/A"
raise Error('ERROR', 'INDIVIDUAL', 'US11', self.get_lineNum()['INDI ID'],
f" Individual {self.get_id()} has committed bigamy")
marrageAgeList.append((marrageAge, devorceAge))
Expand Down Expand Up @@ -245,6 +252,7 @@ def first_cousins_should_not_marry(self):
for first_cousin in child_fam.get_children():
if first_cousin == self:
#return False
first_cousin.get_lineNum()['INDI ID'] if "INDI ID" in first_cousin.get_lineNum() else "N/A"
raise Error('ANOMALY', 'INDIVIDUAL', 'US19',
first_cousin.get_lineNum()['INDI ID'],
f"first_cousin {first_cousin.get_id()} is married to each other")
Expand All @@ -258,6 +266,7 @@ def first_cousins_should_not_marry(self):
for first_cousin in mummy_sibling_fam.get_children():
if first_cousin == self:
#return False
first_cousin.get_lineNum()['INDI ID'] if "INDI ID" in first_cousin.get_lineNum() else "N/A"
raise Error('ANOMALY', 'INDIVIDUAL', 'US19',
first_cousin.get_lineNum()['INDI ID'],
f"first_cousin {first_cousin.get_id()} is married to each other")
Expand Down