def get_source_map(source_dict): source_map = {} for system_name, sources in source_dict.iteritems(): source_map[system_name] = [] for class_name, options in sources.iteritems(): source_class = utils.get_class(class_name) source_map[system_name].append(source_class(options)) return source_map
def get_backend_map(backend_dict): backend_map = {} for system_name, envs in backend_dict.iteritems(): backend_map[system_name] = {} for env_name, backends in envs.iteritems(): for class_name, options in backends.iteritems(): # Only one backend per environment backend_class = utils.get_class(class_name) backend_map[system_name][env_name] = backend_class(options) break return backend_map
def test_get_class(importlib): importlib.import_module.return_value = testutils.mock_attr(klass='foo') eq_(utils.get_class('path.to.klass'), 'foo') importlib.import_module.assert_called_with('path.to')