From 46d73a16a06b5503962c65d6d001aca678ed925f Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Sun, 2 Jul 2017 13:37:17 -0700 Subject: [PATCH] add verify.py rules: match same birth or death date as marriage date Issue #2583 --- gramps/plugins/tool/verify.py | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/gramps/plugins/tool/verify.py b/gramps/plugins/tool/verify.py index 51cf6907e..db0f2a42a 100644 --- a/gramps/plugins/tool/verify.py +++ b/gramps/plugins/tool/verify.py @@ -435,6 +435,9 @@ class Verify(tool.Tool, ManagedWindow, UpdateCallback): Disconnected(self.db, person), InvalidBirthDate(self.db, person, invdate), InvalidDeathDate(self.db, person, invdate), + BirthEqualsDeath(self.db, person), + BirthEqualsMarriage(self.db, person), + DeathEqualsMarriage(self.db, person), ] for rule in rule_list: @@ -1788,3 +1791,55 @@ class OldAgeButNoDeath(PersonRule): """ return the rule's error message """ return _("Old age but no death") +class BirthEqualsDeath(PersonRule): + """ test if a person's birth date is the same as their death date """ + ID = 33 + SEVERITY = Rule.ERROR + def broken(self): + """ return boolean indicating whether this rule is violated """ + birth_date = get_birth_date(self.db, self.obj) + death_date = get_death_date(self.db, self.obj) + birth_ok = birth_date > 0 if birth_date is not None else False + death_ok = death_date > 0 if death_date is not None else False + return death_ok and birth_ok and birth_date == death_date + + def get_message(self): + """ return the rule's error message """ + return _("Birth equals death") + +class BirthEqualsMarriage(PersonRule): + """ test if a person's birth date is the same as their marriage date """ + ID = 34 + SEVERITY = Rule.ERROR + def broken(self): + """ return boolean indicating whether this rule is violated """ + birth_date = get_birth_date(self.db, self.obj) + birth_ok = birth_date > 0 if birth_date is not None else False + for fhandle in self.obj.get_family_handle_list(): + family = self.db.get_family_from_handle(fhandle) + marr_date = get_marriage_date(self.db, family) + marr_ok = marr_date > 0 if marr_date is not None else False + return marr_ok and birth_ok and birth_date == marr_date + + def get_message(self): + """ return the rule's error message """ + return _("Birth equals marriage") + +class DeathEqualsMarriage(PersonRule): + """ test if a person's death date is the same as their marriage date """ + ID = 35 + SEVERITY = Rule.WARNING # it's possible + def broken(self): + """ return boolean indicating whether this rule is violated """ + death_date = get_death_date(self.db, self.obj) + death_ok = death_date > 0 if death_date is not None else False + for fhandle in self.obj.get_family_handle_list(): + family = self.db.get_family_from_handle(fhandle) + marr_date = get_marriage_date(self.db, family) + marr_ok = marr_date > 0 if marr_date is not None else False + return marr_ok and death_ok and death_date == marr_date + + def get_message(self): + """ return the rule's error message """ + return _("Death equals marriage") +