From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 0CEC8139086 for ; Sun, 22 Jan 2017 12:36:16 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ACB46E0C78; Sun, 22 Jan 2017 12:36:14 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 754AAE0C77 for ; Sun, 22 Jan 2017 12:36:14 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 75BAD341649 for ; Sun, 22 Jan 2017 12:36:13 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D5F8F2C79 for ; Sun, 22 Jan 2017 12:36:11 +0000 (UTC) From: "Gilles Dartiguelongue" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Gilles Dartiguelongue" Message-ID: <1485088558.c71c75d3fbf28528c844f8280e0ef499dacb1819.eva@gentoo> Subject: [gentoo-commits] proj/grumpy:master commit in: backend/lib/ X-VCS-Repository: proj/grumpy X-VCS-Files: backend/lib/sync.py X-VCS-Directories: backend/lib/ X-VCS-Committer: eva X-VCS-Committer-Name: Gilles Dartiguelongue X-VCS-Revision: c71c75d3fbf28528c844f8280e0ef499dacb1819 X-VCS-Branch: master Date: Sun, 22 Jan 2017 12:36:11 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d3c75d5a-5c97-4869-a15f-7c78ec5f96c1 X-Archives-Hash: 9274299ae7857797b328d5a0ca7fbe9b commit: c71c75d3fbf28528c844f8280e0ef499dacb1819 Author: Gilles Dartiguelongue gentoo org> AuthorDate: Sun Jan 22 12:35:58 2017 +0000 Commit: Gilles Dartiguelongue gentoo org> CommitDate: Sun Jan 22 12:35:58 2017 +0000 URL: https://gitweb.gentoo.org/proj/grumpy.git/commit/?id=c71c75d3 sync: use dict facilities for key retrieval with a default backend/lib/sync.py | 39 +++++++++++++++++++-------------------- 1 file 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