for group in groups: if group not in plugin_groups: badgroups.append(group) if badgroups: raise RuntimeError("Didn't recognize the following entry point" " groups: %s. Allowed groups are: %s" % (badgroups, plugin_groups.keys())) types = [] for fct in _factories: types.extend(fct.get_available_types(groups)) return sorted(types, _cmp) def get_signature(typname, version=None): """Return constructor argument signature for *typname* using the specified package version. The form of the return value matches that of :meth:`inspect.getargspec`. """ for fct in _factories: signature = fct.get_signature(typname, version) if signature is not None: return signature return None # register factory that loads plugins via pkg_resources register_class_factory(PkgResourcesFactory()) # register factory for simple imports register_class_factory(ImportFactory())
def test_import(self): ifactory = ImportFactory() mycomp = ifactory.create('openmdao.main.component.Component') self.assertEqual(mycomp.__class__.__name__ , 'Component')
def test_res_desc_import(self): ifactory = ImportFactory() obj = ifactory.create('openmdao.main.component.Component', res_desc={'my_attribute':4}) self.assertEqual(obj, None)
def test_server_import(self): ifactory = ImportFactory() obj = ifactory.create('openmdao.main.component.Component', server='open_mdao_srv') self.assertEqual(obj, None)
def test_version_import(self): ifactory = ImportFactory() obj = ifactory.create('openmdao.main.component.Component', version='1.2') self.assertEqual(obj, None)
def test_bad_import(self): ifactory = ImportFactory() obj = ifactory.create('boguscompname') self.assertEqual(obj, None)