Added some guards against bad data in name_parts().
- Legacy-Id: 11285
This commit is contained in:
parent
9e382bb711
commit
ab20d0002d
|
@ -3,7 +3,10 @@ import re
|
|||
def name_parts(name):
|
||||
prefix, first, middle, last, suffix = "", "", "", "", ""
|
||||
|
||||
# if we got a name on the form "Hello There (Foo Bar)", get rid of
|
||||
if not name.strip():
|
||||
return prefix, first, middle, last, suffix
|
||||
|
||||
# if we got a name on the form "Some Name (Foo Bar)", get rid of
|
||||
# the paranthesized part
|
||||
name_with_paren_match = re.search("^([^(]+)\s*\(.*\)$", name)
|
||||
if name_with_paren_match:
|
||||
|
@ -13,7 +16,7 @@ def name_parts(name):
|
|||
if len(parts) > 2 and parts[0] in ["M", "M.", "Sri", ] and "." not in parts[1]:
|
||||
prefix = parts[0];
|
||||
parts = parts[1:]
|
||||
if parts[0] in ["Mr", "Mr.", "Mrs", "Mrs.", "Ms", "Ms.", "Miss", "Dr", "Dr.", "Doctor", "Prof", "Prof.", "Professor", "Sir", "Lady", "Dame", ]:
|
||||
if len(parts) > 1 and parts[0] in ["Mr", "Mr.", "Mrs", "Mrs.", "Ms", "Ms.", "Miss", "Dr", "Dr.", "Doctor", "Prof", "Prof.", "Professor", "Sir", "Lady", "Dame", ]:
|
||||
prefix = parts[0];
|
||||
parts = parts[1:]
|
||||
if len(parts) > 2:
|
||||
|
|
Loading…
Reference in a new issue