aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2013-02-03 00:14:46 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2013-02-03 00:14:46 +0100
commit979d73efcf471f899c44676f9f624ff8a2d3ba00 (patch)
tree1457b32f4d5665a281ca8ddfef5632ddf7dc9468 /source
parentadded empty line (diff)
downloadnewspipe-979d73efcf471f899c44676f9f624ff8a2d3ba00.tar.gz
newspipe-979d73efcf471f899c44676f9f624ff8a2d3ba00.tar.bz2
newspipe-979d73efcf471f899c44676f9f624ff8a2d3ba00.zip
Improvement: dict.setdefault used in order to set a default value when a key does not exist
Diffstat (limited to 'source')
-rwxr-xr-xsource/pyAggr3g470r.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py
index b3392151..590d242b 100755
--- a/source/pyAggr3g470r.py
+++ b/source/pyAggr3g470r.py
@@ -466,10 +466,8 @@ 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"]))
- if language not in result.keys():
- result[language] = {}
- if feed["feed_id"] not in result[language].keys():
- result[language][feed["feed_id"]] = []
+ result.setdefault(language, {})
+ result[language].setdefault(feed["feed_id"], [])
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