-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy path__main__.py
More file actions
31 lines (24 loc) · 788 Bytes
/
Copy path__main__.py
File metadata and controls
31 lines (24 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Command-line debug helper: parse a name and print the result.
Usage:
python -m nameparser "Dr. Juan Q. Xavier de la Vega III"
"""
import logging
import sys
from nameparser import HumanName
def main() -> None:
if len(sys.argv) <= 1:
print('Usage: python -m nameparser "Name String"')
raise SystemExit(1)
log = logging.getLogger('HumanName')
log.setLevel(logging.ERROR)
log.addHandler(logging.StreamHandler())
name_string = sys.argv[1]
hn = HumanName(name_string)
print(repr(hn))
hn.capitalize()
print(repr(hn))
# Use comma rather than concatenation: initials() returns
# empty_attribute_default (possibly None) when there are no initials.
print("Initials:", hn.initials())
if __name__ == '__main__':
main()