Skip to content

Commit

Permalink
Merge pull request #76 from initstring/name-keyerrors
Browse files Browse the repository at this point in the history
Fix key errors on short names
  • Loading branch information
initstring authored Nov 28, 2023
2 parents 53f8170 + 2f13902 commit 31608d2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions linkedin2username.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ def split_name(name):
"""
parsed = re.split(' |-', name)

# Discard people without at least a first and last name
if len(parsed) < 2:
return None

if len(parsed) > 2:
split_name = {'first': parsed[0], 'second': parsed[-2], 'last': parsed[-1]}
else:
Expand Down Expand Up @@ -648,8 +652,9 @@ def write_lines(employees, name_func, domain, outfile):
"""
for employee in employees:
mutator = NameMutator(employee["full_name"])
for name in getattr(mutator, name_func)():
outfile.write(name + domain + '\n')
if mutator.name:
for name in getattr(mutator, name_func)():
outfile.write(name + domain + '\n')


def write_files(company, domain, employees, out_dir):
Expand Down

0 comments on commit 31608d2

Please sign in to comment.