[Python-modules-commits] [python-nameparser] 01/03: New upstream version 0.5.2
Edward Betts
edward at moszumanska.debian.org
Fri Apr 21 09:32:37 UTC 2017
This is an automated email from the git hooks/post-receive script.
edward pushed a commit to branch master
in repository python-nameparser.
commit 1dd1e39df9e8952da7bbfdc94f88671113f3b94b
Author: Edward Betts <edward at 4angle.com>
Date: Mon Apr 17 18:03:09 2017 +0100
New upstream version 0.5.2
---
PKG-INFO | 2 +-
nameparser.egg-info/PKG-INFO | 2 +-
nameparser/__init__.py | 2 +-
nameparser/config/titles.py | 210 +++++++++++++++++++++++++++++++++++++++++++
nameparser/parser.py | 136 +++++++++++++++++-----------
tests.py | 16 +++-
6 files changed, 311 insertions(+), 57 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index 6b0218e..5ae6db2 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: nameparser
-Version: 0.5.1
+Version: 0.5.2
Summary: A simple Python module for parsing human names into their individual components.
Home-page: https://github.com/derek73/python-nameparser
Author: Derek Gulbranson
diff --git a/nameparser.egg-info/PKG-INFO b/nameparser.egg-info/PKG-INFO
index 6b0218e..5ae6db2 100644
--- a/nameparser.egg-info/PKG-INFO
+++ b/nameparser.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: nameparser
-Version: 0.5.1
+Version: 0.5.2
Summary: A simple Python module for parsing human names into their individual components.
Home-page: https://github.com/derek73/python-nameparser
Author: Derek Gulbranson
diff --git a/nameparser/__init__.py b/nameparser/__init__.py
index 71c4f7a..7661fab 100644
--- a/nameparser/__init__.py
+++ b/nameparser/__init__.py
@@ -1,4 +1,4 @@
-VERSION = (0, 5, 1)
+VERSION = (0, 5, 2)
__version__ = '.'.join(map(str, VERSION))
__author__ = "Derek Gulbranson"
__author_email__ = 'derek73 at gmail.com'
diff --git a/nameparser/config/titles.py b/nameparser/config/titles.py
index 28c6d01..0f37a19 100644
--- a/nameparser/config/titles.py
+++ b/nameparser/config/titles.py
@@ -43,22 +43,38 @@ TITLES = FIRST_NAME_TITLES | set([
"marquis",
"marquise",
"queen's",
+ '10th',
'1lt',
'1sgt',
+ '1st',
'1stlt',
'1stsgt',
'2lt',
+ '2nd',
'2ndlt',
+ '3rd',
+ '4th',
+ '5th',
+ '6th',
+ '7th',
+ '8th',
+ '9th',
'a1c',
'ab',
'abbess',
'abbot',
+ 'abolitionist',
'academic',
'acolyte',
+ 'activist',
+ 'actor ',
+ 'actress',
'adept',
'adjutant',
'adm',
'admiral',
+ 'advertising',
+ 'adviser',
'advocate',
'air',
'akhoond',
@@ -67,6 +83,9 @@ TITLES = FIRST_NAME_TITLES | set([
'ambassador',
'amn',
'analytics',
+ 'anarchist',
+ 'animator',
+ 'anthropologist',
'appellate',
'apprentice',
'arbitrator',
@@ -75,70 +94,123 @@ TITLES = FIRST_NAME_TITLES | set([
'archdruid',
'archduchess',
'archduke',
+ 'archeologist',
+ 'architect',
'arhat',
+ 'army',
+ 'arranger',
'assistant',
'assoc',
'associate',
'asst',
+ 'astronomer',
'attache',
'attorney',
+ 'author',
+ 'award-winning',
'ayatollah',
'baba',
'bailiff',
+ 'ballet',
+ 'bandleader',
+ 'banker',
'banner',
'bard',
'baron',
'barrister',
+ 'baseball',
'bearer',
+ 'behavioral',
'bench',
'bg',
'bgen',
+ 'biblical',
+ 'bibliographer',
+ 'biochemist',
+ 'biographer',
+ 'biologist',
+ 'bishop',
'blessed',
+ 'blogger',
+ 'blues',
'bodhisattva',
+ 'bookseller',
+ 'botanist',
'brigadier',
'briggen',
+ 'british',
+ 'broadcaster',
'buddha',
'burgess',
+ 'burlesque',
'business',
+ 'businessman',
+ 'businesswoman',
'bwana',
'canon',
'capt',
'captain',
'cardinal',
+ 'cartographer',
+ 'cartoonist',
'catholicos',
'ccmsgt',
'cdr',
+ 'celebrity',
'ceo',
'cfo',
'chair',
'chairs',
'chancellor',
'chaplain',
+ 'chef',
+ 'chemist',
'chief',
'chieftain',
+ 'choreographer',
'civil',
+ 'classical',
+ 'clergyman',
'clerk',
'cmsaf',
'cmsgt',
'co-chair',
'co-chairs',
+ 'co-founder',
'coach',
'col',
+ 'collector',
'colonel',
+ 'comedian',
+ 'comedienne',
+ 'comic',
'commander',
'commander-in-chief',
'commodore',
+ 'composer',
+ 'compositeur',
'comptroller',
+ 'computer',
+ 'comtesse',
+ 'conductor',
+ 'consultant',
+ 'contessa',
'controller',
'corporal',
'corporate',
+ 'correspondent',
'councillor',
+ 'counselor',
+ 'count',
+ 'countess',
'courtier',
'cpl',
'cpo',
'cpt',
'credit',
'criminal',
+ 'criminologist',
+ 'critic',
'csm',
'curator',
'customs',
@@ -150,13 +222,20 @@ TITLES = FIRST_NAME_TITLES | set([
'cwo3',
'cwo4',
'cwo5',
+ 'cyclist',
+ 'dancer',
'deacon',
'delegate',
'deputy',
'designated',
+ 'designer',
+ 'detective',
+ 'developer',
+ 'diplomat',
'dir',
'director',
'discovery',
+ 'dissident',
'district',
'division',
'do',
@@ -166,32 +245,52 @@ TITLES = FIRST_NAME_TITLES | set([
'doyen',
'dpty',
'dr',
+ 'dramatist',
'druid',
+ 'drummer',
+ 'duchesse',
'duke',
'dutchess',
+ 'ecologist',
+ 'economist',
+ 'editor',
'edmi',
'edohen',
+ 'educator',
'effendi',
'ekegbian',
'elder',
'elerunwon',
+ 'eminence',
'emperor',
'empress',
+ 'engineer',
+ 'english',
'ens',
+ 'entertainer',
+ 'entrepreneur',
'envoy',
+ 'essayist',
+ 'evangelist',
+ 'excellency',
+ 'excellent',
'exec',
'executive',
+ 'expert',
'fadm',
'family',
'federal',
'field',
+ 'film',
'financial',
'first',
'flag',
'flying',
'foreign',
'forester',
+ 'founder',
'friar',
+ 'gaf',
'gen',
'general',
'generalissimo',
@@ -200,39 +299,64 @@ TITLES = FIRST_NAME_TITLES | set([
'goodman',
'goodwife',
'governor',
+ 'graf',
'grand',
'group',
+ 'guitarist',
'guru',
'gyani',
'gysgt',
'hajji',
'headman',
+ 'heir',
+ 'heiress',
'her',
'hereditary',
'high',
+ 'highness',
'his',
+ 'historian',
+ 'historicus',
+ 'historien',
+ 'holiness',
'hon', # sorry Hon Solo, but judges seem more common.
'honorable',
'honourable',
+ 'host',
+ 'illustrator',
'imam',
+ 'industrialist',
'information',
+ 'instructor',
'intelligence',
'intendant',
+ 'inventor',
+ 'investigator',
+ 'investor',
+ 'journalist',
'journeyman',
'jr',
'judge',
'judicial',
'junior',
+ 'jurist',
+ 'keyboardist',
'kingdom',
'knowledge',
'lady',
'lama',
'lamido',
'law',
+ 'lawyer',
'lcdr',
'lcpl',
'leader',
+ 'lecturer',
+ 'legal',
+ 'librarian',
'lieutenant',
+ 'linguist',
+ 'literary',
'lord',
'lt',
'ltc',
@@ -240,13 +364,16 @@ TITLES = FIRST_NAME_TITLES | set([
'ltg',
'ltgen',
'ltjg',
+ 'lyricist',
'madam',
'madame',
+ 'mademoiselle',
'mag',
'mag-judge',
'mag/judge',
'magistrate',
'magistrate-judge',
+ 'magnate',
'maharajah',
'maharani',
'mahdi',
@@ -255,7 +382,11 @@ TITLES = FIRST_NAME_TITLES | set([
'majgen',
'manager',
'marcher',
+ 'marchess',
'marketing',
+ 'marquis',
+ 'mathematician',
+ 'mathematics',
'matriarch',
'mayor',
'mcpo',
@@ -263,15 +394,26 @@ TITLES = FIRST_NAME_TITLES | set([
'mcpon',
'md',
'member',
+ 'memoirist',
+ 'merchant',
'metropolitan',
'mg',
'mgr',
'mgysgt',
+ 'military',
'minister',
'miss',
'misses',
+ 'missionary',
'mister',
+ 'mlle',
+ 'mme',
+ 'mobster',
+ 'model',
+ 'monk',
'monsignor',
+ 'most',
+ 'mountaineer',
'mpco-cg',
'mr',
'mrs',
@@ -282,23 +424,50 @@ TITLES = FIRST_NAME_TITLES | set([
'mullah',
'municipal',
'murshid',
+ 'musician',
+ 'musicologist',
+ 'mystery',
'nanny',
+ 'narrator',
'national',
+ 'naturalist',
+ 'navy',
+ 'neuroscientist',
+ 'novelist',
'nurse',
+ 'obstetritian',
'officer',
+ 'opera',
'operating',
+ 'ornithologist',
+ 'painter',
+ 'paleontologist',
'pastor',
'patriarch',
+ 'pediatrician',
+ 'personality',
'petty',
'pfc',
'pharaoh',
+ 'phd',
+ 'philantropist',
+ 'philosopher',
+ 'photographer',
+ 'physician',
+ 'physicist',
+ 'pianist',
'pilot',
+ 'pioneer',
'pir',
+ 'player',
+ 'playwright',
'po1',
'po2',
'po3',
+ 'poet',
'police',
'political',
+ 'politician',
'prefect',
'prelate',
'premier',
@@ -314,16 +483,24 @@ TITLES = FIRST_NAME_TITLES | set([
'prince',
'princess',
'principal',
+ 'printer',
+ 'printmaker',
'prior',
'private',
'pro',
+ 'producer',
'prof',
+ 'professor',
'provost',
'pslc',
+ 'psychiatrist',
+ 'psychologist',
+ 'publisher',
'pursuivant',
'pv2',
'pvt',
'rabbi',
+ 'radio',
'radm',
'rangatira',
'ranger',
@@ -333,18 +510,27 @@ TITLES = FIRST_NAME_TITLES | set([
'registrar',
'rep',
'representative',
+ 'researcher',
'resident',
'rev',
'revenue',
'reverend',
'right',
'risk',
+ 'rock',
'royal',
'rt',
'sa',
+ 'sailor',
'saint',
+ 'sainte',
'saoshyant',
+ 'satirist',
+ 'scholar',
+ 'schoolmaster',
+ 'scientist',
'scpo',
+ 'screenwriter',
'se',
'secretary',
'security',
@@ -363,10 +549,18 @@ TITLES = FIRST_NAME_TITLES | set([
'sheikh',
'sheriff',
'siddha',
+ 'singer',
+ 'singer-songwriter',
'sma',
'smsgt',
'sn',
+ 'soccer',
+ 'social',
+ 'sociologist',
+ 'software',
+ 'soldier',
'solicitor',
+ 'soprano',
'spc',
'speaker',
'special',
@@ -380,17 +574,29 @@ TITLES = FIRST_NAME_TITLES | set([
'strategy',
'subaltern',
'subedar',
+ 'suffragist',
'sultan',
'sultana',
'superior',
'supreme',
'surgeon',
+ 'swami',
'swordbearer',
'sysselmann',
'tax',
+ 'teacher',
'technical',
+ 'technologist',
+ 'television ',
+ 'tenor',
+ 'theater',
+ 'theatre',
+ 'theologian',
+ 'theorist',
'timi',
'tirthankar',
+ 'translator',
+ 'travel',
'treasurer',
'tsar',
'tsarina',
@@ -407,6 +613,8 @@ TITLES = FIRST_NAME_TITLES | set([
'vice',
'viscount',
'vizier',
+ 'vocalist',
+ 'voice',
'warden',
'warrant',
'wing',
@@ -417,4 +625,6 @@ TITLES = FIRST_NAME_TITLES | set([
'wo4',
'wo5',
'woodman',
+ 'writer',
+ 'zoologist',
])
diff --git a/nameparser/parser.py b/nameparser/parser.py
index d697a69..55f574a 100644
--- a/nameparser/parser.py
+++ b/nameparser/parser.py
@@ -30,9 +30,9 @@ class HumanName(object):
"""
Parse a person's name into individual components.
- Instantiation assigns to ``full_name``, and assignment to :py:attr:`full_name`
- triggers :py:func:`parse_full_name`. After parsing the name, these instance
- attributes are available.
+ Instantiation assigns to ``full_name``, and assignment to
+ :py:attr:`full_name` triggers :py:func:`parse_full_name`. After parsing the
+ name, these instance attributes are available.
**HumanName Instance Attributes**
@@ -51,14 +51,12 @@ class HumanName(object):
:param str string_format: python string formatting
"""
- has_own_config = False
- """True if this instance is not using the shared module-level configuration. Read only."""
-
C = CONSTANTS
"""
- A reference to the configuration for this instance, which may or may not be a
- reference to the shared, module-wide instance at :py:mod:`~nameparser.config.CONSTANTS`.
- See `Customizing the Parser <customize.html>`_.
+ A reference to the configuration for this instance, which may or may not be
+ a reference to the shared, module-wide instance at
+ :py:mod:`~nameparser.config.CONSTANTS`. See `Customizing the Parser
+ <customize.html>`_.
"""
original = ''
@@ -183,6 +181,10 @@ class HumanName(object):
@property
def has_own_config(self):
+ """
+ True if this instance is not using the shared module-level
+ configuration.
+ """
return self.C is not CONSTANTS
### attributes
@@ -191,7 +193,8 @@ class HumanName(object):
def title(self):
"""
The person's titles. Any string of consecutive pieces in
- :py:mod:`~nameparser.config.titles` or :py:mod:`~nameparser.config.conjunctions`
+ :py:mod:`~nameparser.config.titles` or
+ :py:mod:`~nameparser.config.conjunctions`
at the beginning of :py:attr:`full_name`.
"""
return " ".join(self.title_list) or self.C.empty_attribute_default
@@ -207,8 +210,8 @@ class HumanName(object):
@property
def middle(self):
"""
- The person's middle names. All name pieces after the first name and before
- the last name parsed from :py:attr:`full_name`.
+ The person's middle names. All name pieces after the first name and
+ before the last name parsed from :py:attr:`full_name`.
"""
return " ".join(self.middle_list) or self.C.empty_attribute_default
@@ -225,8 +228,9 @@ class HumanName(object):
"""
The persons's suffixes. Pieces at the end of the name that are found in
:py:mod:`~nameparser.config.suffixes`, or pieces that are at the end
- of comma separated formats, e.g. "Lastname, Title Firstname Middle[,] Suffix
- [, Suffix]" parsed from :py:attr:`full_name`.
+ of comma separated formats, e.g.
+ "Lastname, Title Firstname Middle[,] Suffix [, Suffix]" parsed
+ from :py:attr:`full_name`.
"""
return ", ".join(self.suffix_list) or self.C.empty_attribute_default
@@ -248,8 +252,9 @@ class HumanName(object):
elif value is None:
val = []
else:
- raise TypeError("Can only assign strings, lists or None to name attributes. "
- "Got {0}".format(type(value)))
+ raise TypeError(
+ "Can only assign strings, lists or None to name attributes."
+ " Got {0}".format(type(value)))
setattr(self, attr+"_list", self.parse_pieces(val))
@title.setter
@@ -287,7 +292,10 @@ class HumanName(object):
return piece.lower() in self.C.conjunctions and not self.is_an_initial(piece)
def is_prefix(self, piece):
- """Lowercase and no periods version of piece is in the `~nameparser.config.titles.PREFIXES` set."""
+ """
+ Lowercase and no periods version of piece is in the
+ `~nameparser.config.titles.PREFIXES` set.
+ """
return lc(piece) in self.C.prefixes
def is_roman_numeral(self, value):
@@ -318,7 +326,9 @@ class HumanName(object):
return True
def is_rootname(self, piece):
- '''Is not a known title, suffix or prefix. Just first, middle, last names.'''
+ """
+ Is not a known title, suffix or prefix. Just first, middle, last names.
+ """
return lc(piece) not in self.C.suffixes_prefixes_titles \
and not self.is_an_initial(piece)
@@ -353,10 +363,12 @@ class HumanName(object):
def pre_process(self):
"""
- This method happens at the beginning of the :py:func:`parse_full_name` before
- any other processing of the string aside from unicode normalization, so
- it's a good place to do any custom handling in a subclass.
- Runs :py:func:`parse_nicknames`.
+
+ This method happens at the beginning of the :py:func:`parse_full_name`
+ before any other processing of the string aside from unicode
+ normalization, so it's a good place to do any custom handling in a
+ subclass. Runs :py:func:`parse_nicknames`.
+
"""
self.parse_nicknames()
@@ -394,11 +406,14 @@ class HumanName(object):
def parse_full_name(self):
"""
- The main parse method for the parser. This method is run upon assignment to the
- :py:attr:`full_name` attribute or instantiation.
+
+ The main parse method for the parser. This method is run upon
+ assignment to the :py:attr:`full_name` attribute or instantiation.
- Basic flow is to hand off to :py:func:`pre_process` to handle nicknames. It
- then splits on commas and chooses a code path depending on the number of commas.
+ Basic flow is to hand off to :py:func:`pre_process` to handle
+ nicknames. It then splits on commas and chooses a code path depending
+ on the number of commas.
+
:py:func:`parse_pieces` then splits those parts on spaces and
:py:func:`join_on_conjunctions` joins any pieces next to conjunctions.
"""
@@ -436,7 +451,9 @@ class HumanName(object):
nxt = None
# title must have a next piece, unless it's just a title
- if self.is_title(piece) and (nxt or p_len == 1) and not self.first:
+ if self.is_title(piece) \
+ and (nxt or p_len == 1) \
+ and not self.first:
self.title_list.append(piece)
continue
if not self.first:
@@ -444,8 +461,8 @@ class HumanName(object):
continue
if self.are_suffixes(pieces[i+1:]) or \
(
- # if the next piece is the last piece and a roman numeral
- # but this piece is not an initial
+ # if the next piece is the last piece and a roman
+ # numeral but this piece is not an initial
self.is_roman_numeral(nxt) and i == p_len - 2
and not self.is_an_initial(piece)
):
@@ -458,13 +475,16 @@ class HumanName(object):
self.middle_list.append(piece)
else:
- # if all the end parts are suffixes and there is more than one piece in
- # the first part. (Suffixes will never appear after last names only, and
- # allows potential first names to be in suffixes, e.g. "Johnson, Bart"
- if self.are_suffixes(parts[1].split(' ')) and len(parts[0].split(' ')) > 1:
+ # if all the end parts are suffixes and there is more than one piece
+ # in the first part. (Suffixes will never appear after last names
+ # only, and allows potential first names to be in suffixes, e.g.
+ # "Johnson, Bart"
+ if self.are_suffixes(parts[1].split(' ')) \
+ and len(parts[0].split(' ')) > 1:
- # suffix comma: title first middle last [suffix], suffix [suffix] [, suffix]
- # parts[0], parts[1:...]
+ # suffix comma:
+ # title first middle last [suffix], suffix [suffix] [, suffix]
+ # parts[0], parts[1:...]
self.suffix_list += parts[1:]
@@ -476,7 +496,9 @@ class HumanName(object):
except IndexError:
nxt = None
- if self.is_title(piece) and (nxt or len(pieces) == 1) and not self.first:
+ if self.is_title(piece) \
+ and (nxt or len(pieces) == 1) \
+ and not self.first:
self.title_list.append(piece)
continue
if not self.first:
@@ -492,8 +514,9 @@ class HumanName(object):
self.middle_list.append(piece)
else:
- # lastname comma: last [suffix], title first middles[,] suffix [,suffix]
- # parts[0], parts[1], parts[2:...]
+ # lastname comma:
+ # last [suffix], title first middles[,] suffix [,suffix]
+ # parts[0], parts[1], parts[2:...]
pieces = self.parse_pieces(parts[1].split(' '), 1)
log.debug("pieces: {0}".format(u(pieces)))
@@ -501,7 +524,8 @@ class HumanName(object):
# lastname part may have suffixes in it
lastname_pieces = self.parse_pieces(parts[0].split(' '), 1)
for piece in lastname_pieces:
- # the first one is always a last name, even if it look like a suffix
+ # the first one is always a last name, even if it look like
+ # a suffix
if self.is_suffix(piece) and len(self.last_list) > 0:
self.suffix_list.append(piece)
else:
@@ -513,7 +537,9 @@ class HumanName(object):
except IndexError:
nxt = None
- if self.is_title(piece) and (nxt or len(pieces) == 1) and not self.first:
+ if self.is_title(piece) \
+ and (nxt or len(pieces) == 1) \
+ and not self.first:
self.title_list.append(piece)
continue
if not self.first:
@@ -547,7 +573,8 @@ class HumanName(object):
:param int additional_parts_count:
if the comma format contains other parts, we need to know
- how many there are to decide if things should be considered a conjunction.
+ how many there are to decide if things should be considered a
+ conjunction.
:return: pieces split on spaces and joined on conjunctions
:rtype: list
"""
@@ -555,15 +582,18 @@ class HumanName(object):
output = []
for part in parts:
if not isinstance(part, text_types):
- raise TypeError("Name parts must be strings. Got {0}".format(type(part)))
+ raise TypeError("Name parts must be strings. "
+ "Got {0}".format(type(part)))
output += [x.strip(' ,') for x in part.split(' ')]
- # If part contains periods, check if it's multiple titles or suffixes together without spaces
- # if so, add the new part with periods to the constants so they get parsed correctly later
+ # If part contains periods, check if it's multiple titles or suffixes
+ # together without spaces if so, add the new part with periods to the
+ # constants so they get parsed correctly later
for part in output:
# if this part has a period not at the beginning or end
if self.C.regexes.period_not_at_end.match(part):
- # split on periods, any of the split pieces titles or suffixes? ("Lt.Gov.")
+ # split on periods, any of the split pieces titles or suffixes?
+ # ("Lt.Gov.")
period_chunks = part.split(".")
titles = list(filter(self.is_title, period_chunks))
suffixes = list(filter(self.is_suffix, period_chunks))
@@ -595,7 +625,8 @@ class HumanName(object):
:param list pieces: name pieces strings after split on spaces
:param int additional_parts_count:
- :return: new list with piece next to conjunctions merged into one piece with spaces in it.
+ :return: new list with piece next to conjunctions merged into one piece
+ with spaces in it.
:rtype: list
"""
@@ -605,12 +636,13 @@ class HumanName(object):
return pieces
rootname_pieces = [p for p in pieces if self.is_rootname(p)]
- total_length= len(rootname_pieces) + additional_parts_count
+ total_length = len(rootname_pieces) + additional_parts_count
# find all the conjunctions, join any conjunctions that are next to each
# other, then join those newly joined conjunctions and any single
# conjunctions to the piece before and after it
- conj_index = [i for i, piece in enumerate(pieces) if self.is_conjunction(piece)]
+ conj_index = [i for i, piece in enumerate(pieces)
+ if self.is_conjunction(piece)]
contiguous_conj_i = []
for i, val in enumerate(conj_index):
@@ -674,7 +706,7 @@ class HumanName(object):
pieces.pop(i)
except IndexError:
rm_count = 1
- pass
+
# subtract the number of removed pieces from the index
# of all the remaining conjunctions
for j,val in enumerate(conj_index):
@@ -724,9 +756,9 @@ class HumanName(object):
def capitalize(self, force=False):
"""
- The HumanName class can try to guess the correct capitalization
- of name entered in all upper or lower case. By default, it will not adjust
- the case of names entered in mixed case. To run capitalization on all names
+ The HumanName class can try to guess the correct capitalization of name
+ entered in all upper or lower case. By default, it will not adjust the
+ case of names entered in mixed case. To run capitalization on all names
pass the parameter `force=True`.
:param bool force: force capitalization of strings that include mixed case
diff --git a/tests.py b/tests.py
index 32e0b74..4137e74 100644
--- a/tests.py
+++ b/tests.py
@@ -1231,6 +1231,18 @@ class HumanNameConjunctionTestCase(HumanNameTestBase):
self.m(hn.first, "Yin", hn)
self.m(hn.middle, "a", hn)
self.m(hn.last, "Le", hn)
+
+ def test_conjunction_in_an_address_with_a_title(self):
+ hn = HumanName("His Excellency Lord Duncan")
+ self.m(hn.title, "His Excellency Lord", hn)
+ self.m(hn.last, "Duncan", hn)
+
+ @unittest.expectedFailure
+ def test_conjunction_in_an_address_with_a_first_name_title(self):
+ hn = HumanName("Her Majesty Queen Elizabeth")
+ self.m(hn.title, "Her Majesty Queen", hn)
+ # if you want to be technical, Queen is in FIRST_NAME_TITLES
+ self.m(hn.first, "Elizabeth", hn)
class ConstantsCustomization(HumanNameTestBase):
@@ -2148,8 +2160,8 @@ if __name__ == '__main__':
name = sys.argv[1]
hn = HumanName(name, encoding=sys.stdout.encoding)
print((repr(hn)))
- hn.capitalize()
- print((repr(hn)))
+ # hn.capitalize()
+ # print((repr(hn)))
else:
print("-"*80)
print("Running tests")
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-nameparser.git
More information about the Python-modules-commits
mailing list