69 """Replace one object with a different one of the same type.
71 This function replaces the contents of `fromObj` object with those of `toObj`,
72 so all references ot it remain valid.
75 if not isinstance(toObj, type(fromObj)):
76 raise TypeError(
'replaceWith requires both arguments to be the same type')
78 if isinstance(toObj, cms._ModuleSequenceType):
79 fromObj._seq = toObj._seq
81 elif isinstance(toObj, cms._Parameterizable):
83 for p
in fromObj.parameterNames_():
85 for p
in toObj.parameterNames_():
86 setattr(fromObj, p, getattr(toObj, p))
87 if isinstance(toObj, cms._TypedParameterizable):
88 fromObj._TypedParameterizable__type = toObj._TypedParameterizable__type
91 raise TypeError(
'replaceWith does not work with "%s" objects' %
str(type(fromObj)))