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