def fix_name_capitalization(lastname, givennames):
lastnames = lastname.split()<EOL>if len(lastnames) == <NUM_LIT:1>:<EOL><INDENT>if '<STR_LIT:->' in lastname:<EOL><INDENT>names = lastname.split('<STR_LIT:->')<EOL>names = [a[<NUM_LIT:0>] + a[<NUM_LIT:1>:].lower() for a in names]<EOL>lastname = '<STR_LIT:->'.join(names)<EOL><DEDENT>else:<EOL><INDENT>lastname = lastname[<NUM_LIT:0>] + lastname[<NUM_LIT:1>:].lower()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>names = []<EOL>for name in lastnames:<EOL><INDENT>if re.search(r'<STR_LIT>', name):<EOL><INDENT>names.append(name)<EOL><DEDENT>else:<EOL><INDENT>names.append(name[<NUM_LIT:0>] + name[<NUM_LIT:1>:].lower())<EOL><DEDENT><DEDENT>lastname = '<STR_LIT:U+0020>'.join(names)<EOL>lastname = collapse_initials(lastname)<EOL><DEDENT>names = []<EOL>for name in givennames:<EOL><INDENT>if re.search(r'<STR_LIT>', name):<EOL><INDENT>names.append(name)<EOL><DEDENT>else:<EOL><INDENT>names.append(name[<NUM_LIT:0>] + name[<NUM_LIT:1>:].lower())<EOL><DEDENT><DEDENT>givennames = '<STR_LIT:U+0020>'.join(names)<EOL>return lastname, givennames<EOL>
Converts capital letters to lower keeps first letter capital.