Uses arguments to construct a list of xapian.Query's.
17172
def _query_from_term(self, term, field_name, filter_type, is_not):
        
        if field_name != 'content' and field_name not in self.backend.column:
            raise InvalidIndexError('field "%s" not indexed' % field_name)

        # It it is an AutoQuery, it has no filters
        # or others, thus we short-circuit the procedure.
        if isinstance(term, AutoQuery):
            if field_name != 'content':
                query = '%s:%s' % (field_name, term.prepare(self))
            else:
                query = term.prepare(self)
            return [self.backend.parse_query(query)]
        query_list = []

        # Handle `ValuesListQuerySet`.
        if hasattr(term, 'values_list'):
            term = list(term)

        if field_name == 'content':
            # content is the generic search:
            # force no field_name search
            # and the field_type to be 'text'.
            field_name = None
            field_type = 'text'

            # we don't know what is the type(term), so we parse it.
            # Ideally this would not be required, but
            # some filters currently depend on the term to make decisions.
            term = _to_xapian_term(term)

            query_list.append(self._filter_contains(term, field_name, field_type, is_not))
            # when filter has no filter_type, haystack uses
            # filter_type = 'content'. Here we remove it
            # since the above query is already doing this
            if filter_type == 'content':
                filter_type = None
        else:
            # get the field_type from the backend
            field_type = self.backend.schema[self.backend.column[field_name]]['type']

        # private fields don't accept 'contains' or 'startswith'
        # since they have no meaning.
        if filter_type in ('contains', 'startswith') and field_name in (ID, DJANGO_ID, DJANGO_CT):
            filter_type = 'exact'

        if field_type == 'text':
            # we don't know what type "term" is, but we know we are searching as text
            # so we parse it like that.
            # Ideally this would not be required since _term_query does it, but
            # some filters currently depend on the term to make decisions.
            if isinstance(term, list):
                term = [_to_xapian_term(term) for term in term]
            else:
                term = _to_xapian_term(term)

        # todo: we should check that the filter is valid for this field_type or raise InvalidIndexError
        if filter_type == 'contains':
            query_list.append(self._filter_contains(term, field_name, field_type, is_not))
        elif filter_type in ('content', 'exact'):
            query_list.append(self._filter_exact(term, field_name, field_type, is_not))
        elif filter_type == 'in':
            query_list.append(self._filter_in(term, field_name, field_type, is_not))
        elif filter_type == 'startswith':
            query_list.append(self._filter_startswith(term, field_name, field_type, is_not))
        elif filter_type == 'endswith':
            raise NotImplementedError("The Xapian search backend doesn't support endswith queries.")
        elif filter_type == 'gt':
            query_list.append(self._filter_gt(term, field_name, field_type, is_not))
        elif filter_type == 'gte':
            query_list.append(self._filter_gte(term, field_name, field_type, is_not))
        elif filter_type == 'lt':
            query_list.append(self._filter_lt(term, field_name, field_type, is_not))
        elif filter_type == 'lte':
            query_list.append(self._filter_lte(term, field_name, field_type, is_not))
        elif filter_type == 'range':
            query_list.append(self._filter_range(term, field_name, field_type, is_not))
        return query_list
418611
def _build_parmlist(self, parameters):
        

        args = []
        for key, value in parameters.items():
            if not value is None:
                # We always use the explicit-length keyname format, to reduce the chance
                # of requests failing due to unusual characters in parameter values.

                try:
                    classinfo = unicode
                except NameError:
                    classinfo = str

                if isinstance(value, classinfo):
                    key = '%s[%d]' % (key.upper(), len(value.encode('utf-8')))
                else:
                    key = '%s[%d]' % (key.upper(), len(str(value)))
                args.append('%s=%s' % (key, value))
        args.sort()
        parmlist = '&'.join(args)        
        return parmlist
1340143
def _create_entity_query_arguments(self, load_metadata: bool=True) -> List[str]:
        
        arguments = ["--acl", "--replicate", "--timestamp"]
        if load_metadata:
            arguments.append("--avu")
        return arguments
982178
def query_params(*es_query_params):
    

    def _wrapper(func):
        @wraps(func)
        def _wrapped(*args, **kwargs):
            params = {}
            if "params" in kwargs:
                params = kwargs.pop("params").copy()
            for p in es_query_params + GLOBAL_PARAMS:
                if p in kwargs:
                    v = kwargs.pop(p)
                    if v is not None:
                        params[p] = _escape(v)

            # don't treat ignore and request_timeout as other params to avoid escaping
            for p in ("ignore", "request_timeout"):
                if p in kwargs:
                    params[p] = kwargs.pop(p)
            return func(*args, params=params, **kwargs)

        return _wrapped

    return _wrapper
9570
def serialize_args(self):
        """"""

        args, kwargs = super(ListParameter, self).serialize_args()
        args.insert(0, [self.param_type.id, self.param_type.serialize_args()])
