From a81fd54c10a7aab5c31249312c69096be5563359 Mon Sep 17 00:00:00 2001 From: David Hampton Date: Sun, 16 Dec 2001 02:58:02 +0000 Subject: [PATCH] Consolidate all definitions of probably_alive() into one. svn: r623 --- gramps/src/Date.py | 13 +++++++++++++ gramps/src/RelLib.py | 10 +++++++++- gramps/src/plugins/WebPage.py | 25 +------------------------ gramps/src/plugins/WriteGedcom.py | 28 +++++----------------------- gramps/src/plugins/WritePafPalm.py | 26 -------------------------- 5 files changed, 28 insertions(+), 74 deletions(-) diff --git a/gramps/src/Date.py b/gramps/src/Date.py index a91d6567f..c4b3adbf9 100644 --- a/gramps/src/Date.py +++ b/gramps/src/Date.py @@ -22,6 +22,7 @@ from re import IGNORECASE, compile import string +import time from Calendar import * from intl import gettext @@ -962,6 +963,18 @@ class SingleDate: self.month = m-1 self.day = d +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def not_too_old(date): + time_struct = time.localtime(time.time()) + current_year = time_struct[0] + if date.year != UNDEF and current_year - date.year > 110: + return 0 + return 1 + #------------------------------------------------------------------------- # # diff --git a/gramps/src/RelLib.py b/gramps/src/RelLib.py index 0c50ec0f8..5a2c72cdd 100644 --- a/gramps/src/RelLib.py +++ b/gramps/src/RelLib.py @@ -24,7 +24,7 @@ __author__ = "Don Allingham" from re import compile -from Date import Date, compare_dates +from Date import Date, compare_dates, not_too_old from string import strip CONF_VERY_HIGH = 4 @@ -1105,6 +1105,14 @@ class Person: def getLdsSeal(self): return self.lds_seal + + def probablyAlive(self): + if self.death.getDate() != "": + return 0 + if self.birth.getDate() != "": + return not_too_old(self.birth.getDateObj().get_start_date()) + return 1 + class Event(DataObj): """Event record, recording the event type, description, place, and date diff --git a/gramps/src/plugins/WebPage.py b/gramps/src/plugins/WebPage.py index bdd4d1801..161f5bea0 100644 --- a/gramps/src/plugins/WebPage.py +++ b/gramps/src/plugins/WebPage.py @@ -92,7 +92,7 @@ class IndividualPage: self.doc = doc self.list = map self.private = private - self.alive = probably_alive(person) and restrict + self.alive = person.probablyAlive() and restrict self.photos = (photos == 2) or (photos == 1 and not self.alive) self.usecomments = not uc self.dir = dir_name @@ -671,29 +671,6 @@ filter_map = { _("Entire database") : entire_db_filter } -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def probably_alive(person): - - if person == None: - return 1 - - death = person.getDeath() - birth = person.getBirth() - - if death.getDate() != "": - return 0 - if birth.getDate() != "": - year = birth.getDateObj().get_start_date() - time_struct = time.localtime(time.time()) - current_year = time_struct[0] - if year.getYearValid() and current_year - year.getYear() > 110: - return 0 - return 1 - #------------------------------------------------------------------------ # # diff --git a/gramps/src/plugins/WriteGedcom.py b/gramps/src/plugins/WriteGedcom.py index fa6763c38..2919492c7 100644 --- a/gramps/src/plugins/WriteGedcom.py +++ b/gramps/src/plugins/WriteGedcom.py @@ -571,18 +571,19 @@ class GedcomWriter: nump = float(len(self.flist)) index = 0.0 for family in self.flist: + father_alive = mother_alive = 0 self.g.write("0 @%s@ FAM\n" % self.fid(family.getId())) person = family.getFather() if person != None: self.g.write("1 HUSB @%s@\n" % self.pid(person.getId())) + father_alive = person.probablyAlive() person = family.getMother() if person != None: self.g.write("1 WIFE @%s@\n" % self.pid(person.getId())) + mother_alive = person.probablyAlive() - father = family.getFather() - mother = family.getMother() - if not self.probably_alive(father) or not self.probably_alive(mother): + if not self.restrict or ( not father_alive and not mother_alive ): self.write_ord("SLGS",family.getLdsSeal(),1) for event in family.getEventList(): @@ -665,7 +666,7 @@ class GedcomWriter: elif person.getGender() == Person.female: self.g.write("1 SEX F\n") - if not self.probably_alive(person): + if not self.restrict or not person.probablyAlive(): birth = person.getBirth() if not (self.private and birth.getPrivacy()): @@ -980,25 +981,6 @@ class GedcomWriter: if ref.getComments() != "": self.write_long_text("NOTE",level+1,ref.getComments()) - def probably_alive(self,person): - if person == None: - return 1 - if self.restrict == 0: - return 0 - - death = person.getDeath() - birth = person.getBirth() - - if death.getDate() != "": - return 0 - if birth.getDate() != "": - year = birth.getDateObj() - time_struct = time.localtime(time.time()) - current_year = time_struct[0] - if year.getYearValid() and current_year - year.getYear() > 110: - return 0 - return 1 - def fid(self,id): if self.fidmap.has_key(id): return self.fidmap[id] diff --git a/gramps/src/plugins/WritePafPalm.py b/gramps/src/plugins/WritePafPalm.py index df16122a0..bbfb11921 100644 --- a/gramps/src/plugins/WritePafPalm.py +++ b/gramps/src/plugins/WritePafPalm.py @@ -260,32 +260,6 @@ def sortByName(first,second): return 1 -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def probably_alive(person): - - if person == None: - return 1 - - if restrict == 0: - return 0 - - death = person.getDeath() - birth = person.getBirth() - - if death.getDate() != "": - return 0 - if birth.getDate() != "": - year = birth.getDateObj() - time_struct = time.localtime(time.time()) - current_year = time_struct[0] - if year.getYearValid() and current_year - year.getYear() > 110: - return 0 - return 1 - #------------------------------------------------------------------------- # #