def lookupEncoding(encoding):
if isinstance(encoding, binary_type):<EOL><INDENT>try:<EOL><INDENT>encoding = encoding.decode("<STR_LIT:ascii>")<EOL><DEDENT>except UnicodeDecodeError:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>if encoding is not None:<EOL><INDENT>try:<EOL><INDENT>return webencodings.lookup(encoding)<EOL><DEDENT>except AttributeError:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
Return the python codec name corresponding to an encoding or None if the
    string doesn't correspond to a valid encoding.