def obj_equal_prims(obj_1, obj_2, ignore=None):
 def _strip(prim, keys):
  if isinstance(prim, dict):
   for k in keys:
    prim.pop(k, None)
   for v in prim.values():
    _strip(v, keys)
  if isinstance(prim, list):
   for v in prim:
    _strip(v, keys)
  return prim
 if (ignore is not None):
  keys = (['nova_object.changes'] + ignore)
 else:
  keys = ['nova_object.changes']
 prim_1 = _strip(obj_1.obj_to_primitive(), keys)
 prim_2 = _strip(obj_2.obj_to_primitive(), keys)
 return (prim_1 == prim_2)

def obj_equal_prims ( obj_1 , obj_2 , ignore = None ) : def _strip ( prim , keys ) : if isinstance ( prim , dict ) : for k in keys : prim . pop ( k , None ) for v in prim . values ( ) : _strip ( v , keys ) if isinstance ( prim , list ) : for v in prim : _strip ( v , keys ) return prim if ( ignore is not None ) : keys = ( [ 'nova_object.changes' ] + ignore ) else : keys = [ 'nova_object.changes' ] prim_1 = _strip ( obj_1 . obj_to_primitive ( ) , keys ) prim_2 = _strip ( obj_2 . obj_to_primitive ( ) , keys ) return ( prim_1 == prim_2 )
compare two primitives for equivalence ignoring some keys .