def sameValuesAs(self, other): # we sort based on packed values since the items do not # necessarily implement __cmp__ def pack_(x): return x.pack() try: for key in set(six.iterkeys(self)).union(set(six.iterkeys(other))): if (key == Attribute.CODE.MP_REACH_NLRI or key == Attribute.CODE.MP_UNREACH_NLRI): continue sval = self[key] oval = other[key] # In the case where the attribute is Communities or # extended communities, we want to compare values independently of their order if isinstance(sval, Communities): if not isinstance(oval, Communities): return False sval = sorted(sval, key=pack_) oval = sorted(oval, key=pack_) if sval != oval: return False return True except KeyError: return False
def sameValuesAs (self, other): # we sort based on packed values since the items do not # necessarily implement __cmp__ def pack_(x): return x.pack() try: for key in set(six.iterkeys(self)).union(set(six.iterkeys(other))): if (key == Attribute.CODE.MP_REACH_NLRI or key == Attribute.CODE.MP_UNREACH_NLRI): continue sval = self[key] oval = other[key] # In the case where the attribute is Communities or # extended communities, we want to compare values independently of their order if isinstance(sval, Communities): if not isinstance(oval, Communities): return False sval = sorted(sval,key=pack_) oval = sorted(oval,key=pack_) if sval != oval: return False return True except KeyError: return False