From e9ac46e16e7c6bffeca8652193203493bb641c58 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Mon, 6 Jun 2011 22:14:29 +0200 Subject: Bugfix: ZeroDivisionError when calculating the 'Daily post average' value if there is only one article in the feed. --- pyAggr3g470r.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 824b6d2d..9ce4bc80 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -569,9 +569,10 @@ class Root: delta = last_article - first_article delta_today = datetime.datetime.fromordinal(datetime.date.today().toordinal()) - last_article html += "

The last article was posted " + str(abs(delta_today.days)) + " day(s) ago.

" - html += """

Daily average: %s,""" % (str(round(float(feed.nb_articles)/abs(delta.days), 2)),) - html += """ between the %s and the %s.

\n""" % \ - (feed.articles.values()[-1].article_date[:10], feed.articles.values()[0].article_date[:10]) + if delta.days > 0: + html += """

Daily average: %s,""" % (str(round(float(feed.nb_articles)/abs(delta.days), 2)),) + html += """ between the %s and the %s.

\n""" % \ + (feed.articles.values()[-1].article_date[:10], feed.articles.values()[0].article_date[:10]) html += "

Recent articles

" for article in feed.articles.values()[:10]: -- cgit