def diff(data_one, data_two, prec=0): token_one = data_one.split() token_two = data_two.split() if len(token_one) != len(token_two): # for item_one, item_two in zip(token_one, token_two): # if item_one != item_two: # print(item_one) # print(item_two) # break return False for item_one, item_two in zip(token_one, token_two): if is_int(item_one) ^ is_int(item_two): return False elif is_int(item_one): if int(item_one) != int(item_two): return False elif is_float(item_one) ^ is_float(item_two): return False elif is_float(item_one): if abs(float(item_one) - float(item_two)) > prec: return False elif item_one != item_two: # print(item_one) # print(item_two) return False return True
def __set_config_values(self): for default_value in self.default_values.keys(): if self.config.has_option(self.section, default_value): try: self.config_value[default_value] = int( self.config.get(self.section, default_value)) except ValueError: if self.config.get(self.section, default_value) == "True": self.config_value[default_value] = True elif self.config.get(self.section, default_value) == "False": self.config_value[default_value] = False elif self.config.get(self.section, default_value).startswith("[") and \ self.config.get(self.section, default_value).endswith("]"): self.config_value[default_value] = \ self.config.get(self.section, default_value)[1:-1].replace(' ', '').split(',') elif self.config.get(self.section, default_value).startswith("{") and \ self.config.get(self.section, default_value).endswith("}"): self.config_value[default_value] = json.loads( self.config.get(self.section, default_value)) else: if is_float( self.config.get(self.section, default_value)): self.config_value[default_value] = float( self.config.get(self.section, default_value)) elif is_int( self.config.get(self.section, default_value)): self.config_value[default_value] = int( self.config.get(self.section, default_value)) else: self.config_value[default_value] = self.config.get( self.section, default_value) else: self.config_value[default_value] = self.default_values[ default_value]