aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2011-06-06 22:14:29 +0200
committercedricbonhomme <devnull@localhost>2011-06-06 22:14:29 +0200
commite9ac46e16e7c6bffeca8652193203493bb641c58 (patch)
treee85e75fec7cf0e1534655054d6b5ac803df5a889
parentImprovement. Daily post average. (diff)
downloadnewspipe-e9ac46e16e7c6bffeca8652193203493bb641c58.tar.gz
newspipe-e9ac46e16e7c6bffeca8652193203493bb641c58.tar.bz2
newspipe-e9ac46e16e7c6bffeca8652193203493bb641c58.zip
Bugfix: ZeroDivisionError when calculating the 'Daily post average' value if there is only one article in the feed.
-rwxr-xr-xpyAggr3g470r.py7
1 files 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 += "<p>The last article was posted " + str(abs(delta_today.days)) + " day(s) ago.</p>"
- html += """<p>Daily average: %s,""" % (str(round(float(feed.nb_articles)/abs(delta.days), 2)),)
- html += """ between the %s and the %s.</p>\n""" % \
- (feed.articles.values()[-1].article_date[:10], feed.articles.values()[0].article_date[:10])
+ if delta.days > 0:
+ html += """<p>Daily average: %s,""" % (str(round(float(feed.nb_articles)/abs(delta.days), 2)),)
+ html += """ between the %s and the %s.</p>\n""" % \
+ (feed.articles.values()[-1].article_date[:10], feed.articles.values()[0].article_date[:10])
html += "<br /><h1>Recent articles</h1>"
for article in feed.articles.values()[:10]:
bgstack15