From d461c157afb574ee4b3ef7cdac349bfa6798c7e8 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Mon, 26 Sep 2016 00:34:14 +0000 Subject: [PATCH] Only force first letter of fullname to be upper This change enforce the first and last component of a fullname to start with an uppercase letter. This is to keep user's custom capitalisation such as: * middle name should be lower-case * keep in-middle uppercase such as "McGinnis" Change-Id: Ifdad9f05c0d74d18396e9b06bd57c1c0f391be8d --- doc/source/ocata_ptl_candidates.rst | 4 ++-- doc/source/ocata_ptl_results.rst | 2 +- openstack_election/utils.py | 10 ++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/source/ocata_ptl_candidates.rst b/doc/source/ocata_ptl_candidates.rst index 04ea4a4d..826a9c7f 100644 --- a/doc/source/ocata_ptl_candidates.rst +++ b/doc/source/ocata_ptl_candidates.rst @@ -13,7 +13,7 @@ Ocata PTL Candidates * Cinder - * `Sean Mcginnis (smcginnis) `_ + * `Sean McGinnis (smcginnis) `_ * Cloudkitty @@ -83,7 +83,7 @@ Ocata PTL Candidates * Keystone - * `Samuel De Medeiros Queiroz (samueldmq) `_ + * `Samuel de Medeiros Queiroz (samueldmq) `_ * `Steve Martinelli (stevemar) `_ * Kolla diff --git a/doc/source/ocata_ptl_results.rst b/doc/source/ocata_ptl_results.rst index 1106dd0d..f8816c5b 100644 --- a/doc/source/ocata_ptl_results.rst +++ b/doc/source/ocata_ptl_results.rst @@ -15,7 +15,7 @@ Ocata PTL * Cinder - * `Sean Mcginnis (smcginnis) `_ + * `Sean McGinnis (smcginnis) `_ * Cloudkitty diff --git a/openstack_election/utils.py b/openstack_election/utils.py index d7066676..93b69287 100644 --- a/openstack_election/utils.py +++ b/openstack_election/utils.py @@ -102,8 +102,14 @@ def get_fullname(filepath): # Strip double space and trailing spaces fullname = re.sub(r" ", " ", fullname).strip() - # Return capitalized name - return u" ".join(map(unicode.capitalize, fullname.split())) + # Make sure first letter of first and last component are upper-case + s = fullname.split() + fullname = ( + [s[0][0].upper() + s[0][1:]] + + s[1:-1] + + [s[-1][0].upper() + s[-1][1:]] + ) + return u" ".join(fullname) def get_reviews(query):