def normalize_name(name):
if not name or not isinstance(name, basestring):<EOL><INDENT>raise ValueError('<STR_LIT>'+ repr(name))<EOL><DEDENT>if len(name) > <NUM_LIT:1>:<EOL><INDENT>name = name.lower()<EOL><DEDENT>if name != '<STR_LIT:_>' and '<STR_LIT:_>' in name:<EOL><INDENT>name = name.replace('<STR_LIT:_>', '<STR_LIT:U+0020>')<EOL><DEDENT>return canonical_names.get(name, name)<EOL>
Given a key name (e.g. "LEFT CONTROL"), clean up the string and convert to
the canonical representation (e.g. "left ctrl") if one is known.