aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2013-02-03 00:30:23 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2013-02-03 00:30:23 +0100
commit33ef607cecb94f325ceb31d4f4926053d926f89a (patch)
treecb368959a2004a8860f030c4a3c2f460abc5c28b /source
parentUpdated revision date. (diff)
downloadnewspipe-33ef607cecb94f325ceb31d4f4926053d926f89a.tar.gz
newspipe-33ef607cecb94f325ceb31d4f4926053d926f89a.tar.bz2
newspipe-33ef607cecb94f325ceb31d4f4926053d926f89a.zip
It's even better with defaultdict
Diffstat (limited to 'source')
-rwxr-xr-xsource/pyAggr3g470r.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py
index c0807bce..ac4c5998 100755
--- a/source/pyAggr3g470r.py
+++ b/source/pyAggr3g470r.py
@@ -44,6 +44,8 @@ import os
import re
import datetime
+from collections import defaultdict
+
import cherrypy
from mako.template import Template
from mako.lookup import TemplateLookup
@@ -466,8 +468,7 @@ class pyAggr3g470r(object):
for feed in feeds:
for article in self.mongo.get_articles(feed["feed_id"]):
language = guess_language_name(utils.clear_string(article["article_content"]))
- result.setdefault(language, {})
- result[language].setdefault(feed["feed_id"], [])
+ result.setdefault(language, defaultdict(list))
result[language][feed["feed_id"]].append(article)
tmpl = lookup.get_template("languages.html")
return tmpl.render(articles_sorted_by_languages=result, mongo=self.mongo)
bgstack15