#NEWLINE# def _parse_qs( qs , keep_blank_values = 0 , strict_parsing = 0 , encoding = 'utf-8' ) : #NEWLINE# #INDENT# 'Parse a query given as a string argument.\n\n    Arguments:\n\n    qs: URL-encoded query string to be parsed\n\n    keep_blank_values: flag indicating whether blank values in\n        URL encoded queries should be treated as blank strings.  A\n        true value indicates that blanks should be retained as blank\n        strings.  The default false value indicates that blank values\n        are to be ignored and treated as if they were  not included.\n\n    strict_parsing: flag indicating what to do with parsing errors. If\n        false (the default), errors are silently ignored. If true,\n        errors raise a ValueError exception.\n\n    Returns a dict, as G-d intended.\n    ' #NEWLINE# pairs = [ s2 for s1 in qs . split ( '&' ) for s2 in s1 . split ( ';' ) ] #NEWLINE# d = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for name_value in pairs : #NEWLINE# #INDENT# if ( ( not name_value ) and ( not strict_parsing ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# nv = name_value . split ( '=' , 1 ) #NEWLINE# if ( len ( nv ) != 2 ) : #NEWLINE# #INDENT# if strict_parsing : #NEWLINE# #INDENT# raise ValueError ( ( 'bad query field: %r' % ( name_value , ) ) ) #NEWLINE# #UNINDENT# if keep_blank_values : #NEWLINE# #INDENT# nv . append ( '' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# if ( len ( nv [ 1 ] ) or keep_blank_values ) : #NEWLINE# #INDENT# name = unquote_qs ( nv [ 0 ] , encoding ) #NEWLINE# value = unquote_qs ( nv [ 1 ] , encoding ) #NEWLINE# if ( name in d ) : #NEWLINE# #INDENT# if ( not isinstance ( d [ name ] , list ) ) : #NEWLINE# #INDENT# d [ name ] = [ d [ name ] ] #NEWLINE# #UNINDENT# d [ name ] . append ( value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# d [ name ] = value #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return d