diff --git a/models/Family.py b/models/Family.py index e289ae6..4e77a30 100644 --- a/models/Family.py +++ b/models/Family.py @@ -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}") @@ -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()}") @@ -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()}") @@ -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()}") @@ -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 @@ -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 @@ -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 @@ -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.") @@ -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): diff --git a/models/Gedcom.py b/models/Gedcom.py index 66e54eb..4a4c3f5 100644 --- a/models/Gedcom.py +++ b/models/Gedcom.py @@ -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 @@ -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) @@ -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) diff --git a/models/Individual.py b/models/Individual.py index 52c697f..43baf36 100644 --- a/models/Individual.py +++ b/models/Individual.py @@ -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): @@ -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)) @@ -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") @@ -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")