def fetch_data(self, country_codes, indicator_codes, start_date, end_date, wb_pause): # fetch indicator values # (through the date, countries and indicators parameters) # doesn't care of the crises conditions etc. # gets all the years!!! (which can be a lot of data for many countries) country_list = [] for cnt_code in country_codes: country = Country(cnt_code) for ind_code in indicator_codes: indicator = self.fetch_indicator(country.code, ind_code, start_date, end_date) time.sleep(wb_pause) indicator.code = ind_code country.set_indicator(ind_code, indicator) country_list.append(country) self.indicators = indicator_codes self.countries = country_list return self.countries
def fetch_data_sparse(self, country_codes, indicator_codes, event_boundaries, wb_pause): """ We fetch data only for the years that we need, specified in event_boundaries """ country_list = [] for cnt_code in country_codes: country = Country(cnt_code) for ind_code in indicator_codes: indicator = Indicator() for event in event_boundaries[cnt_code]: begin, end = event indicator_part = self.fetch_indicator( country.code, ind_code, begin, end) time.sleep(wb_pause) indicator.merge_with_indicator(indicator_part) indicator.code = ind_code country.set_indicator(ind_code, indicator) country_list.append(country) self.indicators = indicator_codes self.countries = country_list return self.countries
def fetch_data_sparse(self, country_codes, indicator_codes, event_boundaries, wb_pause): """ We fetch data only for the years that we need, specified in event_boundaries """ country_list = [] for cnt_code in country_codes: country = Country(cnt_code) for ind_code in indicator_codes: indicator = Indicator() for event in event_boundaries[cnt_code]: begin, end = event indicator_part = self.fetch_indicator(country.code, ind_code, begin, end) time.sleep(wb_pause) indicator.merge_with_indicator(indicator_part) indicator.code = ind_code country.set_indicator(ind_code, indicator) country_list.append(country) self.indicators = indicator_codes self.countries = country_list return self.countries