#NEWLINE# def xml_compare( x1 , x2 , reporter = None ) : #NEWLINE# #INDENT# if ( x1 . tag != x2 . tag ) : #NEWLINE# #INDENT# if reporter : #NEWLINE# #INDENT# reporter ( ( 'Tags do not match: %s and %s' % ( x1 . tag , x2 . tag ) ) ) #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# for ( name , value ) in six . iteritems ( x1 . attrib ) : #NEWLINE# #INDENT# if ( x2 . attrib . get ( name ) != value ) : #NEWLINE# #INDENT# if reporter : #NEWLINE# #INDENT# reporter ( ( 'Attributes do not match: %s=%r, %s=%r' % ( name , value , name , x2 . attrib . get ( name ) ) ) ) #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# for name in x2 . attrib : #NEWLINE# #INDENT# if ( name not in x1 . attrib ) : #NEWLINE# #INDENT# if reporter : #NEWLINE# #INDENT# reporter ( ( 'x2 has an attribute x1 is missing: %s' % name ) ) #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# if ( not text_compare ( x1 . text , x2 . text ) ) : #NEWLINE# #INDENT# if reporter : #NEWLINE# #INDENT# reporter ( ( 'text: %r != %r' % ( x1 . text , x2 . text ) ) ) #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# if ( not text_compare ( x1 . tail , x2 . tail ) ) : #NEWLINE# #INDENT# if reporter : #NEWLINE# #INDENT# reporter ( ( 'tail: %r != %r' % ( x1 . tail , x2 . tail ) ) ) #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# cl1 = list ( x1 ) #NEWLINE# cl2 = list ( x2 ) #NEWLINE# if ( len ( cl1 ) != len ( cl2 ) ) : #NEWLINE# #INDENT# if reporter : #NEWLINE# #INDENT# reporter ( ( 'children length differs, %i != %i' % ( len ( cl1 ) , len ( cl2 ) ) ) ) #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# i = 0 #NEWLINE# for ( c1 , c2 ) in zip ( cl1 , cl2 ) : #NEWLINE# #INDENT# i += 1 #NEWLINE# if ( not xml_compare ( c1 , c2 , reporter = reporter ) ) : #NEWLINE# #INDENT# if reporter : #NEWLINE# #INDENT# reporter ( ( 'children %i do not match: %s' % ( i , c1 . tag ) ) ) #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# return True