Return a human-readable representation of a parameterized MATCH query string.
323894
def pretty_print_match(match, parameterized=True):
    """"""
    left_curly = '{{' if parameterized else '{'
    right_curly = '}}' if parameterized else '}'
    match = remove_custom_formatting(match)
    parts = re.split('({}|{})'.format(left_curly, right_curly), match)

    inside_braces = False
    indent_size = 4
    indent = ' ' * indent_size

    output = [parts[0]]
    for current_index, current_part in enumerate(parts[1:]):
        if current_part == left_curly:
            if inside_braces:
                raise AssertionError(u'Found open-braces pair while already inside braces: '
                                     u'{} {} {}'.format(current_index, parts, match))
            inside_braces = True
            output.append(current_part + '\n')
        elif current_part == right_curly:
            if not inside_braces:
                raise AssertionError(u'Found close-braces pair while not inside braces: '
                                     u'{} {} {}'.format(current_index, parts, match))
            inside_braces = False
            output.append(current_part)
        else:
            if not inside_braces:
                stripped_part = current_part.lstrip()
                if stripped_part.startswith('.'):
                    # Strip whitespace before traversal steps.
                    output.append(stripped_part)
                else:
                    # Do not strip whitespace before e.g. the RETURN keyword.
                    output.append(current_part)
            else:
                # Split out the keywords, initially getting rid of commas.
                separate_keywords = re.split(', ([a-z]+:)', current_part)

                # The first item in the separated list is the full first "keyword: value" pair.
                # For every subsequent item, the keyword and value are separated; join them
                # back together, outputting the comma, newline and indentation before them.
                output.append(indent + separate_keywords[0].lstrip())
                for i in six.moves.xrange(1, len(separate_keywords) - 1, 2):
                    output.append(',\n{indent}{keyword} {value}'.format(
                        keyword=separate_keywords[i].strip(),
                        value=separate_keywords[i + 1].strip(),
                        indent=indent))
                output.append('\n')

    return ''.join(output).strip()
1001433
def parse_query(self, query):
        """"""
        tree = pypeg2.parse(query, Main, whitespace="")
        return tree.accept(self.converter)
1229858
def parse_match_info(self, req: Request, name: str, field: Field) -> typing.Any:
        """"""
        return core.get_value(req.match_info, name, field)
829031
def match_uriinfo(cls, info):
        
        items = sorted(
            cls._entries.items(),
            key=lambda matcher_entries: matcher_entries[0].priority,
            reverse=True,
        )
        for matcher, value in items:
            if matcher.matches(info):
                return (matcher, info)

        return (None, [])
112962
function QueryString(search) {
        "use strict";
    
        if (search.substr(0, 1) === '?') {
            search = search.substr(1);
        }
    
        search = search.split('&')
    
        if (search == "") return {};
    
        for (var i = 0; i < search.length; ++i) {
    
            var param = search[i].split('=', 2);
            if (param.length != 2) {
                continue;
            }
    
            this[param[0]] = decodeURIComponent(param[1].replace(/\+/g, " "));
    
        }
    
    }
77327
def parse_querystring(self, req, name, field):
        """"""
        return core.get_value(req.params, name, field)
298985
def str_matcher(mode):
    

    def f_raw(inp_str, pos):
        return unique_literal_cache_pool[mode] if inp_str.startswith(mode, pos) else None

    def f_collection(inp_str, pos):
        for each in mode:
            if inp_str.startswith(each, pos):
                return unique_literal_cache_pool[each]
        return None

    if isinstance(mode, str):
        return f_raw

    if len(mode) is 1:
        mode = mode[0]
        return f_raw

    return f_collection
560529
def parse_querystring(self, req, name, field):
        """"""
        return get_value(req.query_arguments, name, field)
