Skip to content
Snippets Groups Projects

The get/pop CA method cause exception if looked for component is missing

Merged Tomasz Bold requested to merge tbold/athena:make-get-mehhods-fail-when-missing into master
All threads resolved!
Files
4
@@ -344,6 +344,8 @@ class ComponentAccumulator(object):
The CA will not keep any reference to the AlgTool.
"""
tool=self._privateTools
if tool is None:
raise ConfigurationError("Private tool(s) requested, but none are present")
self._privateTools=None
return tool
@@ -441,6 +443,9 @@ class ComponentAccumulator(object):
hits=[a for a in self._conditionsAlgs if a.name==name]
if (len(hits)>1):
raise ConfigurationError("More than one conditions algorithm with name {} found".format(name))
if (len(hits)==0):
raise ConfigurationError("No conditions algorithm with name {} found".format(name))
return hits[0]
def addService(self,newSvc,primary=False,create=False):
@@ -517,7 +522,8 @@ class ComponentAccumulator(object):
def __getOne(self, allcomps, name=None, typename="???"):
selcomps = allcomps if name is None else [ t for t in allcomps if t.name == name ]
if len( selcomps ) == 0:
return None
raise ConfigurationError(f"Requested component of name {name} but is missing" )
if len( selcomps ) == 1:
return selcomps[0]
raise ConfigurationError("Number of {} available {} which is != 1 expected by this API".format(typename, len(selcomps)) )
Loading