def compare(self, data_fingerprint): if data_fingerprint == '' or data_fingerprint is None: return None my_sig = self.get_fingerprint(recalculate=True) result = [] if my_sig[0] != data_fingerprint[0]: #TODO: make info print "=!> Full fingerprints differ" if "dims" in my_sig[1] and "dims" in data_fingerprint[1]: if my_sig[1]["dims"][0] != data_fingerprint[1]["dims"][0]: #TODO: make info print "==!> Dimensions differ" for dk in my_sig[1]["dims"][1]: v1 = my_sig[1]["dims"][1][dk] if dk in data_fingerprint[1]["dims"][1]: v2 = data_fingerprint[1]["dims"][1][dk] else: #TODO: make info print "===!> Dimension '%s' does not exist in 2nd dataset" % dk res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.NEW_DIM result.append(res) continue if v1 != v2: #TODO: make info print "===!> Dimension '%s' differs" % dk res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.MOD_DIM result.append(res) else: #TODO: make debug # print "====> Dimension '%s' is equal" % dk continue for dk in data_fingerprint[1]["dims"][1]: v1 = data_fingerprint[1]["dims"][1][dk] if dk in my_sig[1]["dims"][1]: v2 = my_sig[1]["dims"][1][dk] else: #TODO: make info print "===!> Dimension '%s' does not exist in 1st dataset" % dk res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.NEW_DIM result.append(res) continue else: #TODO: make info print "===> Dimensions are equal" if "gbl_atts" in my_sig[1] and "gbl_atts" in data_fingerprint[1]: if my_sig[1]["gbl_atts"][0] != data_fingerprint[1]["gbl_atts"][0]: #TODO: make info print "==!> Global Attributes differ" for gk in my_sig[1]["gbl_atts"][1]: v1 = my_sig[1]["gbl_atts"][1][gk] if gk in data_fingerprint[1]["gbl_atts"][1]: v2 = data_fingerprint[1]["gbl_atts"][1][gk] else: #TODO: make info print "===!> Global Attribute '%s' does not exist in 2nd dataset" % gk res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.NEW_GATT result.append(res) continue if v1 != v2: #TODO: make info print "===!> Global Attribute '%s' differs" % gk res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.MOD_GATT result.append(res) else: #TODO: make debug # print "====> Global Attribute '%s' is equal" % gk continue for gk in data_fingerprint[1]["gbl_atts"][1]: v1 = data_fingerprint[1]["gbl_atts"][1][gk] if gk in my_sig[1]["gbl_atts"][1]: v2 = my_sig[1]["gbl_atts"][1][gk] else: #TODO: make info print "===!> Global Attribute '%s' does not exist in 1st dataset" % gk res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.NEW_GATT result.append(res) #dcr.add_gbl_attr(gk, True) continue else: #TODO: make info print "===> Global Attributes are equal" if "vars" in my_sig[1] and "vars" in data_fingerprint[1]: if my_sig[1]["vars"][0] != data_fingerprint[1]["vars"][0]: #TODO: make info print "==!> Variable attributes differ" for vk in my_sig[1]["vars"][1]: v1 = my_sig[1]["vars"][1][vk][0] if vk in data_fingerprint[1]["vars"][1]: v2 = data_fingerprint[1]["vars"][1][vk][0] else: #TODO: make info print "===!> Variable '%s' does not exist in 2nd dataset" % vk res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.NEW_VAR result.append(res) continue if v1 != v2: #TODO: make info print "===!> Variable '%s' differ" % vk res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.MOD_VAR result.append(res) for vak in my_sig[1]["vars"][1][vk][1]: va1 = my_sig[1]["vars"][1][vk][1][vak] if vak in data_fingerprint[1]["vars"][1][vk][1]: va2 = data_fingerprint[1]["vars"][1][vk][1][vak] else: #TODO: make info print "====!> Variable Attribute '%s' does not exist in 2nd dataset" % vak res = CompareResult() res.field_name = vak res.difference = CompareResultEnum.NEW_VARATT result.append(res) continue if va1 != va2: #TODO: make info print "====!> Variable Attribute '%s' differs" % vak res = CompareResult() res.field_name = vak res.difference = CompareResultEnum.MOD_VARATT result.append(res) else: #TODO: make debug # print "======> Variable Attribute '%s' is equal" % vak continue for vk in data_fingerprint[1]["vars"][1]: v1 = data_fingerprint[1]["vars"][1][vk][0] if vk in my_sig[1]["vars"][1]: v2 = my_sig[1]["vars"][1][vk][0] else: #TODO: make info print "===!> Variable '%s' does not exist in 1st dataset" % vk res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.NEW_VAR result.append(res) continue else: #TODO: make info print "===> Variable attributes are equal" else: #TODO: make debug print "==> Datasets are equal" res = CompareResult() res.field_name = "" res.difference = CompareResultEnum.EQUAL result.append(res) return result
def _compare(self, base_fingerprint, new_fingerprint): """ Compares two fingerprints to see what, if anything, is different @param base_fingerprint first fingerprint used in the comparison @param new_fingerprint second fingerprint used in the comparison """ if base_fingerprint == '' or base_fingerprint is None: return None if new_fingerprint == '' or new_fingerprint is None: return None my_sig = base_fingerprint result = [] if my_sig[0] != new_fingerprint[0]: #TODO: make info log.info("=!> Full fingerprints differ") if "dims" in my_sig[1] and "dims" in new_fingerprint[1]: if my_sig[1]["dims"][0] != new_fingerprint[1]["dims"][0]: #TODO: make info log.info("==!> Dimensions differ") for dk in my_sig[1]["dims"][1]: v1 = my_sig[1]["dims"][1][dk] if dk in new_fingerprint[1]["dims"][1]: v2 = new_fingerprint[1]["dims"][1][dk] else: #TODO: make info log.info("===!> Dimension '%s' does not exist in 2nd dataset" % dk) res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.NEW_DIM result.append(res) continue if v1 != v2: #TODO: make info log.info("===!> Dimension '%s' differs" % dk) res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.MOD_DIM result.append(res) else: #TODO: make debug # print "====> Dimension '%s' is equal" % dk continue for dk in new_fingerprint[1]["dims"][1]: v1 = new_fingerprint[1]["dims"][1][dk] if dk in my_sig[1]["dims"][1]: v2 = my_sig[1]["dims"][1][dk] else: #TODO: make info log.info("===!> Dimension '%s' does not exist in 1st dataset" % dk) res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.NEW_DIM result.append(res) continue else: #TODO: make info log.info("===> Dimensions are equal") if "gbl_atts" in my_sig[1] and "gbl_atts" in new_fingerprint[1]: if my_sig[1]["gbl_atts"][0] != new_fingerprint[1]["gbl_atts"][0]: #TODO: make info log.info("==!> Global Attributes differ") for gk in my_sig[1]["gbl_atts"][1]: v1 = my_sig[1]["gbl_atts"][1][gk] if gk in new_fingerprint[1]["gbl_atts"][1]: v2 = new_fingerprint[1]["gbl_atts"][1][gk] else: #TODO: make info log.info("===!> Global Attribute '%s' does not exist in 2nd dataset" % gk) res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.NEW_GATT result.append(res) continue if v1 != v2: #TODO: make info log.info("===!> Global Attribute '%s' differs" % gk) res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.MOD_GATT result.append(res) else: #TODO: make debug # print "====> Global Attribute '%s' is equal" % gk continue for gk in new_fingerprint[1]["gbl_atts"][1]: v1 = new_fingerprint[1]["gbl_atts"][1][gk] if gk in my_sig[1]["gbl_atts"][1]: v2 = my_sig[1]["gbl_atts"][1][gk] else: #TODO: make info log.info("===!> Global Attribute '%s' does not exist in 1st dataset" % gk) res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.NEW_GATT result.append(res) #dcr.add_gbl_attr(gk, True) continue else: #TODO: make info log.info("===> Global Attributes are equal") if "vars" in my_sig[1] and "vars" in new_fingerprint[1]: if my_sig[1]["vars"][0] != new_fingerprint[1]["vars"][0]: #TODO: make info log.info("==!> Variable attributes differ") for vk in my_sig[1]["vars"][1]: v1 = my_sig[1]["vars"][1][vk][0] if vk in new_fingerprint[1]["vars"][1]: v2 = new_fingerprint[1]["vars"][1][vk][0] else: #TODO: make info log.info("===!> Variable '%s' does not exist in 2nd dataset" % vk) res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.NEW_VAR result.append(res) continue if v1 != v2: #TODO: make info log.info("===!> Variable '%s' differ" % vk) res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.MOD_VAR result.append(res) for vak in my_sig[1]["vars"][1][vk][1]: va1 = my_sig[1]["vars"][1][vk][1][vak] if vak in new_fingerprint[1]["vars"][1][vk][1]: va2 = new_fingerprint[1]["vars"][1][vk][1][vak] else: #TODO: make info log.info("====!> Variable Attribute '%s' does not exist in 2nd dataset" % vak) res = CompareResult() res.field_name = vak res.difference = CompareResultEnum.NEW_VARATT result.append(res) continue if va1 != va2: #TODO: make info log.info("====!> Variable Attribute '%s' differs" % vak) res = CompareResult() res.field_name = vak res.difference = CompareResultEnum.MOD_VARATT result.append(res) else: #TODO: make debug # print "======> Variable Attribute '%s' is equal" % vak continue for vk in new_fingerprint[1]["vars"][1]: v1 = new_fingerprint[1]["vars"][1][vk][0] if vk in my_sig[1]["vars"][1]: v2 = my_sig[1]["vars"][1][vk][0] else: #TODO: make info log.info("===!> Variable '%s' does not exist in 1st dataset" % vk) res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.NEW_VAR result.append(res) continue else: #TODO: make info log.info("===> Variable attributes are equal") else: #TODO: make debug log.info("==> Datasets are equal") res = CompareResult() res.field_name = "" res.difference = CompareResultEnum.EQUAL result.append(res) return result
def _compare(self, base_fingerprint, new_fingerprint): """ Compares two fingerprints to see what, if anything, is different @param base_fingerprint first fingerprint used in the comparison @param new_fingerprint second fingerprint used in the comparison """ if base_fingerprint == '' or base_fingerprint is None: return None if new_fingerprint == '' or new_fingerprint is None: return None my_sig = base_fingerprint result = [] if my_sig[0] != new_fingerprint[0]: #TODO: make info log.info("=!> Full fingerprints differ") if "dims" in my_sig[1] and "dims" in new_fingerprint[1]: if my_sig[1]["dims"][0] != new_fingerprint[1]["dims"][0]: #TODO: make info log.info("==!> Dimensions differ") for dk in my_sig[1]["dims"][1]: v1 = my_sig[1]["dims"][1][dk] if dk in new_fingerprint[1]["dims"][1]: v2 = new_fingerprint[1]["dims"][1][dk] else: #TODO: make info log.info( "===!> Dimension '%s' does not exist in 2nd dataset" % dk) res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.NEW_DIM result.append(res) continue if v1 != v2: #TODO: make info log.info("===!> Dimension '%s' differs" % dk) res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.MOD_DIM result.append(res) else: #TODO: make debug # print "====> Dimension '%s' is equal" % dk continue for dk in new_fingerprint[1]["dims"][1]: v1 = new_fingerprint[1]["dims"][1][dk] if dk in my_sig[1]["dims"][1]: v2 = my_sig[1]["dims"][1][dk] else: #TODO: make info log.info( "===!> Dimension '%s' does not exist in 1st dataset" % dk) res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.NEW_DIM result.append(res) continue else: #TODO: make info log.info("===> Dimensions are equal") if "gbl_atts" in my_sig[1] and "gbl_atts" in new_fingerprint[1]: if my_sig[1]["gbl_atts"][0] != new_fingerprint[1]["gbl_atts"][ 0]: #TODO: make info log.info("==!> Global Attributes differ") for gk in my_sig[1]["gbl_atts"][1]: v1 = my_sig[1]["gbl_atts"][1][gk] if gk in new_fingerprint[1]["gbl_atts"][1]: v2 = new_fingerprint[1]["gbl_atts"][1][gk] else: #TODO: make info log.info( "===!> Global Attribute '%s' does not exist in 2nd dataset" % gk) res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.NEW_GATT result.append(res) continue if v1 != v2: #TODO: make info log.info("===!> Global Attribute '%s' differs" % gk) res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.MOD_GATT result.append(res) else: #TODO: make debug # print "====> Global Attribute '%s' is equal" % gk continue for gk in new_fingerprint[1]["gbl_atts"][1]: v1 = new_fingerprint[1]["gbl_atts"][1][gk] if gk in my_sig[1]["gbl_atts"][1]: v2 = my_sig[1]["gbl_atts"][1][gk] else: #TODO: make info log.info( "===!> Global Attribute '%s' does not exist in 1st dataset" % gk) res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.NEW_GATT result.append(res) #dcr.add_gbl_attr(gk, True) continue else: #TODO: make info log.info("===> Global Attributes are equal") if "vars" in my_sig[1] and "vars" in new_fingerprint[1]: if my_sig[1]["vars"][0] != new_fingerprint[1]["vars"][0]: #TODO: make info log.info("==!> Variable attributes differ") for vk in my_sig[1]["vars"][1]: v1 = my_sig[1]["vars"][1][vk][0] if vk in new_fingerprint[1]["vars"][1]: v2 = new_fingerprint[1]["vars"][1][vk][0] else: #TODO: make info log.info( "===!> Variable '%s' does not exist in 2nd dataset" % vk) res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.NEW_VAR result.append(res) continue if v1 != v2: #TODO: make info log.info("===!> Variable '%s' differ" % vk) res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.MOD_VAR result.append(res) for vak in my_sig[1]["vars"][1][vk][1]: va1 = my_sig[1]["vars"][1][vk][1][vak] if vak in new_fingerprint[1]["vars"][1][vk][1]: va2 = new_fingerprint[1]["vars"][1][vk][1][ vak] else: #TODO: make info log.info( "====!> Variable Attribute '%s' does not exist in 2nd dataset" % vak) res = CompareResult() res.field_name = vak res.difference = CompareResultEnum.NEW_VARATT result.append(res) continue if va1 != va2: #TODO: make info log.info( "====!> Variable Attribute '%s' differs" % vak) res = CompareResult() res.field_name = vak res.difference = CompareResultEnum.MOD_VARATT result.append(res) else: #TODO: make debug # print "======> Variable Attribute '%s' is equal" % vak continue for vk in new_fingerprint[1]["vars"][1]: v1 = new_fingerprint[1]["vars"][1][vk][0] if vk in my_sig[1]["vars"][1]: v2 = my_sig[1]["vars"][1][vk][0] else: #TODO: make info log.info( "===!> Variable '%s' does not exist in 1st dataset" % vk) res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.NEW_VAR result.append(res) continue else: #TODO: make info log.info("===> Variable attributes are equal") else: #TODO: make debug log.info("==> Datasets are equal") res = CompareResult() res.field_name = "" res.difference = CompareResultEnum.EQUAL result.append(res) return result
def compare(self, data_fingerprint): if data_fingerprint == '' or data_fingerprint is None: return None my_sig = self.get_fingerprint(recalculate=True) result = [] if my_sig[0] != data_fingerprint[0]: #TODO: make info print "=!> Full fingerprints differ" if "dims" in my_sig[1] and "dims" in data_fingerprint[1]: if my_sig[1]["dims"][0] != data_fingerprint[1]["dims"][0]: #TODO: make info print "==!> Dimensions differ" for dk in my_sig[1]["dims"][1]: v1 = my_sig[1]["dims"][1][dk] if dk in data_fingerprint[1]["dims"][1]: v2 = data_fingerprint[1]["dims"][1][dk] else: #TODO: make info print "===!> Dimension '%s' does not exist in 2nd dataset" % dk res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.NEW_DIM result.append(res) continue if v1 != v2: #TODO: make info print "===!> Dimension '%s' differs" % dk res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.MOD_DIM result.append(res) else: #TODO: make debug # print "====> Dimension '%s' is equal" % dk continue for dk in data_fingerprint[1]["dims"][1]: v1 = data_fingerprint[1]["dims"][1][dk] if dk in my_sig[1]["dims"][1]: v2 = my_sig[1]["dims"][1][dk] else: #TODO: make info print "===!> Dimension '%s' does not exist in 1st dataset" % dk res = CompareResult() res.field_name = dk res.difference = CompareResultEnum.NEW_DIM result.append(res) continue else: #TODO: make info print "===> Dimensions are equal" if "gbl_atts" in my_sig[1] and "gbl_atts" in data_fingerprint[1]: if my_sig[1]["gbl_atts"][0] != data_fingerprint[1]["gbl_atts"][ 0]: #TODO: make info print "==!> Global Attributes differ" for gk in my_sig[1]["gbl_atts"][1]: v1 = my_sig[1]["gbl_atts"][1][gk] if gk in data_fingerprint[1]["gbl_atts"][1]: v2 = data_fingerprint[1]["gbl_atts"][1][gk] else: #TODO: make info print "===!> Global Attribute '%s' does not exist in 2nd dataset" % gk res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.NEW_GATT result.append(res) continue if v1 != v2: #TODO: make info print "===!> Global Attribute '%s' differs" % gk res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.MOD_GATT result.append(res) else: #TODO: make debug # print "====> Global Attribute '%s' is equal" % gk continue for gk in data_fingerprint[1]["gbl_atts"][1]: v1 = data_fingerprint[1]["gbl_atts"][1][gk] if gk in my_sig[1]["gbl_atts"][1]: v2 = my_sig[1]["gbl_atts"][1][gk] else: #TODO: make info print "===!> Global Attribute '%s' does not exist in 1st dataset" % gk res = CompareResult() res.field_name = gk res.difference = CompareResultEnum.NEW_GATT result.append(res) #dcr.add_gbl_attr(gk, True) continue else: #TODO: make info print "===> Global Attributes are equal" if "vars" in my_sig[1] and "vars" in data_fingerprint[1]: if my_sig[1]["vars"][0] != data_fingerprint[1]["vars"][0]: #TODO: make info print "==!> Variable attributes differ" for vk in my_sig[1]["vars"][1]: v1 = my_sig[1]["vars"][1][vk][0] if vk in data_fingerprint[1]["vars"][1]: v2 = data_fingerprint[1]["vars"][1][vk][0] else: #TODO: make info print "===!> Variable '%s' does not exist in 2nd dataset" % vk res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.NEW_VAR result.append(res) continue if v1 != v2: #TODO: make info print "===!> Variable '%s' differ" % vk res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.MOD_VAR result.append(res) for vak in my_sig[1]["vars"][1][vk][1]: va1 = my_sig[1]["vars"][1][vk][1][vak] if vak in data_fingerprint[1]["vars"][1][vk][ 1]: va2 = data_fingerprint[1]["vars"][1][vk][ 1][vak] else: #TODO: make info print "====!> Variable Attribute '%s' does not exist in 2nd dataset" % vak res = CompareResult() res.field_name = vak res.difference = CompareResultEnum.NEW_VARATT result.append(res) continue if va1 != va2: #TODO: make info print "====!> Variable Attribute '%s' differs" % vak res = CompareResult() res.field_name = vak res.difference = CompareResultEnum.MOD_VARATT result.append(res) else: #TODO: make debug # print "======> Variable Attribute '%s' is equal" % vak continue for vk in data_fingerprint[1]["vars"][1]: v1 = data_fingerprint[1]["vars"][1][vk][0] if vk in my_sig[1]["vars"][1]: v2 = my_sig[1]["vars"][1][vk][0] else: #TODO: make info print "===!> Variable '%s' does not exist in 1st dataset" % vk res = CompareResult() res.field_name = vk res.difference = CompareResultEnum.NEW_VAR result.append(res) continue else: #TODO: make info print "===> Variable attributes are equal" else: #TODO: make debug print "==> Datasets are equal" res = CompareResult() res.field_name = "" res.difference = CompareResultEnum.EQUAL result.append(res) return result