1039771
private static Object readQueryString(String queryName,
                                          Class<?> paramType,
                                          Type genericType,
                                          Annotation[] paramAnns,
                                          Message m,
                                          String defaultValue,
                                          boolean decode) {

        MultivaluedMap<String, String> queryMap = new UriInfoImpl(m, null).getQueryParameters(decode);

        if ("".equals(queryName)) {
            return InjectionUtils.handleBean(paramType, paramAnns, queryMap, ParameterType.QUERY, m, false);
        }
        return InjectionUtils.createParameterObject(queryMap.get(queryName),
                                                    paramType,
                                                    genericType,
                                                    paramAnns,
                                                    defaultValue,
                                                    false,
                                                    ParameterType.QUERY, m);
    }
354766
function(query) {
        var queryObj = {q: ''};
        if(!query) {
            return queryObj;
        }

        var qArray = query.split('&');
        var qObj = qs.parse(query);
        for(var i = 0, len = qArray.length; i < len; i++) {
            var queryItem = decodeURIComponent(qArray[i]).replace('=', '');
            if(/^\?/g.test(queryItem)) {
                debug('matched query: %s', queryItem) ;
                queryObj.q = queryItem;
                break;
            }
        }

        queryObj.m = qObj._mcss == 'true' || qObj._mcss == 'y';
        return queryObj;
    }
221943
function querystring(query) {
  var parser = /([^=?&]+)=?([^&]*)/g
    , result = {}
    , part;

  while (part = parser.exec(query)) {
    var key = decode(part[1])
      , value = decode(part[2]);

    //
    // Prevent overriding of existing properties. This ensures that build-in
    // methods like `toString` or __proto__ are not overriden by malicious
    // querystrings.
    //
    if (key in result) continue;
    result[key] = value;
  }

  return result;
}
1991
def _build_query_string(q, default_field=None, default_operator='AND'):
    
    def _is_phrase_search(query_string):
        clean_query = query_string.strip()
        return clean_query and clean_query.startswith('"') and clean_query.endswith('"')

    def _get_phrase(query_string):
        return query_string.strip().strip('"')

    if _is_phrase_search(q):
        query = {'match_phrase': {'_all': _get_phrase(q)}}
    else:
        query = {'query_string': {'query': q, 'default_operator': default_operator}}
        query['query_string'].update({'lenient': False} if default_field else {'default_field': default_field})

    return query
319435
def regex_query(expression):
    """"""
    def _regex(index, expression=expression):
        """Return store key for documents that satisfy expression."""
        pattern = re.compile(expression)
        return [
            store_key
            for value, store_keys
            in index.get_index().items()
            if (isinstance(value, six.string_types)
                and re.match(pattern, value))
            for store_key in store_keys
        ]

    return _regex
759812
def _query_gen(self):
        """"""
        return urlencode(self.__query__, safe=self.safe, querydelimiter=self.__querydelimiter__)
711931
def build_query_string(self, data):
        
        query_params = []
        keys_to_be_removed = []
        for key, value in data.items():
            if key not in ['version', 'restApi', 'resourcePath']:
                if key == 'addressLine':
                    query_params.append('{0}={1}'.format(key,
                                                         quote(value)))
                    keys_to_be_removed.append(key)
                else:
                    query_params.append('{0}={1}'.format(key,
                                                         value))
                    keys_to_be_removed.append(key)
        data['query'] = "&".join(query_params)
        for k in keys_to_be_removed:
            del data[k]
        return data
227646
def _matching_string(matched, string):
        
        if string is None:
            return string
        if IS_PY2:
            # pylint: disable=undefined-variable
            if isinstance(matched, text_type):
                return text_type(string)
        else:
            if isinstance(matched, bytes) and isinstance(string, str):
                return string.encode(locale.getpreferredencoding(False))
        return string
1270400
def _build_matches(matches, uuids, no_filtered, fastmode=False):
    """"""

    result = []

    for m in matches:
        mk = m[0].uuid if not fastmode else m[0]
        subset = [uuids[mk]]

        for id_ in m[1:]:
            uk = id_.uuid if not fastmode else id_
            u = uuids[uk]

            if u not in subset:
                subset.append(u)

        result.append(subset)

    result += no_filtered
    result.sort(key=len, reverse=True)

    sresult = []
    for r in result:
        r.sort(key=lambda id_: id_.uuid)
        sresult.append(r)

    return sresult