#NEWLINE# def looks_like_xml( text ) : #NEWLINE# #INDENT# '\n    Check if a doctype exists or if we have some tags.\n    ' #NEWLINE# key = hash ( text ) #NEWLINE# try : #NEWLINE# #INDENT# return _looks_like_xml_cache [ key ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# m = doctype_lookup_re . match ( text ) #NEWLINE# if ( m is not None ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# rv = ( tag_re . search ( m [ : 1000 ] ) is not None ) #NEWLINE# _looks_like_xml_cache [ key ] = rv #NEWLINE# return rv