Split the query component into individual `name=value` pairs
        separated by `sep` and return a dictionary of query variables.
        The dictionary keys are the unique query variable names and
        the values are lists of values for each name.
764957
def getquerydict(self, sep='&', encoding='utf-8', errors='strict'):
        
        dict = collections.defaultdict(list)
        for name, value in self.getquerylist(sep, encoding, errors):
            dict[name].append(value)
        return dict
1319530
def parse_query(qs, d = '&;')
      params = {}
      (qs || '').split(/[#{d}] */n).each do |p|
        k, v = p.split('=', 2).map { |str| str } # NOTE: uri_unescape
        k = k.to_sym
        if cur = params[k]
          if cur.class == Array
            params[k] << v
          else
            params[k] = [cur, v]
          end
        else
          params[k] = v
        end
      end
      params
    end
1143831
private void generatePermutationsQueryVariables(
      ArrayList<HashMap<String, String[]>> result, Set<String> keys,
      HashMap<String, String[]> queryVariables) {
    if (keys != null && !keys.isEmpty()) {
      Set<String> newKeys = new HashSet<>();
      Iterator<String> it = keys.iterator();
      String key = it.next();
      String[] value = queryVariables.get(key);
      if (result.isEmpty()) {
        HashMap<String, String[]> newItem;
        if (value == null || value.length == 0) {
          newItem = new HashMap<>();
          newItem.put(key, value);
          result.add(newItem);
        } else {
          for (int j = 0; j < value.length; j++) {
            newItem = new HashMap<>();
            newItem.put(key, new String[] { value[j] });
            result.add(newItem);
          }
        }
      } else {
        ArrayList<HashMap<String, String[]>> newResult = new ArrayList<>();
        for (int i = 0; i < result.size(); i++) {
          HashMap<String, String[]> newItem;
          if (value == null || value.length == 0) {
            newItem = (HashMap<String, String[]>) result.get(i).clone();
            newItem.put(key, value);
            newResult.add(newItem);
          } else {
            for (int j = 0; j < value.length; j++) {
              newItem = (HashMap<String, String[]>) result.get(i).clone();
              newItem.put(key, new String[] { value[j] });
              newResult.add(newItem);
            }
          }
        }
        result.clear();
        result.addAll(newResult);
      }
      while (it.hasNext()) {
        newKeys.add(it.next());
      }
      generatePermutationsQueryVariables(result, newKeys, queryVariables);
    }
  }
885580
def parse_values(self, query):
        
        values = {}
        for name, filt in self.filters.items():
            val = filt.parse_value(query)
            if val is None:
                continue
            values[name] = val
        return values
217483
def query_params(self, value=None):
        
        if value is not None:
            return URL._mutate(self, query=unicode_urlencode(value, doseq=True))
        query = '' if self._tuple.query is None else self._tuple.query

        # In Python 2.6, urlparse needs a bytestring so we encode and then
        # decode the result.
        if not six.PY3:
            result = parse_qs(to_utf8(query), True)
            return dict_to_unicode(result)

        return parse_qs(query, True)
31811
private HashMap<String, String[]>[] expandedQueryVariables(
      HashMap<String, String[]> queryVariables) {
    ArrayList<HashMap<String, String[]>> result = new ArrayList<>();
    Set<String> keys = queryVariables.keySet();
    generatePermutationsQueryVariables(result, keys, queryVariables);
    return result.toArray(new HashMap[result.size()]);
  }
1328629
def map_query_string(self):
        
        if (not self.query_key_mapper or
            self.request.method == 'POST'):
            # Nothing to map, don't do anything.
            # return self.request.POST
            return {}

        keys = list(self.query_key_mapper.keys())

        return {self.query_key_mapper.get(k) if k in keys else k: v.strip()
                for k, v in self.request.GET.items()}
975891
def prepare_query_params(**kwargs):
    
    return [
        (sub_key, sub_value)
        for key, value in kwargs.items()
        for sub_key, sub_value in expand(value, key)
        if sub_value is not None
    ]
1202982
def clean_query(self):
        
        if self.query:
            for key, value in self.query.items():
                if isinstance(value, list) and None in value:
                    self.query[key] = [v for v in value if v is not None]
1100948
def _split_url_string(query_string):
        
        parameters = parse_qs(to_utf8(query_string), keep_blank_values=True)
        for k, v in parameters.iteritems():
            parameters[k] = urllib.unquote(v[0])
        return parameters
1292914
def _to_key_val_pairs(defs):
    

    if isinstance(defs, STRING_TYPES):
        # Convert 'a' to [('a', None)], or 'a.b.c' to [('a', 'b.c')]
        return [defs.split('.', 1) if '.' in defs else (defs, None)]
    else:
        pairs = []

        # Convert collections of strings or lists as above; break dicts into component items
        pairs.extend(p for s in defs if isinstance(s, STRING_TYPES) for p in _to_key_val_pairs(s))
        pairs.extend(p for l in defs if isinstance(l, list) for p in _to_key_val_pairs(l))
        pairs.extend(p for d in defs if isinstance(d, dict) for p in iteritems(d))

        return pairs
1227577
def append_query_param(self, key, value):
        
        values = self.query_param(key, as_list=True, default=[])
        values.append(value)
        return self.query_param(key, values)
968120
def get_unique_variable_names(text, nb):
    ''''''
    base_name = '__VAR_'
    var_names = []
    i = 0
    j = 0
    while j < nb:
        tentative_name = base_name + str(i)
        if text.count(tentative_name) == 0 and tentative_name not in ALL_NAMES:
            var_names.append(tentative_name)
            ALL_NAMES.append(tentative_name)
            j += 1
        i += 1
    return var_names
835529
def query_string=(query)
      self.query_params.clear

      ::URI::QueryParams.parse(query).each do |name,value|
        self.query_params.new(
          :name  => URLQueryParamName.first_or_new(:name => name),
          :value => value
        )
      end

      return query
    end
1331619
def _split_variables(variables):
    
    file_vs = []
    std_vs = []
    for v in variables:
        cur_type = v["type"]
        while isinstance(cur_type, dict):
            if "items" in cur_type:
                cur_type = cur_type["items"]
            else:
                cur_type = cur_type["type"]
        if (cur_type in ["File", "null", "record"] or
              (isinstance(cur_type, (list, tuple)) and
               ("File" in cur_type or {'items': 'File', 'type': 'array'} in cur_type))):
            file_vs.append(v)
        elif v["id"] in ALWAYS_AVAILABLE:
            std_vs.append(v)
        else:
            file_vs.append(v)
    return file_vs, std_vs
934908
function collectQueryParams(req, paramNames) {
    var result = {
        query: {},
        fields: {},
        options: {},
        params: {}
    };
    paramNames.forEach(function (paramName) {
        var paramValue = req.anyParam(paramName);
        if (paramValue) {
            paramValue = paramValue.trim();
            if (paramValue && paramValue !== '*') {
                if (paramValue.charAt(paramValue.length - 1) === '*') {
                    // regexp to match prefix
                    paramValue = new RegExp('^' + paramValue.substring(0, paramValue.length - 1));
                }
                result.query[paramName] = paramValue;
            }
            result.params[paramName] = paramValue;
        }
    });
    var fields = req.anyParam('fields');
    if (fields) {
        result.fields = {};
        fields.split(',').forEach(function (field) {
            field = field.trim();
            if (field) {
                var select = 1;
                switch (field.charAt(0)) {
                    case '-':
                        field = field.substring(1);
                        select = 0;
                        break;
                    case '+':
                        field = field.substring(1);
                        break;
                }
                result.fields[field] = select;
            }
        });
    }
    var sort = req.anyParam('sort');
    if (sort) {
        result.options.sort = {};
        sort.split(',').forEach(function (field) {
            field = field.trim();
            if (field) {
                var order = 1;
                switch (field.charAt(0)) {
                    case '-':
                        field = field.substring(1);
                        order = -1;
                        break;
                    case '+':
                        field = field.substring(1);
                        break;
                }
                result.options.sort[field] = order;
            }
        });
        result.params.sort = sort;
    }
    var skip = req.anyParam('skip') || req.anyParam('offset');
    if (skip) {
        result.options.skip = parseInt(skip, 10);
        result.params.skip = skip;
    }
    var limit = req.anyParam('limit');
    if (limit) {
        result.options.limit = parseInt(limit, 10);
        result.params.limit = limit;
    }
    return result;
}
981031
def query_to_map(text):
    '''
    '''
    dict_obj = {}

    for key, value in split_query(text, True):
        if key not in dict_obj:
            dict_obj[key] = []

        if value:
            dict_obj[key].append(value.replace('+', ' '))
        else:
            dict_obj[key].append('')

    return query_to_map(text)