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:
parent
a6fafa5409
commit
ac2e0e2547
@ -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)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -42,7 +42,6 @@ import gen.lib
|
||||
from Utils import probably_alive, ProgressMeter
|
||||
|
||||
import libholiday
|
||||
from libholiday import _make_date
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -201,12 +200,16 @@ class CalendarReport(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
|
||||
|
||||
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:
|
||||
@ -224,20 +227,31 @@ class CalendarReport(Report):
|
||||
if father_handle:
|
||||
father = self.database.get_person_from_handle(father_handle)
|
||||
if father is not None:
|
||||
father_lastname = father.get_primary_name().get_surname()
|
||||
father_lastname = father.get_primary_name().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):
|
||||
comment = ""
|
||||
if self.relationships:
|
||||
relation = rel_calc.get_one_relationship(
|
||||
self.database,
|
||||
self.center_person,
|
||||
person)
|
||||
if relation:
|
||||
comment = " --- %s" % relation
|
||||
self.add_day_item("%s, %d%s" % (short_name, age, comment), month, day)
|
||||
|
||||
alive = probably_alive(person, self.database, prob_alive_date)
|
||||
if ((self.alive and alive) or not self.alive):
|
||||
|
||||
comment = ""
|
||||
if self.relationships:
|
||||
relation = rel_calc.get_one_relationship(
|
||||
self.database,
|
||||
self.center_person,
|
||||
person)
|
||||
if relation:
|
||||
comment = " --- %s" % relation
|
||||
if nyears == 0:
|
||||
text = _('%(person)s, birth%(relation)s') % {
|
||||
'person' : short_name,
|
||||
'relation' : comment}
|
||||
else:
|
||||
text = _('%(person)s, %(age)d%(relation)s') % {
|
||||
'person' : short_name,
|
||||
'age' : nyears,
|
||||
'relation' : comment}
|
||||
|
||||
self.add_day_item(text, month, day)
|
||||
if self.anniversaries:
|
||||
family_list = person.get_family_handle_list()
|
||||
for fhandle in family_list:
|
||||
@ -273,16 +287,23 @@ class CalendarReport(Report):
|
||||
year = event_obj.get_year()
|
||||
month = event_obj.get_month()
|
||||
day = event_obj.get_day()
|
||||
years = self.year - year
|
||||
if years >= 0:
|
||||
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):
|
||||
'nyears' : nyears}
|
||||
|
||||
prob_alive_date = gen.lib.Date(self.year, month, day)
|
||||
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)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
@ -2758,7 +2758,7 @@ class NavWebReport(Report):
|
||||
value)
|
||||
return
|
||||
|
||||
self.progress = Utils.ProgressMeter(_("Generate XHTML Reports"), '')
|
||||
self.progress = Utils.ProgressMeter(_("Narrated Web Site Report"), '')
|
||||
|
||||
# Build the person list
|
||||
ind_list = self.build_person_list()
|
||||
|
@ -78,7 +78,6 @@ from DateHandler import displayer as _dd
|
||||
from DateHandler import parser as _dp
|
||||
|
||||
import libholiday
|
||||
from libholiday import _make_date
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -321,13 +320,14 @@ class WebCalReport(Report):
|
||||
|
||||
if month > 0:
|
||||
try:
|
||||
my_date = _make_date(year, month, day)
|
||||
event_date = gen.lib.Date()
|
||||
event_date.set_yr_mon_day(year, month, day)
|
||||
except ValueError:
|
||||
my_date = '...'
|
||||
event_date = '...'
|
||||
else:
|
||||
my_date = '...' #Incomplete date as in about, circa, etc.
|
||||
event_date = '...' #Incomplete date as in about, circa, etc.
|
||||
|
||||
day_list.append((text, event, my_date))
|
||||
day_list.append((text, event, event_date))
|
||||
month_dict[day] = day_list
|
||||
self.calendar[month] = month_dict
|
||||
|
||||
@ -614,7 +614,8 @@ class WebCalReport(Report):
|
||||
# specify day class for this day
|
||||
of.write('class="%s">\n' % hilightday)
|
||||
|
||||
event_date = _make_date(thisday.year, thisday.month, thisday.day)
|
||||
event_date = gen.lib.Date()
|
||||
event_date.set_yr_mon_day(thisday.year, thisday.month, thisday.day)
|
||||
day_list = get_day_list(event_date, holiday_list, bday_anniv_list)
|
||||
|
||||
if day_list:
|
||||
@ -902,7 +903,7 @@ class WebCalReport(Report):
|
||||
"""
|
||||
|
||||
# open progress meter bar
|
||||
self.progress = Utils.ProgressMeter(_("Generate XHTML Calendars"), '')
|
||||
self.progress = Utils.ProgressMeter(_("Web Calendar Report"), '')
|
||||
|
||||
# get data from database for birthdays/ anniversaries
|
||||
# TODO. Verify that we collect correct info based on start_year
|
||||
@ -998,7 +999,7 @@ class WebCalReport(Report):
|
||||
nr_up = 1 # Number of directory levels up to get to self.html_dir / root
|
||||
|
||||
# generate progress pass for "WebCal"
|
||||
self.progress.set_pass(_('Creating WebCal calendars'), self.end_month - self.start_month)
|
||||
self.progress.set_pass(_('Formatting months ...'), self.end_month - self.start_month)
|
||||
|
||||
for month in range(self.start_month, self.end_month + 1):
|
||||
|
||||
@ -1072,11 +1073,15 @@ class WebCalReport(Report):
|
||||
month = birth_date.get_month()
|
||||
day = birth_date.get_day()
|
||||
|
||||
prob_alive_date = gen.lib.Date(this_year, month, day)
|
||||
|
||||
# add some things to handle maiden name:
|
||||
father_lastname = None # husband, actually
|
||||
sex = person.get_gender()
|
||||
if sex == gen.lib.Person.FEMALE:
|
||||
if self.maiden_name in ['spouse_first', 'spouse_last']: # get husband's last name:
|
||||
|
||||
# get husband's last name:
|
||||
if self.maiden_name in ['spouse_first', 'spouse_last']:
|
||||
if len(family_list) > 0:
|
||||
if self.maiden_name == 'spouse_first':
|
||||
fhandle = family_list[0]
|
||||
@ -1092,9 +1097,9 @@ class WebCalReport(Report):
|
||||
father_name = father.get_primary_name()
|
||||
father_lastname = _get_regular_surname(sex, father_name)
|
||||
short_name = _get_short_name(person, father_lastname)
|
||||
alive = probably_alive(person, self.database, _make_date(this_year, month, day))
|
||||
alive = probably_alive(person, self.database, prob_alive_date)
|
||||
text = _('%(short_name)s') % {'short_name' : short_name}
|
||||
if ((self.alive and alive) or not self.alive):
|
||||
if (self.alive and alive) or not self.alive:
|
||||
self.add_day_item(text, year, month, day, 'Birthday')
|
||||
|
||||
# add anniversary if requested
|
||||
@ -1122,6 +1127,8 @@ class WebCalReport(Report):
|
||||
month = event_obj.get_month()
|
||||
day = event_obj.get_day()
|
||||
|
||||
prob_alive_date = gen.lib.Date(this_year, month, day)
|
||||
|
||||
# determine if anniversary date is a valid date???
|
||||
complete_date = False
|
||||
if event_obj.get_valid():
|
||||
@ -1132,8 +1139,8 @@ class WebCalReport(Report):
|
||||
'spouse' : spouse_name,
|
||||
'person' : short_name}
|
||||
|
||||
alive1 = probably_alive(person, self.database, _make_date(this_year, month, day))
|
||||
alive2 = probably_alive(spouse, self.database, _make_date(this_year, month, day))
|
||||
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, year, month, day, 'Anniversary')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user