From 2c1ff889fa4a8aefd9728d6a8e5020c96f621492 Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Wed, 10 Dec 2014 00:57:17 +0100 Subject: [PATCH] Fix scope in HTML output. --- dosagelib/events.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/dosagelib/events.py b/dosagelib/events.py index 4ea2b6728..888b2e81d 100644 --- a/dosagelib/events.py +++ b/dosagelib/events.py @@ -144,6 +144,11 @@ class HtmlEventHandler(EventHandler): fn = os.path.abspath(fn) return fn + def addNavLinks(self): + if self.yesterdayUrl: + self.html.write(u'Previous Day | ' % self.yesterdayUrl) + self.html.write(u'Next Day\n' % self.tomorrowUrl) + def start(self): """Start HTML output.""" today = time.time() @@ -167,10 +172,10 @@ class HtmlEventHandler(EventHandler): try: fn_yesterday = self.fnFromDate(yesterday) fn_yesterday = util.getExistingFile(fn_yesterday) - yesterdayUrl = self.getUrlFromFilename(fn_yesterday) + self.yesterdayUrl = self.getUrlFromFilename(fn_yesterday) except ValueError: - yesterdayUrl = None - tomorrowUrl = self.getUrlFromFilename(self.fnFromDate(tomorrow)) + self.yesterdayUrl = None + self.tomorrowUrl = self.getUrlFromFilename(self.fnFromDate(tomorrow)) self.html = codecs.open(fn, 'w', self.encoding) self.html.write(u''' @@ -182,9 +187,8 @@ class HtmlEventHandler(EventHandler): ''' % (self.encoding, configuration.App, time.strftime('%Y/%m/%d', today))) - if yesterdayUrl: - self.html.write(u'Previous Day | ' % yesterdayUrl) - self.html.write(u'Next Day -Previous Day | Next Day - -''') % (yesterdayUrl, tomorrowUrl) + self.html.write(u'\n') + self.addNavLinks() self.html.close()