1161869
def SearchClients(query=None, context=None):
  """"""

  args = client_pb2.ApiSearchClientsArgs(query=query)

  items = context.SendIteratorRequest("SearchClients", args)
  return utils.MapItemsIterator(lambda data: Client(data=data, context=context),
                                items)
835005
def _query_and_op(self, tree, table, method_name, method_kwargs):
        
        result = []
        if tree.keys_in:
            if tree.using:
                raise SyntaxError("Cannot use USING with KEYS IN")
            keys = self._iter_where_in(tree)
        else:
            visitor = Visitor(self.reserved_words)
            (action, kwargs, _) = self._build_query(table, tree, visitor)
            attrs = [visitor.get_field(table.hash_key.name)]
            if table.range_key is not None:
                attrs.append(visitor.get_field(table.range_key.name))
            kwargs["attributes"] = attrs
            kwargs["expr_values"] = visitor.expression_values
            kwargs["alias"] = visitor.attribute_names
            # If there is no 'where' on this update/delete, check with the
            # caution_callback before proceeding.
            if (
                visitor.expression_values is None
                and callable(self.caution_callback)
                and not self.caution_callback(method_name)  # pylint: disable=E1102
            ):
                return False
            method = getattr(self.connection, action + "2")
            keys = method(table.name, **kwargs)
            if self._explaining:
                try:
                    list(keys)
                except ExplainSignal:
                    keys = [{}]

        method = getattr(self.connection, method_name + "2")
        count = 0
        for key in keys:
            try:
                ret = method(table.name, key, **method_kwargs)
            except CheckFailed:
                continue
            count += 1
            if ret:
                result.append(ret)
        if result:
            return result
        else:
            return count
564663
def build_args(args)
      args.each do |arg|
        arg.each do |key, value|
          case key.to_s
          when 'query_params'
            @query_params = value
          when 'request_headers'
            update_headers(value)
          when 'request_body'
            @request_body = value
          end
        end
      end
    end
585665
def map_arguments(self, arguments):
        
        if self.argument_mappings is None:
            return arguments

        return [f(a) for f, a in zip(self.argument_mappings, arguments)]
1344916
def make_query(self, *args, **kwargs):
        
        query = Q()  # initial is an empty query
        query_dict = self._build_query_dict(self.cleaned_data)
        if 'negate' in self.cleaned_data and self.cleaned_data['negate']:
            query = query & ~Q(**query_dict)
        else:
            query = query & Q(**query_dict)
        return query
1172030
def get_query_kwargs(**kwargs):
    """"""
    query_kwargs = {}

    query = kwargs.pop("query")
    if query:
        query_kwargs["query"] = query

    return query_kwargs
1132066
def build_projection_kwargs(cls, source, mapping):
        """"""
        return cls._map_arg_names(source, cls._default_attr_mapping + mapping)
784149
def gql(query_string, *args, **kwds):
  
  qry = _gql(query_string)
  if args or kwds:
    qry = qry._bind(args, kwds)
  return qry
453081
def expand_query(config, kwds):
    
    pattern = []
    for query in kwds.pop('pattern', []):
        expansion = config.search.alias.get(query)
        if expansion is None:
            pattern.append(query)
        else:
            parser = SafeArgumentParser()
            search_add_arguments(parser)
            ns = parser.parse_args(expansion)
            for (key, value) in vars(ns).items():
                if isinstance(value, (list, tuple)):
                    if not kwds.get(key):
                        kwds[key] = value
                    else:
                        kwds[key].extend(value)
                else:
                    kwds[key] = value
    kwds['pattern'] = pattern
    return config.search.kwds_adapter(kwds)
4041
def _match_serializers_by_query_arg(self, serializers):
        """"""
        # if the format query argument is present, match the serializer
        arg_name = current_app.config.get('REST_MIMETYPE_QUERY_ARG_NAME')
        if arg_name:
            arg_value = request.args.get(arg_name, None)

            if arg_value is None:
                return None
            # Search for the serializer matching the format
            try:
                return serializers[
                    self.serializers_query_aliases[arg_value]]
            except KeyError:  # either no serializer for this format
                return None

        return None
234712
@SafeVarargs
  public final QueryBuilder arguments(Object...args) {
    set(Param.QUERY_ARGS, "");
    queryArgs = args.clone();
    return this;
  }
1216130
def fromPostArgs(cls, args):
        
        self = cls()

        # Partition into "openid." args and bare args
        openid_args = {}
        for key, value in args.items():
            if isinstance(value, list):
                raise TypeError("query dict must have one value for each key, "
                                "not lists of values.  Query is %r" % (args,))


            try:
                prefix, rest = key.split('.', 1)
            except ValueError:
                prefix = None

            if prefix != 'openid':
                self.args[(BARE_NS, key)] = value
            else:
                openid_args[rest] = value

        self._fromOpenIDArgs(openid_args)

        return self