aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Dartiguelongue <eva@gentoo.org>2017-01-22 13:35:58 +0100
committerGilles Dartiguelongue <eva@gentoo.org>2017-01-22 13:35:58 +0100
commitc71c75d3fbf28528c844f8280e0ef499dacb1819 (patch)
tree32da6c2e6edf150125d711c733ddf3eb2ac23887
parentsync: use dict facilities for key retrieval with a default (diff)
downloadgrumpy-c71c75d3fbf28528c844f8280e0ef499dacb1819.tar.gz
grumpy-c71c75d3fbf28528c844f8280e0ef499dacb1819.tar.bz2
grumpy-c71c75d3fbf28528c844f8280e0ef499dacb1819.zip
sync: use dict facilities for key retrieval with a default
-rw-r--r--backend/lib/sync.py39
1 files changed, 19 insertions, 20 deletions
diff --git a/backend/lib/sync.py b/backend/lib/sync.py
index 723c3af..02e1116 100644
--- a/backend/lib/sync.py
+++ b/backend/lib/sync.py
@@ -176,26 +176,25 @@ def sync_versions():
package.description = pkg['description']
maintainers = []
- if 'maintainers' in pkg:
- for maint in pkg['maintainers']:
- if 'email' not in maint or 'type' not in maint:
- raise ValueError(
- "Package %s maintainer %s entry not GLEP 67 valid" %
- (package.full_name, maint)
- )
-
- email = maint['email'].lower()
- if email in existing_maintainers:
- maintainers.append(existing_maintainers[email])
- else:
- is_project = False
- if maint['type'] == 'project':
- is_project = True
- print("Adding %s maintainer %s" % ("project" if is_project else "individual", email))
- new_maintainer = Maintainer(email=email, is_project=is_project, name=maint.get('name'))
- db.session.add(new_maintainer)
- existing_maintainers[email] = new_maintainer
- maintainers.append(new_maintainer)
+ for maint in pkg.get('maintainers', []):
+ if 'email' not in maint or 'type' not in maint:
+ raise ValueError(
+ "Package %s maintainer %s entry not GLEP 67 valid" %
+ (package.full_name, maint)
+ )
+
+ email = maint['email'].lower()
+ if email in existing_maintainers:
+ maintainers.append(existing_maintainers[email])
+ else:
+ is_project = False
+ if maint['type'] == 'project':
+ is_project = True
+ print("Adding %s maintainer %s" % ("project" if is_project else "individual", email))
+ new_maintainer = Maintainer(email=email, is_project=is_project, name=maint.get('name'))
+ db.session.add(new_maintainer)
+ existing_maintainers[email] = new_maintainer
+ maintainers.append(new_maintainer)
# Intentionally outside if 'maintainers' in pkg, because if there are no maintainers in JSON, it's falled to maintainer-needed and we need to clean out old maintainer entries
package.maintainers = maintainers # TODO: Retain order to know who is primary; retain description associated with the maintainership