def valuesSimilar(self, col, mValue, sValue): response = False if not (mValue or sValue): response = True elif not (mValue and sValue): response = False #check if they are similar if SanitationUtils.similarComparison(mValue) == SanitationUtils.similarComparison(sValue): response = True if self.DEBUG_UPDATE: self.registerMessage(self.testToStr(col, mValue, sValue, response)) return response
def update_meta(self, newmeta): oldmeta = self.read_meta() newmeta = dict([(key, SanitationUtils.coerceAscii(value)) for key, value in newmeta.items()]) changed = [] for key in ['title', 'description']: if SanitationUtils.similarComparison(oldmeta[key]) != SanitationUtils.similarComparison(newmeta[key]): changed += [key] if self.DEBUG_IMG: self.registerMessage( u"changing imgmeta[%s] from %s to %s" % (key, repr(oldmeta[key]), repr(newmeta[key])), self.fname ) if changed: self.write_meta(newmeta['title'], newmeta['description'])
def valuesSimilar(self, col, mValue, sValue): response = super(SyncUpdate_Usr, self).valuesSimilar(col, mValue, sValue) if not response: if "phone" in col.lower(): if "preferred" in col.lower(): mPreferred = SanitationUtils.similarTruStrComparison(mValue) sPreferred = SanitationUtils.similarTruStrComparison(sValue) # print repr(mValue), " -> ", mPreferred # print repr(sValue), " -> ", sPreferred if mPreferred == sPreferred: response = True else: mPhone = SanitationUtils.similarPhoneComparison(mValue) sPhone = SanitationUtils.similarPhoneComparison(sValue) plen = min(len(mPhone), len(sPhone)) if plen > 7 and mPhone[-plen] == sPhone[-plen]: response = True elif "role" in col.lower(): mRole = SanitationUtils.similarComparison(mValue) sRole = SanitationUtils.similarComparison(sValue) if mRole == 'rn': mRole = '' if sRole == 'rn': sRole = '' if mRole == sRole: response = True elif "address" in col.lower() and isinstance(mValue, ContactAddress): if( mValue != sValue ): pass # print "M: ", mValue.__str__(out_schema="flat"), "S: ", sValue.__str__(out_schema="flat") response = mValue.similar(sValue) elif "web site" in col.lower(): if SanitationUtils.similarURLComparison(mValue) == SanitationUtils.similarURLComparison(sValue): response = True if self.DEBUG_UPDATE: self.registerMessage(self.testToStr(col, mValue.__str__(), sValue.__str__(), response)) return response
def valuesSimilar(self, col, mValue, sValue): response = super(SyncUpdate_Prod, self).valuesSimilar(col, mValue, sValue) if col in self.colData.data: colData = self.colData.data[col] if colData.get('type'): if colData.get('type') == 'currency': mPrice = SanitationUtils.similarCurrencyComparison(mValue) sPrice = SanitationUtils.similarCurrencyComparison(sValue) if mPrice == sPrice: response = True elif not response: if col is 'descsum': mDesc = SanitationUtils.similarMarkupComparison(mValue) sDesc = SanitationUtils.similarMarkupComparison(sValue) if mDesc == sDesc: response = True elif col is 'CVC': mCom = SanitationUtils.similarComparison(mValue) or '0' sCom = SanitationUtils.similarComparison(sValue) or '0' if mCom == sCom: response = True if self.DEBUG_UPDATE: self.registerMessage(self.testToStr(col, mValue.__repr__(), sValue.__repr__(), response)) return response