def instantiate(self, cls, name): """ Instantiate a component and call it *name*. The component, *cls*, is either an instance of a BMI-like object or a class that implements the BMI. If *cls* is a class, it is instantiated by calling it's __init__ method without any arguments. """ if inspect.isclass(cls): self[name] = cls() else: self[name] = cls try: assert(is_implementation(type(self[name]), BmiBase)) except AssertionError: self.pop(name) raise TypeError( 'Class is not an implementation of cmt.bmi.BmiBase') else: self._connections[name] = dict()
def instantiate(self, cls, name): """ Instantiate a component and call it *name*. The component, *cls*, is either an instance of a BMI-like object or a class that implements the BMI. If *cls* is a class, it is instantiated by calling it's __init__ method without any arguments. """ if inspect.isclass(cls): self[name] = cls() else: self[name] = cls try: assert (is_implementation(type(self[name]), BmiBase)) except AssertionError: self.pop(name) raise TypeError( 'Class is not an implementation of cmt.bmi.BmiBase') else: self._connections[name] = dict()
def __init__(self, **kwds): super(Collection, self).__init__(**kwds) for (name, component) in self.items(): assert(is_implementation(component, BmiBase))
def __init__(self, **kwds): super(Collection, self).__init__(**kwds) for (name, component) in self.items(): assert (is_implementation(component, BmiBase))