def lookupEncoding(encoding):
 if isinstance(encoding, binary_type):
  try:
   encoding = encoding.decode(u'ascii')
  except UnicodeDecodeError:
   return None
 if (encoding is not None):
  try:
   return webencodings.lookup(encoding)
  except AttributeError:
   return None
 else:
  return None

def lookupEncoding ( encoding ) : if isinstance ( encoding , binary_type ) : try : encoding = encoding . decode ( u'ascii' ) except UnicodeDecodeError : return None if ( encoding is not None ) : try : return webencodings . lookup ( encoding ) except AttributeError : return None else : return None
return the python codec name corresponding to an encoding or none if the string doesnt correspond to a valid encoding .