def get_key_value(parts, key_field_num, ignore_missing_keys, seen_keys,<EOL>output_type):
key_val = parts[key_field_num]<EOL>if key_val.strip() == "<STR_LIT>":<EOL><INDENT>if not ignore_missing_keys:<EOL><INDENT>raise MissingKeyError("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>if key_val in seen_keys andoutput_type is OutputType.error_on_dups:<EOL><INDENT>raise DuplicateKeyError(key_val + "<STR_LIT>")<EOL><DEDENT>return key_val<EOL>
get the key value from the line and check it's not a dup. or missing. fields
with only whitespace are considered empty (missing).

:param ignore_missing_keys: if True, return None for missing keys. If false,
                            missing keys cause an exception
                            (MissingKeyError).
:param seen_keys: a set of keys already seen.

:return: the key value, or None if the field was empty.