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
27 if exception:
28 raiseWithCurrentContext(exception)
29
30
31
32 compList[idx] = newComp
33 return False
34
35
36 compList.append(newComp)
37 return True
38
39