61 """Replace one object with a different one of the same type.
63 This function replaces the contents of `fromObj` object with those of `toObj`,
64 so all references ot it remain valid.
67 if not isinstance(toObj, type(fromObj)):
68 raise TypeError(
'replaceWith requires both arguments to be the same type')
70 if isinstance(toObj, cms._ModuleSequenceType):
71 fromObj._seq = toObj._seq
73 elif isinstance(toObj, cms._Parameterizable):
75 for p
in fromObj.parameterNames_():
77 for p
in toObj.parameterNames_():
78 setattr(fromObj, p, getattr(toObj, p))
79 if isinstance(toObj, cms._TypedParameterizable):
80 fromObj._TypedParameterizable__type = toObj._TypedParameterizable__type
83 raise TypeError(
'replaceWith does not work with "%s" objects' %
str(type(fromObj)))