class Comparator: def __init__(self, logger): self.logger = logger self.weather_ui = WeatherUi(logger) self.weather_api = WeatherApi(logger) self.result = dict() def get_temp_comparision(self, cities, variance): self.logger.info( 'Starting weather details comparision from UI and API') temp_from_ui = self.weather_ui.get_weather_details(cities) temp_from_api = self.weather_api.get_weather_details(cities) for ct in cities: res = abs( float(temp_from_ui.get(ct, 0)) - float(temp_from_api.get(ct, 0))) if res < variance: self.result[ct] = True else: self.result[ct] = False return self.result