diff --git a/src/plugins/WebCal.py b/src/plugins/WebCal.py index 37b541329..c2dc80279 100644 --- a/src/plugins/WebCal.py +++ b/src/plugins/WebCal.py @@ -47,8 +47,8 @@ TODO list: - untangle calendar_build, it's too complex the way it is - correct surname (prefix missing, or misinterpreted) - add_day_item and self.calendar seem to be adding list entries as list (list of list) - - get rid of self.year - daylight saving not just for USA and Europe + - move the close_file() from one_day() to caller """ #------------------------------------------------------------------------ @@ -230,8 +230,6 @@ class WebCalReport(Report): self.partyear = menu.get_option_by_name('partyear').get_value() self.multiyear = menu.get_option_by_name('multiyear').get_value() - # self.start_year, and self.year are the same value - self.year = menu.get_option_by_name('start_year').get_value() self.start_year = menu.get_option_by_name('start_year').get_value() self.end_year = menu.get_option_by_name('end_year').get_value() @@ -333,7 +331,7 @@ class WebCalReport(Report): month_dict[day] = day_list self.calendar[month] = month_dict - def get_holidays(self, country="United States"): + def get_holidays(self, year, country="United States"): """ Looks in multiple places for holidays.xml file. the holidays file will be used first if it exists in user's plugins, otherwise, @@ -349,9 +347,9 @@ class WebCalReport(Report): elif os.path.exists(fname2): holiday_full_path = fname2 if holiday_full_path != "": - self.process_holiday_file(holiday_full_path, country) + self.process_holiday_file(year, holiday_full_path, country) - def process_holiday_file(self, filename, country): + def process_holiday_file(self, year, filename, country): """ This will process the holidays file for the selected country. @@ -367,20 +365,20 @@ class WebCalReport(Report): parser = Xml2Obj() element = parser.Parse(filename) holidays_calendar = Holidays(element, country) - date = datetime.date(self.year, 1, 1) - while date.year == self.year: + date = datetime.date(year, 1, 1) + while date.year == year: event_date = time.strptime('%d/%d/%d' % (date.year, date.month, date.day), '%Y/%m/%d') holidays = holidays_calendar.check_date(date) for text in holidays: if text == "Easter": # TODO. Verify if this needs translation, and how - easter = _easter(self.year) + easter = _easter(year) self.add_holiday_item(_("Easter"), easter[0], easter[1], easter[2]) elif text == "Daylight Saving begins": # TODO. Verify if this needs translation, and how # TODO. There is more than USA and Europe. if Utils.xml_lang() == "en-US": # DST for United States of America - dst_start, dst_stop = _get_dst_start_stop(self.year) + dst_start, dst_stop = _get_dst_start_stop(year) else: # DST for Europe - dst_start, dst_stop = _get_dst_start_stop(self.year, "eu") + dst_start, dst_stop = _get_dst_start_stop(year, "eu") self.add_holiday_item(_("Daylight Saving begins"), \ dst_start[0], dst_start[1], dst_start[2]) self.add_holiday_item(_("Daylight Saving ends"), \ @@ -405,7 +403,7 @@ class WebCalReport(Report): def copy_calendar_files(self): """ - Copies all the necessary files... + Copies all the necessary files """ # Copy the _CALENDARSCREEN stylesheet if self.css != "": @@ -429,7 +427,7 @@ class WebCalReport(Report): from_path = os.path.join(const.IMAGE_DIR, f) self.copy_file(from_path, f, "images") - def display_month_navs(self, of, nr_up, currentsection, use_home=False): + def display_month_navs(self, of, nr_up, year, currentsection, use_home=False): """ Will create and display the navigation menu bar @@ -463,7 +461,7 @@ class WebCalReport(Report): if cond: subdirs = ['..'] * nr_up - subdirs.append(str(self.year)) + subdirs.append(str(year)) # Note. We use '/' here because it is a URL, not a OS dependent pathname if type(url_fname) == int: @@ -497,7 +495,7 @@ class WebCalReport(Report): of.write('\t