def parse_received(received):
values_by_clause = {}<EOL>for pattern in RECEIVED_COMPILED_LIST:<EOL><INDENT>matches = [match for match in pattern.finditer(received)]<EOL>if len(matches) == <NUM_LIT:0>:<EOL><INDENT>log.debug("<STR_LIT>" % (<EOL>pattern.pattern, received))<EOL>continue<EOL><DEDENT>elif len(matches) > <NUM_LIT:1>:<EOL><INDENT>msg = "<STR_LIT>" % (<EOL>pattern.pattern, received)<EOL>log.error(msg)<EOL>raise MailParserReceivedParsingError(msg)<EOL><DEDENT>else:<EOL><INDENT>log.debug("<STR_LIT>" % (<EOL>pattern.pattern, received))<EOL>match = matches[<NUM_LIT:0>].groupdict()<EOL>if six.PY2:<EOL><INDENT>values_by_clause[match.keys()[<NUM_LIT:0>]] = match.values()[<NUM_LIT:0>]<EOL><DEDENT>elif six.PY3:<EOL><INDENT>key = list(match.keys())[<NUM_LIT:0>]<EOL>value = list(match.values())[<NUM_LIT:0>]<EOL>values_by_clause[key] = value<EOL><DEDENT><DEDENT><DEDENT>if len(values_by_clause) == <NUM_LIT:0>:<EOL><INDENT>msg = "<STR_LIT>" % (received)<EOL>log.error(msg)<EOL>raise MailParserReceivedParsingError(msg)<EOL><DEDENT>return values_by_clause<EOL>
Parse a single received header.
Return a dictionary of values by clause.

Arguments:
    received {str} -- single received header

Raises:
    MailParserReceivedParsingError -- Raised when a
        received header cannot be parsed

Returns:
    dict -- values by clause