def mutate(self, obj): if isinstance(obj, UnicodeType): # unicode strings are required to be placed in the body # (by our encoding scheme) self.in_body = 1 else: # XXX really should check getInBody(), but we'd have # to do isinstance() for each type ... maybe do later self.in_body = 0 if isInstanceLike(obj) or hasPickleFuncs(obj): # obj has data items (list,dict,tuple) *AND* attributes. # mutate to an oldstyle object, turning the data items into # a special attribute (eg. __items__, __entries__). # # also, if obj defines the special pickling functions, we treat # it as an instance so we don't have to duplicate all the # protocol logic here. return XMLP_Mutated(newinst_to_oldinst(obj)) else: # obj has only data items (list,dict,tuple,etc.) # convert to the raw datatype and remember the # module.class of obj for unpickling. (o, t) = newdata_to_olddata(obj) return XMLP_Mutated(o, t)
def mutate(self, obj): # (I avoided using strftime(), for portability reasons.) # Pickle seconds as a float to save full precision. s = "YMD = %d/%d/%d, HMS = %d:%d:%f" % \ (obj.year,obj.month,obj.day,\ obj.hour,obj.minute,obj.second) return XMLP_Mutated(s)
def mutate(self, obj): list = [] for item in obj: list.append(item) return XMLP_Mutated(list)
def mutate(self, obj): wrap = _EmptyClass() wrap.__toplevel__ = obj return XMLP_Mutated(wrap)
def mutate(self, obj): return XMLP_Mutated(pickle.dumps(obj))
def mutate(self, obj): return XMLP_Mutated(obj.pattern)