removed _make_date module from libholiday as request by Brian. Removed make_date completely and substituted gen.lib.Date() instead for Calendar, BirthdayReport, and WebCal. Changes progress bar text in WebCal and NarrativeWeb.

svn: r11837
This commit is contained in:
Rob G. Healey
2009-02-04 05:35:34 +00:00
parent a6fafa5409
commit ac2e0e2547
4 changed files with 106 additions and 61 deletions

View File

@@ -43,22 +43,16 @@ from Utils import probably_alive, ProgressMeter
from FontScale import string_trim
import libholiday
from libholiday import _make_date
from libholiday import g2iso
#------------------------------------------------------------------------
#
# Support functions
# Constants
#
#------------------------------------------------------------------------
pt2cm = ReportUtils.pt2cm
cm2pt = ReportUtils.cm2pt
def g2iso(dow):
""" Converst GRAMPS day of week to ISO day of week """
# GRAMPS: SUN = 1
# ISO: MON = 1
return (dow + 5) % 7 + 1
#------------------------------------------------------------------------
#
# Calendar
@@ -143,7 +137,7 @@ class Calendar(Report):
def write_report(self):
""" The short method that runs through each month and creates a page. """
# initialize the dict to fill:
self.progress = ProgressMeter(_('Calendar'))
self.progress = ProgressMeter(_('Calendar Report'))
self.calendar = {}
# get the information, first from holidays:
@@ -259,12 +253,16 @@ class Calendar(Report):
birth_date = None
if birth_ref:
birth_event = self.database.get_event_from_handle(birth_ref.ref)
birth_date = birth_event.get_date_object()
birth_date = birth_event.get_date_object()
if self.birthdays and birth_date is not None:
year = birth_date.get_year()
month = birth_date.get_month()
day = birth_date.get_day()
age = self.year - year
day = birth_date.get_day()
prob_alive_date = gen.lib.Date(self.year, month, day)
nyears = self.year - year
# add some things to handle maiden name:
father_lastname = None # husband, actually
if self.maiden_name in ['spouse_first', 'spouse_last']: # get husband's last name:
@@ -284,10 +282,19 @@ class Calendar(Report):
if father is not None:
father_lastname = father.get_primary_name().get_surname()
short_name = self.get_name(person, father_lastname)
if age >= 0:
alive = probably_alive(person, self.database, _make_date(self.year, month, day))
if ((self.alive and alive) or not self.alive):
self.add_day_item("%s, %d%s" % (short_name, age, ""), month, day)
alive = probably_alive(person, self.database, prob_alive_date)
if (self.alive and alive) or not self.alive:
if nyears == 0:
text = _('%(person)s, birth%(relation)s') % {
'person' : short_name,
'relation' : ""}
else:
text = _('%(person)s, %(age)d%(relation)s') % {
'person' : short_name,
'age' : nyears,
'relation' : ""}
self.add_day_item(text, month, day)
if self.anniversaries:
family_list = person.get_family_handle_list()
for fhandle in family_list:
@@ -323,17 +330,27 @@ class Calendar(Report):
year = event_obj.get_year()
month = event_obj.get_month()
day = event_obj.get_day()
years = self.year - year
if years >= 0:
prob_alive_date = gen.lib.Date(self.year, month, day)
nyears = self.year - year
if nyears == 0:
text = _("%(spouse)s and\n %(person)s, wedding") % {
'spouse' : spouse_name,
'person' : short_name,
}
else:
text = _("%(spouse)s and\n %(person)s, %(nyears)d") % {
'spouse' : spouse_name,
'person' : short_name,
'nyears' : years,
}
alive1 = probably_alive(person, self.database, _make_date(self.year, month, day))
alive2 = probably_alive(spouse, self.database, _make_date(self.year, month, day))
if ((self.alive and alive1 and alive2) or not self.alive):
self.add_day_item(text, month, day)
'nyears' : nyears}
alive1 = probably_alive(person, self.database, \
prob_alive_date)
alive2 = probably_alive(spouse, self.database, \
prob_alive_date)
if ((self.alive and alive1 and alive2) or not self.alive):
self.add_day_item(text, month, day)
#------------------------------------------------------------------------
#