def __eq__(self,other): if self is other: return True if self.source_mmsi != other.source_mmsi: return False if len(self.__dict__) != len(other.__dict__): #k1 = self.__dict__.keys() #k2 = other.__dict__.keys() #k1.sort() #k2.sort() #sys.stderr.write('\n\n%s\n%s\n' % (k1,k2)) #sys.stderr.write('VERY_BAD_eq: len diff %d %s\n' % (len(k1),len(k2))) return False for key in self.__dict__: # FIX: should we skip checking the year and month as they are not really part of the message? #if key in ('year','month'): continue if key not in other.__dict__: #sys.stderr.write('VERY_BAD_eq_2: bad key: %s\n' % (str(key),)) return False if isinstance(self.__dict__[key], float): if not almost_equal(self.__dict__[key], other.__dict__[key]): #sys.stderr.write('float_key_not_same: %s - %s %s\n' % (key,self.__dict__[key],other.__dict__[key])) return False elif self.__dict__[key] != other.__dict__[key]: #sys.stderr.write('key_not_same: %s\n\t%s\n\t%s\n' % (key,self.__dict__[key],other.__dict__[key])) return False return True
def __eq__(self, other): if self is other: return True if self.source_mmsi != other.source_mmsi: return False if len(self.__dict__) != len(other.__dict__): return False for key in self.__dict__: # TODO(schwehr): Should we skip checking the year and month? # They are not really part of the message? if key not in other.__dict__: return False if isinstance(self.__dict__[key], float): if not almost_equal(self.__dict__[key], other.__dict__[key]): return False elif self.__dict__[key] != other.__dict__[key]: return False return True