def _parse_qs(qs, keep_blank_values=0, strict_parsing=0, encoding='utf-8'):
 pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
 d = {}
 for name_value in pairs:
  if ((not name_value) and (not strict_parsing)):
   continue
  nv = name_value.split('=', 1)
  if (len(nv) != 2):
   if strict_parsing:
    raise ValueError(('bad query field: %r' % (name_value,)))
   if keep_blank_values:
    nv.append('')
   else:
    continue
  if (len(nv[1]) or keep_blank_values):
   name = urllib.unquote(nv[0].replace('+', ' '))
   name = name.decode(encoding, 'strict')
   value = urllib.unquote(nv[1].replace('+', ' '))
   value = value.decode(encoding, 'strict')
   if (name in d):
    if (not isinstance(d[name], list)):
     d[name] = [d[name]]
    d[name].append(value)
   else:
    d[name] = value
 return d

def _parse_qs ( qs , keep_blank_values = 0 , strict_parsing = 0 , encoding = 'utf-8' ) : pairs = [ s2 for s1 in qs . split ( '&' ) for s2 in s1 . split ( ';' ) ] d = { } for name_value in pairs : if ( ( not name_value ) and ( not strict_parsing ) ) : continue nv = name_value . split ( '=' , 1 ) if ( len ( nv ) != 2 ) : if strict_parsing : raise ValueError ( ( 'bad query field: %r' % ( name_value , ) ) ) if keep_blank_values : nv . append ( '' ) else : continue if ( len ( nv [ 1 ] ) or keep_blank_values ) : name = urllib . unquote ( nv [ 0 ] . replace ( '+' , ' ' ) ) name = name . decode ( encoding , 'strict' ) value = urllib . unquote ( nv [ 1 ] . replace ( '+' , ' ' ) ) value = value . decode ( encoding , 'strict' ) if ( name in d ) : if ( not isinstance ( d [ name ] , list ) ) : d [ name ] = [ d [ name ] ] d [ name ] . append ( value ) else : d [ name ] = value return d
parse a query given as a string argument .