aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMart Raudsepp <leio@gentoo.org>2017-01-22 14:07:48 +0200
committerMart Raudsepp <leio@gentoo.org>2017-01-22 14:07:48 +0200
commited727d30df105b6852f5118baa5a454965b6f4ba (patch)
treecd61e5c4225106f165e3ed0a0d6b36559a27ebd6
parentsync: use ORM magics in sync_packages (diff)
downloadgrumpy-ed727d30df105b6852f5118baa5a454965b6f4ba.tar.gz
grumpy-ed727d30df105b6852f5118baa5a454965b6f4ba.tar.bz2
grumpy-ed727d30df105b6852f5118baa5a454965b6f4ba.zip
sync: Use dict comprehension in sync_categories as well
-rw-r--r--backend/lib/sync.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/backend/lib/sync.py b/backend/lib/sync.py
index dbb44c2..c837c23 100644
--- a/backend/lib/sync.py
+++ b/backend/lib/sync.py
@@ -117,10 +117,8 @@ def sync_categories():
data = http_session.get(url)
# TODO: Handle response error (if not data)
categories = data.json()
- existing_categories = {}
# TODO: Use UPSERT instead (on_conflict_do_update) if we can rely on postgresql:9.5
- for cat in Category.query.all():
- existing_categories[cat.name] = cat
+ existing_categories = {cat.name: cat for cat in Category.query.all()}
for category in categories:
if category['name'] in existing_categories:
existing_categories[category['name']].description = category['description']