56 """Replace one object with a different one of the same type. 58 This function replaces the contents of `fromObj` object with those of `toObj`, 59 so all references ot it remain valid. 62 if type(toObj) != type(fromObj):
63 raise TypeError(
'replaceWith requires both arguments to be the same type')
65 if isinstance(toObj, cms._ModuleSequenceType):
66 fromObj._seq = toObj._seq
68 elif isinstance(toObj, cms._Parameterizable):
70 for p
in fromObj.parameterNames_():
72 for p
in toObj.parameterNames_():
73 setattr(fromObj, p, getattr(toObj, p))
74 if isinstance(toObj, cms._TypedParameterizable):
75 fromObj._TypedParameterizable__type = toObj._TypedParameterizable__type
78 raise TypeError(
'replaceWith does not work with "%s" objects' %
str(type(fromObj)))
80 def replace_with(fromObj, toObj)