#NEWLINE# def parse( self , key , value ) : #NEWLINE# #INDENT# ref = self . result #NEWLINE# tokens = self . tokens ( key ) #NEWLINE# for token in tokens : #NEWLINE# #INDENT# ( token_type , key ) = token #NEWLINE# if ( token_type == QueryStringToken . ARRAY ) : #NEWLINE# #INDENT# if ( key not in ref ) : #NEWLINE# #INDENT# ref [ key ] = [ ] #NEWLINE# #UNINDENT# ref = ref [ key ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( token_type == QueryStringToken . OBJECT ) : #NEWLINE# #INDENT# if ( key not in ref ) : #NEWLINE# #INDENT# ref [ key ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# ref = ref [ key ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( token_type == QueryStringToken . KEY ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ref = ref [ key ] #NEWLINE# next ( tokens ) #NEWLINE# #UNINDENT# except ( IndexError , KeyError , TypeError ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# next_token = next ( tokens ) #NEWLINE# if ( next_token [ 0 ] == QueryStringToken . ARRAY ) : #NEWLINE# #INDENT# ref . append ( [ ] ) #NEWLINE# ref = ref [ key ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( next_token [ 0 ] == QueryStringToken . OBJECT ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ref [ key ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# ref . append ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# ref = ref [ key ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ref . append ( value ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# ref [ key ] = value #NEWLINE# #UNINDENT# return