def load_data(self, name): """Load tmp given a tmp path. This is a low level method that will search through the various search paths until it's able to load a value. This is typically only needed to load *non* model files (such as _endpoints and _retry). If you need to load model files, you should prefer ``load_service_model``. :type name: str :param name: The tmp path, i.e ``ec2/2015-03-01/service-2``. :return: The loaded tmp. If no tmp could be found then a DataNotFoundError is raised. """ for possible_path in self._potential_locations(name): found = self.file_loader.load_file(possible_path) if found is not None: return found # We didn't find anything that matched on any path. raise DataNotFoundError(data_path=name)
def load_file(self, file_path): """ Loads a regular data file (format-specific to subclass). This load is done uncached, so that you can always get the latest data as needed. Usage:: >>> loader = JSONFileLoader() >>> loader.load_file('/path/to/some/thing.json') { # ...JSON data... } """ try: with open(file_path) as fp: return json.load(fp, object_pairs_hook=OrderedDict) except ValueError: # For backward-compatibility with the previous implementation, # if the JSON is bad, we'll raise a ``DataNotFoundError`` exception # instead of letting it propagate. raise DataNotFoundError(data_path=file_path)
def test_add_waiter_no_waiter_config(self): self.session.get_waiter_model.side_effect = DataNotFoundError( data_path='foo') command_table = {} add_waiters(command_table, self.session, self.command_object) self.assertEqual(command_table, {})