More code cleanup in get_day_list() with help from Kees Bakker.
svn: r12052
This commit is contained in:
parent
bc4ba94a94
commit
1f36ff6a13
@ -426,7 +426,8 @@ class WebCalReport(Report):
|
|||||||
num_years = (self.end_year - self.start_year)
|
num_years = (self.end_year - self.start_year)
|
||||||
cal_year = self.start_year
|
cal_year = self.start_year
|
||||||
|
|
||||||
for rows in range((num_years // 16) + 1):
|
nrows = (num_years / 16)
|
||||||
|
for rows in range(0, (nrows + 1)):
|
||||||
of.write('<div id="navigation">\n')
|
of.write('<div id="navigation">\n')
|
||||||
of.write('\t<ul>\n')
|
of.write('\t<ul>\n')
|
||||||
cols = 0
|
cols = 0
|
||||||
@ -907,12 +908,12 @@ class WebCalReport(Report):
|
|||||||
for cal_year in range(self.start_year, (self.end_year + 1)):
|
for cal_year in range(self.start_year, (self.end_year + 1)):
|
||||||
|
|
||||||
# generate progress pass for year ????
|
# generate progress pass for year ????
|
||||||
self.progress.set_pass(_('Creating year %d calendars') % cal_year, 1)
|
self.progress.set_pass(_('Creating year %d calendars') % cal_year, '')
|
||||||
|
|
||||||
# initialize the holidays dict to fill:
|
# initialize the holidays dict to fill:
|
||||||
self.holidays = {}
|
self.holidays = {}
|
||||||
|
|
||||||
# get the information, first from holidays:
|
# get the information, USA is equal to zero now
|
||||||
if self.country != 0:
|
if self.country != 0:
|
||||||
self.__get_holidays(cal_year)
|
self.__get_holidays(cal_year)
|
||||||
|
|
||||||
@ -1434,59 +1435,60 @@ def get_day_list(event_date, holiday_list, bday_anniv_list):
|
|||||||
# initialize day_list
|
# initialize day_list
|
||||||
day_list = []
|
day_list = []
|
||||||
|
|
||||||
|
##################################################################
|
||||||
# holiday on this day
|
# holiday on this day
|
||||||
if holiday_list > []:
|
# The 0 will force holidays to be first in the list
|
||||||
|
for event_name in holiday_list:
|
||||||
# will force holidays to be first in the list
|
for line in event_name.splitlines():
|
||||||
nyears = 0
|
day_list.append((0, event_date, line, 'Holiday'))
|
||||||
|
##################################################################
|
||||||
for event_name in holiday_list:
|
|
||||||
for line in event_name.splitlines():
|
|
||||||
day_list.append((nyears, event_date, line, 'Holiday'))
|
|
||||||
|
|
||||||
|
##################################################################
|
||||||
# birthday/ anniversary on this day
|
# birthday/ anniversary on this day
|
||||||
if bday_anniv_list > []:
|
# '...' signifies an incomplete date for an event. See add_day_item()
|
||||||
birth_anniversary = [(t, e, d) for t, e, d in bday_anniv_list if d.is_valid()]
|
bday_anniv_list = [(t, e, d) for t, e, d in bday_anniv_list
|
||||||
for text, event, date in birth_anniversary:
|
if d != '...']
|
||||||
|
|
||||||
txt_str = None
|
# number of years have to be at least zero
|
||||||
|
bday_anniv_list = [(t, e, d) for t, e, d in bday_anniv_list
|
||||||
|
if (event_date.get_year() - d.get_year()) >= 0]
|
||||||
|
for text, event, date in bday_anniv_list:
|
||||||
|
|
||||||
# number of years married, ex: 10
|
# number of years married, ex: 10
|
||||||
nyears = event_date.get_year() - date.get_year()
|
nyears = event_date.get_year() - date.get_year()
|
||||||
|
|
||||||
# no negative years; have to be at least zero
|
txt_str = None
|
||||||
if nyears > -1:
|
|
||||||
|
|
||||||
# number of years for birthday, ex: 10 years
|
# number of years for birthday, ex: 10 years
|
||||||
age_str = event_date - date
|
age_str = event_date - date
|
||||||
age_str.format(precision=1)
|
age_str.format(precision=1)
|
||||||
|
|
||||||
# a birthday
|
# a birthday
|
||||||
if event == 'Birthday':
|
if event == 'Birthday':
|
||||||
|
|
||||||
if nyears == 0:
|
if nyears == 0:
|
||||||
txt_str = _('%(person)s, <em>birth</em>') % {
|
txt_str = _('%(person)s, <em>birth</em>') % {
|
||||||
'person' : text}
|
'person' : text}
|
||||||
else:
|
else:
|
||||||
txt_str = _('%(person)s, <em>%(age)s</em> old') % {
|
txt_str = _('%(person)s, <em>%(age)s</em> old') % {
|
||||||
'person' : text, 'age' : age_str}
|
'person' : text, 'age' : age_str}
|
||||||
|
|
||||||
# an anniversary
|
# an anniversary
|
||||||
elif event == 'Anniversary':
|
elif event == 'Anniversary':
|
||||||
|
|
||||||
if nyears == 0:
|
if nyears == 0:
|
||||||
txt_str = _('%(couple)s, <em>wedding</em>') % {
|
txt_str = _('%(couple)s, <em>wedding</em>') % {
|
||||||
'couple' : text}
|
'couple' : text}
|
||||||
else:
|
else:
|
||||||
txt_str = (ngettext('%(couple)s, <em>%(years)d'
|
txt_str = (ngettext('%(couple)s, <em>%(years)d'
|
||||||
'</em> year anniversary',
|
'</em> year anniversary',
|
||||||
'%(couple)s, <em>%(years)d'
|
'%(couple)s, <em>%(years)d'
|
||||||
'</em> year anniversary', nyears)
|
'</em> year anniversary', nyears)
|
||||||
% {'couple' : text, 'years' : nyears})
|
% {'couple' : text, 'years' : nyears})
|
||||||
txt_str = '<span class="yearsmarried">%s</span>' % txt_str
|
txt_str = '<span class="yearsmarried">%s</span>' % txt_str
|
||||||
|
|
||||||
if txt_str is not None:
|
if txt_str is not None:
|
||||||
day_list.append((nyears, date, txt_str, event))
|
day_list.append((nyears, date, txt_str, event))
|
||||||
|
|
||||||
# sort them based on number of years
|
# sort them based on number of years
|
||||||
# holidays will always be on top of day
|
# holidays will always be on top of day
|
||||||
@ -1558,7 +1560,6 @@ def get_next_day(year, month, day_col):
|
|||||||
next_month_day = firstweek_nextmonth[day_col]
|
next_month_day = firstweek_nextmonth[day_col]
|
||||||
return next_month_day
|
return next_month_day
|
||||||
|
|
||||||
# TODO. Eliminate this function, or make it do something useful.
|
|
||||||
def _has_webpage_extension(url):
|
def _has_webpage_extension(url):
|
||||||
"""
|
"""
|
||||||
determine if a filename has an extension or not...
|
determine if a filename has an extension or not...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user