ATLAS Offline Software
Loading...
Searching...
No Matches
python.Deduplication Namespace Reference

Classes

class  DeduplicationFailed

Functions

 deduplicate (newComp, compList)
 deduplicateOne (newComp, oldComp)

Function Documentation

◆ deduplicate()

python.Deduplication.deduplicate ( newComp,
compList )
Merge newComp with compList. If a matching component is found it is updated
in compList. Otherwise a new component is added to compList.

Returns True if a new component has been added, otherwise False. If merging fails,
an exception is raised.

Definition at line 12 of file Deduplication.py.

12def deduplicate(newComp, compList):
13 """Merge newComp with compList. If a matching component is found it is updated
14 in compList. Otherwise a new component is added to compList.
15
16 Returns True if a new component has been added, otherwise False. If merging fails,
17 an exception is raised.
18 """
19
20 for idx, comp in enumerate(compList):
21 if comp.__cpp_type__==newComp.__cpp_type__ and comp.name==newComp.name:
22 exception = None
23 try:
24 newComp.merge(comp)
25 except Exception as e:
26 exception = e # remember exception and raise again outside the handler
27 if exception:
28 raiseWithCurrentContext(exception)
29
30 # We found a service of the same type and name and could reconcile the two instances.
31 # Overwrite the component in the list with the new (merged) component.
32 compList[idx] = newComp
33 return False
34
35 # No component of the same type and name found, simply append
36 compList.append(newComp)
37 return True
38
39

◆ deduplicateOne()

python.Deduplication.deduplicateOne ( newComp,
oldComp )
Merge newComp with oldComp and provide diagnostics on failure.

Definition at line 40 of file Deduplication.py.

40def deduplicateOne(newComp, oldComp):
41 """Merge newComp with oldComp and provide diagnostics on failure."""
42
43 exception = None
44 try:
45 assert oldComp.__cpp_type__ == newComp.__cpp_type__, "Deduplicating components of different type"
46 assert oldComp.name == newComp.name, "Deduplicating components of different name"
47 oldComp.merge(newComp)
48 except Exception as e:
49 exception = e # remember exception and raise again outside the handler
50 if exception:
51 raiseWithCurrentContext(exception)