#NEWLINE# def dict_contents( self , use_dict = None , as_class = dict ) : #NEWLINE# #INDENT# 'Return the contents of an object as a dict.' #NEWLINE# if _debug : #NEWLINE# #INDENT# _log . debug ( 'dict_contents use_dict=%r as_class=%r' , use_dict , as_class ) #NEWLINE# #UNINDENT# if ( use_dict is None ) : #NEWLINE# #INDENT# use_dict = as_class ( ) #NEWLINE# #UNINDENT# for element in self . choiceElements : #NEWLINE# #INDENT# value = getattr ( self , element . name , None ) #NEWLINE# if ( value is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if issubclass ( element . klass , Atomic ) : #NEWLINE# #INDENT# mapped_value = value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if issubclass ( element . klass , AnyAtomic ) : #NEWLINE# #INDENT# mapped_value = value . value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( mapped_value , element . klass ) : #NEWLINE# #INDENT# mapped_value = value . dict_contents ( as_class = as_class ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# use_dict . __setitem__ ( element . name , mapped_value ) #NEWLINE# break #NEWLINE# #UNINDENT# return use_dict