def getParamRenames(self) -> Dict[str, str]: """ Return the parameter renames from all registered plugins. This renders a merged dictionary containing all parameter renames from all of the registered plugins. It also performs simple error checking. """ if self._paramRenames is None: currentNames = {pd.name for pd in parameters.ALL_DEFINITIONS} renames: Dict[str, str] = dict() for ( pluginRenames ) in self._pm.hook.defineParameterRenames(): # pylint: disable=no-member collisions = currentNames & pluginRenames.keys() if collisions: raise plugins.PluginError( "The following parameter renames from a plugin collide with " "currently-defined parameters:\n{}".format(collisions) ) pluginCollisions = renames.keys() & pluginRenames.keys() if pluginCollisions: raise plugins.PluginError( "The following parameter renames are already defined by another " "plugin:\n{}".format(pluginCollisions) ) renames.update(pluginRenames) self._paramRenames = renames return self._paramRenames
def __new__(mcs, name, bases, attrs): # pylint: disable=no-member pm = armi.getPluginManager() if pm is None: runLog.warning( "Blueprints were instantiated before the framework was " "configured with plugins. Blueprints cannot be imported before " "ARMI has been configured." ) else: pluginSections = pm.hook.defineBlueprintsSections() for plug in pluginSections: for (attrName, section, resolver) in plug: assert isinstance(section, yamlize.Attribute) if attrName in attrs: raise plugins.PluginError( "There is already a section called '{}' in the reactor " "blueprints".format(attrName) ) attrs[attrName] = section attrs["_resolveFunctions"].append(resolver) newType = yamlize.objects.ObjectType.__new__(mcs, name, bases, attrs) return newType
def getParamRenames(self) -> Dict[str, str]: """ Return the parameter renames from all registered plugins. This renders a merged dictionary containing all parameter renames from all of the registered plugins. It also performs simple error checking. The result of this operation is cached, since it is somewhat expensive to perform. If the App detects that its plugin manager's set of registered plugins has changed, the cache will be invalidated and recomputed. """ cacheInvalid = False if self._paramRenames is not None: renames, counter = self._paramRenames if counter != self._pm.counter: cacheInvalid = True else: cacheInvalid = True if cacheInvalid: currentNames = {pd.name for pd in parameters.ALL_DEFINITIONS} renames = dict() for ( pluginRenames ) in self._pm.hook.defineParameterRenames(): # pylint: disable=no-member collisions = currentNames & pluginRenames.keys() if collisions: raise plugins.PluginError( "The following parameter renames from a plugin collide with " "currently-defined parameters:\n{}".format(collisions) ) pluginCollisions = renames.keys() & pluginRenames.keys() if pluginCollisions: raise plugins.PluginError( "The following parameter renames are already defined by another " "plugin:\n{}".format(pluginCollisions) ) renames.update(pluginRenames) self._paramRenames = renames, self._pm.counter return renames