rely on explicit aliases; do not modify organization names automatically
Change-Id: I4a78498a07377817266782b224fb86899ab984b1 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
9dbea7f7d4
commit
821cf339b6
@ -62,18 +62,7 @@ class Organizations:
|
|||||||
|
|
||||||
@functools.lru_cache(maxsize=1024)
|
@functools.lru_cache(maxsize=1024)
|
||||||
def __getitem__(self, name):
|
def __getitem__(self, name):
|
||||||
aliased = self._reverse.get(name.lower(), self)
|
return self._reverse.get(name.lower(), name)
|
||||||
if aliased is not self:
|
|
||||||
# We found an alias, use it.
|
|
||||||
return aliased
|
|
||||||
# Strip some common endings from the name to try to
|
|
||||||
# standardize on a shorter form.
|
|
||||||
for end in self._ENDINGS:
|
|
||||||
name = name.strip('"\'')
|
|
||||||
name = name.rstrip(' ,.')
|
|
||||||
if name.endswith(end):
|
|
||||||
name = name[:-1 * len(end)]
|
|
||||||
return name
|
|
||||||
|
|
||||||
@functools.lru_cache(maxsize=1024)
|
@functools.lru_cache(maxsize=1024)
|
||||||
def from_email(self, email):
|
def from_email(self, email):
|
||||||
|
@ -45,28 +45,6 @@ class TestOrganizations(base.TestCase):
|
|||||||
self.o['Green Hat Software'],
|
self.o['Green Hat Software'],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_no_alias_strip_ending(self):
|
|
||||||
self.assertEqual(
|
|
||||||
'Company',
|
|
||||||
self.o['Company, Inc.'],
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_no_alias_strip_multiple_endings(self):
|
|
||||||
self.assertEqual(
|
|
||||||
'Company',
|
|
||||||
self.o['Company Co., Ltd.'],
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_remove_quotes_and_endings(self):
|
|
||||||
self.assertEqual(
|
|
||||||
'Company',
|
|
||||||
self.o['"Company, Inc."'],
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
'Company',
|
|
||||||
self.o["'Company, Inc.'"],
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_from_email(self):
|
def test_from_email(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'PyMOTW',
|
'PyMOTW',
|
||||||
|
Loading…
Reference in New Issue
Block a user