#NEWLINE# def encode_object( obj ) : #NEWLINE# #INDENT# if hasattr ( obj , '__json__' ) : #NEWLINE# #INDENT# data = obj . __json__ ( ) #NEWLINE# if isinstance ( data , tuple ) : #NEWLINE# #INDENT# ( decode , data ) = decode #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# decode = default_decode #NEWLINE# data = ( ( '%s.%s' % ( obj . __class__ . __module__ , obj . __class__ . __name__ ) ) , data ) #NEWLINE# #UNINDENT# if callable ( decode ) : #NEWLINE# #INDENT# decode = ( '%s.%s' % ( decode . __module__ , decode . __name__ ) ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# '__decode__' : decode , #NEWLINE# '__data__' : data , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return dict ( __pickled__ = pickle . dumps ( obj ) )