diff --git a/src/plugins/WebCal.py b/src/plugins/WebCal.py index e2422442b..feb4838d4 100644 --- a/src/plugins/WebCal.py +++ b/src/plugins/WebCal.py @@ -216,7 +216,6 @@ class WebCalReport(Report): self.anniv = menu.get_option_by_name('anniversaries').get_value() self.title_text = menu.get_option_by_name('title').get_value() self.home_link = menu.get_option_by_name('home_link').get_value() - self.use_home = self.home_link self.month_notes = [menu.get_option_by_name('note_jan').get_value(), menu.get_option_by_name('note_feb').get_value(), @@ -266,14 +265,14 @@ class WebCalReport(Report): # code snippets for Easter and Daylight saving start/ stop # are borrowed from Calendar.py - def easter(self, year): + def easter(self): """ Computes the year/month/day of easter. Based on work by J.-M. Oudin (1940) and is reprinted in the "Explanatory Supplement to the Astronomical Almanac", ed. P. K. Seidelmann (1992). Note: Ash Wednesday is 46 days before Easter Sunday. """ - + year = self.year c = year / 100 n = year - 19 * (year / 19) k = (c - 17) / 25 @@ -288,12 +287,12 @@ class WebCalReport(Report): day = l + 28 - 31 * (month / 4) return (year, month, day) - def dst(self, year, area="us"): + def dst(self, area="us"): """ Return Daylight Saving Time start/stop in a given area ("us", "eu"). US calculation valid 1976-2099; EU 1996-2099 """ - + year = self.year if area == "us": if year > 2006: start = (year, 3, 14 - (math.floor(1 + year * 5 / 4) % 7)) # March @@ -342,7 +341,7 @@ class WebCalReport(Report): month_dict[day] = day_list self.calendar[month] = month_dict - def get_holidays(self, year, country = "United States"): + def get_holidays(self, country = "United States"): """ Looks in multiple places for holidays.xml files the holidays file will be used first if it exists in user's plugins, else the GRAMPS plugins will be checked. No more of having duel holidays files being read. @@ -350,20 +349,22 @@ class WebCalReport(Report): User directory is first choice if it exists, and does not use both holiday files any longer """ + year = self.year holiday_file = 'holidays.xml' holiday_full_path = "" fname1 = os.path.join(const.USER_PLUGINS, holiday_file) fname2 = os.path.join(const.PLUGINS_DIR, holiday_file) - if os.path.isfile(fname1): + if os.path.exists(fname1): holiday_full_path = fname1 - elif os.path.isfile(fname2): + elif os.path.exists(fname2): holiday_full_path = fname2 if holiday_full_path != "": - self.process_holiday_file(self.year, holiday_full_path, country) + self.process_holiday_file(holiday_full_path, country) - def process_holiday_file(self, year, filename, country): + def process_holiday_file(self, filename, country): """ This will process a holiday file """ + year = self.year parser = Xml2Obj() element = parser.Parse(filename) mycalendar = Holidays(element, country) @@ -372,13 +373,13 @@ class WebCalReport(Report): holidays = mycalendar.check_date( date ) for text in holidays: if text == "Easter": - date1 = self.easter(self.year) + date1 = self.easter() self.add_day_item(text, date1[0], date1[1], date1[2]) elif text == "Daylight Saving begins": if Utils.xml_lang() == "en-US": - date2 = self.dst(self.year, "us") + date2 = self.dst("us") else: - date2 = self.dst(self.year, "eu") + date2 = self.dst("eu") dst_start = date2[0] dst_stop = date2[1] self.add_day_item(text, dst_start[0], dst_start[1], dst_start[2]) @@ -453,11 +454,13 @@ class WebCalReport(Report): of.write('
%s
\n' % msg) # copyright license - if up: - fname = _subdirs(True, "images", "somerights20.gif") + if cal == "yg" or cal == "by": + to_urldir = os.path.join("yg", "images") + to_dir = os.path.join("yg", "images") + elif cal == "ip": + to_urldir = os.path.join("ip", "images") + to_dir = os.path.join("ip", "images") else: - fname = _subdirs(False, "images", "somerights20.gif") + to_urldir = os.path.join("wc", "images") + to_dir = os.path.join("wc", "images") if self.copy > 0 and self.copy < len(_CC): text = _CC[self.copy] + fname = os.path.join(to_urldir, "somerights20.gif") text = text % {'gif_fname' : fname} from_file = os.path.join(const.IMAGE_DIR, "somerights20.gif") - self.copy_file(from_file, "somerights20.gif", "images") + self.copy_file(from_file, "somerights20.gif", to_dir) else: text = "© %s %s" % (time.localtime()[0], author) of.write('%s
\n' % text) @@ -710,46 +688,6 @@ class WebCalReport(Report): of.write('