public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mart Raudsepp" <leio@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/grumpy:master commit in: backend/lib/
Date: Wed,  7 Dec 2016 04:42:17 +0000 (UTC)	[thread overview]
Message-ID: <1481085706.5f3073d21e0748a9414fbd516c3e032d0456ab35.leio@gentoo> (raw)

commit:     5f3073d21e0748a9414fbd516c3e032d0456ab35
Author:     Mart Raudsepp <leio <AT> gentoo <DOT> org>
AuthorDate: Wed Dec  7 04:41:46 2016 +0000
Commit:     Mart Raudsepp <leio <AT> gentoo <DOT> org>
CommitDate: Wed Dec  7 04:41:46 2016 +0000
URL:        https://gitweb.gentoo.org/proj/grumpy.git/commit/?id=5f3073d2

sync: Always handle e-mails in lower case to not end up with duplicates

Suggested-by: Doug Freed <dwfreed <AT> mtu.edu>

 backend/lib/models.py |  1 +
 backend/lib/sync.py   | 24 ++++++++++++++----------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/backend/lib/models.py b/backend/lib/models.py
index ba20622..2eb9e8c 100644
--- a/backend/lib/models.py
+++ b/backend/lib/models.py
@@ -50,6 +50,7 @@ maintainer_project_membership_rel_table = db.Table('maintainer_project_membershi
 
 class Maintainer(db.Model):
     id = db.Column(db.Integer, primary_key=True)
+    # TODO: This has to be unique case insensitive. Currently we have to always force lower() to guarantee this and find the proper maintainer entry; later we might want to use some sort of NOCASE collate rules here to keep the capitalization as preferred per master data
     email = db.Column(db.Unicode(50), nullable=False, unique=True)
     is_project = db.Column(db.Boolean, nullable=False, server_default='f', default=False)
     name = db.Column(db.Unicode(128))

diff --git a/backend/lib/sync.py b/backend/lib/sync.py
index 7ba583d..744811b 100644
--- a/backend/lib/sync.py
+++ b/backend/lib/sync.py
@@ -28,7 +28,9 @@ def get_project_data():
         proj = {}
         for elem in proj_elem:
             tag = elem.tag.lower()
-            if tag in ['email', 'name', 'url', 'description']:
+            if tag in ['email']:
+                proj[tag] = elem.text.lower()
+            if tag in ['name', 'url', 'description']:
                 proj[tag] = elem.text
             elif tag == 'member':
                 member = {}
@@ -36,19 +38,20 @@ def get_project_data():
                     member['is_lead'] = True
                 for member_elem in elem:
                     member_tag = member_elem.tag.lower()
-                    if member_tag in ['email', 'name', 'role']:
+                    if member_tag in ['email']:
+                        member[member_tag] = member_elem.text.lower()
+                    if member_tag in ['name', 'role']:
                         member[member_tag] = member_elem.text
                 if 'email' in member:
                     if 'members' not in proj:
                         proj['members'] = []
                     proj['members'].append(member)
-                    pass
             elif tag == 'subproject':
                 if 'ref' in elem.attrib:
                     if 'subprojects' not in proj:
                         proj['subprojects'] = []
                     # subprojects will be a list of (subproject_email, inherit-members) tuples where inherit-members is True or False. TODO: Might change if sync code will want it differently
-                    proj['subprojects'].append((elem.attrib['ref'], True if ('inherit-members' in elem.attrib and elem.attrib['inherit-members'] == '1') else False))
+                    proj['subprojects'].append((elem.attrib['ref'].lower(), True if ('inherit-members' in elem.attrib and elem.attrib['inherit-members'] == '1') else False))
                 else:
                     print("Invalid <subproject> tag inside project %s - required 'ref' attribute missing" % proj['email'] if 'email' in proj else "<unknown>")
             else:
@@ -77,7 +80,7 @@ def sync_projects():
                 existing_maintainers[email].url = data['url']
         else:
             print ("Adding project %s" % email)
-            new_maintainer = Maintainer(email=data['email'], is_project=True, description=data['description'], name=data['name'], url=data['url'])
+            new_maintainer = Maintainer(email=email, is_project=True, description=data['description'], name=data['name'], url=data['url'])
             db.session.add(new_maintainer)
             existing_maintainers[email] = new_maintainer
         members = []
@@ -176,16 +179,17 @@ def sync_versions():
                 if 'email' not in maint:
                     print("WARNING: Package %s was told to have a maintainer without an e-mail identifier" % package.full_name)
                     continue
-                if maint['email'] in existing_maintainers: # FIXME: Some proxy-maintainers are using mixed case e-mail address, right now we'd be creating duplicates right now if the case is different across different packages
-                    maintainers.append(existing_maintainers[maint['email']])
+                email = maint['email'].lower()
+                if email in existing_maintainers:
+                    maintainers.append(existing_maintainers[email])
                 else:
                     is_project = False
                     if 'type' in maint and maint['type'] == 'project':
                         is_project = True
-                    print("Adding %s maintainer %s" % ("project" if is_project else "individual", maint['email']))
-                    new_maintainer = Maintainer(email=maint['email'], is_project=is_project, name=maint['name'] if 'name' in maint else None)
+                    print("Adding %s maintainer %s" % ("project" if is_project else "individual", email))
+                    new_maintainer = Maintainer(email=email, is_project=is_project, name=maint['name'] if 'name' in maint else None)
                     db.session.add(new_maintainer)
-                    existing_maintainers[maint['email']] = 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


             reply	other threads:[~2016-12-07  4:42 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-07  4:42 Mart Raudsepp [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-01-23  0:06 [gentoo-commits] proj/grumpy:master commit in: backend/lib/ Gilles Dartiguelongue
2017-01-22 17:46 Gilles Dartiguelongue
2017-01-22 17:13 Gilles Dartiguelongue
2017-01-22 12:36 Gilles Dartiguelongue
2017-01-22 12:36 Gilles Dartiguelongue
2017-01-22 12:36 Gilles Dartiguelongue
2017-01-22 12:24 Gilles Dartiguelongue
2017-01-22 12:24 Gilles Dartiguelongue
2017-01-22 12:24 Gilles Dartiguelongue
2017-01-22 12:08 Mart Raudsepp
2017-01-22 12:00 Gilles Dartiguelongue
2017-01-22 12:00 Gilles Dartiguelongue
2017-01-22 11:59 Mart Raudsepp
2017-01-22 11:04 Gilles Dartiguelongue
2017-01-22 11:04 Gilles Dartiguelongue
2016-12-07  7:10 Mart Raudsepp
2016-12-07  2:53 Mart Raudsepp
2016-12-07  2:40 Mart Raudsepp
2016-12-07  2:10 Mart Raudsepp
2016-12-07  1:58 Mart Raudsepp
2016-12-07  1:58 Mart Raudsepp
2016-12-07  0:34 Mart Raudsepp
2016-12-05 17:46 Mart Raudsepp
2016-12-04  8:04 Mart Raudsepp
2016-12-04  8:04 Mart Raudsepp
2016-12-04  7:44 Mart Raudsepp
2016-12-04  6:27 Mart Raudsepp
2016-12-04  6:27 Mart Raudsepp
2016-12-04  5:26 Mart Raudsepp
2016-12-04  5:26 Mart Raudsepp
2016-12-04  4:56 Mart Raudsepp
2016-11-11  1:22 Mart Raudsepp
2016-11-10 15:50 Mart Raudsepp
2016-09-24  7:02 Mart Raudsepp
2016-09-07 20:21 Mart Raudsepp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1481085706.5f3073d21e0748a9414fbd516c3e032d0456ab35.leio@gentoo \
    --to=leio@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox