#NEWLINE# def _iterencode_dict( self , dct , markers = None ) : #NEWLINE# #INDENT# if ( not dct ) : #NEWLINE# #INDENT# ( yield '{}' ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( markers is not None ) : #NEWLINE# #INDENT# markerid = id ( dct ) #NEWLINE# if ( markerid in markers ) : #NEWLINE# #INDENT# raise ValueError ( 'Circular reference detected' ) #NEWLINE# #UNINDENT# markers [ markerid ] = dct #NEWLINE# #UNINDENT# ( yield '{' ) #NEWLINE# first = True #NEWLINE# if self . ensure_ascii : #NEWLINE# #INDENT# encoder = encode_basestring_ascii #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# encoder = encode_basestring #NEWLINE# #UNINDENT# allow_nan = self . allow_nan #NEWLINE# if self . sort_keys : #NEWLINE# #INDENT# keys = dct . keys ( ) #NEWLINE# keys . sort ( ) #NEWLINE# items = [ ( k , dct [ k ] ) for k in keys ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# items = dct . iteritems ( ) #NEWLINE# #UNINDENT# for ( key , value ) in items : #NEWLINE# #INDENT# if isinstance ( key , ( str , unicode ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( key , float ) : #NEWLINE# #INDENT# key = floatstr ( key , allow_nan ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( key , ( int , long ) ) : #NEWLINE# #INDENT# key = str ( key ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key is True ) : #NEWLINE# #INDENT# key = 'true' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key is False ) : #NEWLINE# #INDENT# key = 'false' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key is None ) : #NEWLINE# #INDENT# key = 'null' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . skipkeys : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( ( 'key %r is not a string' % ( key , ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if first : #NEWLINE# #INDENT# first = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield ', ' ) #NEWLINE# #UNINDENT# ( yield encoder ( key ) ) #NEWLINE# ( yield ': ' ) #NEWLINE# for chunk in self . _iterencode ( value , markers ) : #NEWLINE# #INDENT# ( yield chunk ) #NEWLINE# #UNINDENT# #UNINDENT# ( yield '}' ) #NEWLINE# if ( markers is not None ) : #NEWLINE# #INDENT# del markers [ markerid ]