#NEWLINE# def __eq__( self , other ) : #NEWLINE# #INDENT# "'Deep, sparse compare.\n\n        Deeply compare two entities, following the non-None attributes of the\n        non-persisted object, if possible.\n\n        " #NEWLINE# if ( other is self ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not ( self . __class__ == other . __class__ ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# if ( id ( self ) in _recursion_stack ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# _recursion_stack . add ( id ( self ) ) #NEWLINE# try : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self_key = sa . orm . attributes . instance_state ( self ) . key #NEWLINE# #UNINDENT# except sa . orm . exc . NO_STATE : #NEWLINE# #INDENT# self_key = None #NEWLINE# #UNINDENT# if ( other is None ) : #NEWLINE# #INDENT# a = self #NEWLINE# b = other #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self_key is not None ) : #NEWLINE# #INDENT# a = other #NEWLINE# b = self #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# a = self #NEWLINE# b = other #NEWLINE# #UNINDENT# #UNINDENT# for attr in list ( a . __dict__ ) : #NEWLINE# #INDENT# if attr . startswith ( '_' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# value = getattr ( a , attr ) #NEWLINE# try : #NEWLINE# #INDENT# battr = getattr ( b , attr ) #NEWLINE# #UNINDENT# except ( AttributeError , sa_exc . UnboundExecutionError ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if hasattr ( value , '__iter__' ) : #NEWLINE# #INDENT# if ( hasattr ( value , '__getitem__' ) and ( not hasattr ( value , 'keys' ) ) ) : #NEWLINE# #INDENT# if ( list ( value ) != list ( battr ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( set ( value ) != set ( battr ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( value is not None ) and ( value != battr ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return True #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# _recursion_stack . remove ( id ( self ) )