Skip to content

Commit

Permalink
Fix key errors on short names
Browse files Browse the repository at this point in the history
  • Loading branch information
initstring committed Nov 28, 2023
1 parent 53f8170 commit 2f13902
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 2f13902

Please sign in to comment.