Skip to content

Commit 761ed8a

Browse files
committed
Extended name_parts to consider military rank prefixes.
- Legacy-Id: 12816
1 parent 77f1a25 commit 761ed8a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

ietf/person/name.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ def name_parts(name):
1616
if len(parts) > 2 and parts[0] in ["M", "M.", "Sri", ] and "." not in parts[1]:
1717
prefix = parts[0];
1818
parts = parts[1:]
19-
if len(parts) > 1 and parts[0] in ["Mr", "Mr.", "Mrs", "Mrs.", "Ms", "Ms.", "Miss", "Dr", "Dr.", "Doctor", "Prof", "Prof.", "Professor", "Sir", "Lady", "Dame", ]:
20-
prefix = parts[0];
19+
prefix = []
20+
while len(parts) > 1 and parts[0] in ["Mr", "Mr.", "Mrs", "Mrs.", "Ms", "Ms.", "Miss", "Dr",
21+
"Dr.", "Doctor", "Prof", "Prof.", "Professor", "Sir", "Lady", "Dame",
22+
"Gen.", "Col.", "Maj.", "Capt.", "Lieut.", "Lt.", "Cmdr.", "Col.", ]:
23+
prefix.append(parts[0])
2124
parts = parts[1:]
25+
prefix = " ".join(prefix)
2226
if len(parts) > 2:
2327
if parts[-1] in ["Jr", "Jr.", "II", "2nd", "III", "3rd", "Ph.D."]:
2428
suffix = parts[-1]

0 commit comments

Comments
 (0)