Skip to content
Snippets Groups Projects
Commit a66c6eaa authored by Tomasz Bold's avatar Tomasz Bold Committed by Frank Winklmeier
Browse files

Add wasMerged in ComponentAccumulator

parent b8831fe2
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,10 @@ atlas_add_test( ComponentAccumulatorTest
SCRIPT python -m unittest -v AthenaConfiguration.ComponentAccumulator
POST_EXEC_SCRIPT nopost.sh )
atlas_add_test( UnifyPropertiesTest
SCRIPT python -m unittest -v AthenaConfiguration.UnifyProperties
POST_EXEC_SCRIPT nopost.sh )
atlas_add_test( AthConfigFlagsTest
SCRIPT python -m unittest AthenaConfiguration.AthConfigFlags
POST_EXEC_SCRIPT nopost.sh )
......
This diff is collapsed.
# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
# A collection of methods to unify/merge list-properties
# ToDo: Define the merging-method when defining the property
from AthenaCommon.Logging import logging
log=logging.getLogger('ComponentAccumulator')
def unifySet(prop1,prop2):
#May want to strip whitespace in case the params are lists of strings
......@@ -11,6 +13,13 @@ def unifySet(prop1,prop2):
su=s1 | s2
return list(su)
def unifySetVerbose(prop1,prop2):
log.debug("In UnifyProperties: unifying sets" )
log.debug( str(prop1) )
log.debug( "and" )
log.debug( str(prop2) )
return unifySet(prop1,prop2)
def unifySetOfPairs(prop1,prop2):
def getPairs(seq):
......@@ -19,7 +28,7 @@ def unifySetOfPairs(prop1,prop2):
if (2*nPairs!=len(seq)):
from AthenaConfiguration.ComponentAccumulator import ConfigurationError
raise ConfigurationError("Expected a sequence with even number of elements")
for i in range(0,nPairs):
r.add((seq[2*i],seq[2*i+1]))
return r
......@@ -32,6 +41,9 @@ def unifySetOfPairs(prop1,prop2):
finallist+=p
return finallist
_propsToUnify={"GeoModelSvc.DetectorTools":unifySet,
"CondInputLoader.Load":unifySet,
"IOVDbSvc.Folders":unifySet,
......@@ -48,6 +60,8 @@ _propsToUnify={"GeoModelSvc.DetectorTools":unifySet,
"AtRndmGenSvc.Seeds": unifySet,
}
def setUnificationFunction(key, function):
_propsToUnify[key] = function
def getUnificationKey(propname):
if propname in _propsToUnify:
......@@ -88,3 +102,17 @@ def unifyProperty(propname,prop1,prop2):
+ str(prop1) +"\n and \n" +str(prop2) \
+ "\nIf this property should be merged, consider adding it to AthenaConfiguration/UnifyProperties.py")
return unificationFunc(prop1,prop2)
# self test
import unittest
class BasicTest( unittest.TestCase ):
def runTest( self ):
unified = unifyProperty("Alg.HypoTools", ["a", "b"], ["c", "b"])
self.assertEqual( sorted(unified), sorted(["a", "b", "c"]), "Hypo tools unification failed" )
setUnificationFunction("*.HypoTools", unifySetVerbose)
log.setLevel(7)
unified = unifyProperty("Alg.HypoTools", ["a", "b"], ["c", "b"])
self.assertEqual( sorted(unified), sorted(["a", "b", "c"]), "Hypo tools unification failed" )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment