See ``QuerySet.filter`` for full documentation

        This adds support for ``destination_object`` and ``source_object``
        as kwargs.  This converts those objects into the values necessary
        to handle the ``GenericForeignKey`` fields.
973500
def filter(self, destination_object=None, source_object=None, **kwargs):
        
        if destination_object:
            kwargs.update({
                "destination_id": destination_object.pk,
                "destination_type": get_for_model(destination_object),
            })
        if source_object:
            kwargs.update({
                "source_id": source_object.pk,
                "source_type": get_for_model(source_object),
            })
        return super(RelatedContentQuerySet, self).filter(**kwargs)
145664
def dicts_filter(dicts_object, field_to_filter, value_of_filter):
    
    lambda_query = lambda value: value[field_to_filter] == value_of_filter

    filtered_coin = filter(lambda_query, dicts_object)
    selected_coins = list(filtered_coin)
    #if not selected_coin: #Empty list, no coin found
    #    raise AttributeError('attribute %s not found' % attr)
    return selected_coins
908042
def filter_queryset(self, attrs, queryset):
        
        # If this is an update, then any unprovided field should
        # have it's value set based on the existing instance attribute.
        if self.instance is not None:
            for field_name in self.fields:
                if field_name not in attrs:
                    attrs[field_name] = getattr(self.instance, field_name)

        # Determine the filter keyword arguments and filter the queryset.
        filter_kwargs = {
            field_name: attrs[field_name]
            for field_name in self.fields
        }
        return queryset.filter(**filter_kwargs)
781016
def get_filter_qobj(self, keys=None):
    
    # only care about columns in aggregates right?
    cols = set()
    for agg in self.select.aggregates:
        cols.update(agg.cols)
    sels = [SelectExpr(col, [col], col, None) for col in cols]
    select = Select(sels)
    where = list(self.where)
    if keys:
      keys = list(keys)
      keys = map(sqlize, list(keys))
      expr = self.select.nonaggs[0].expr

      clause = []
      if None in keys:
        clause.append("%s is null" % expr)
      if len([k for k in keys if k is not None]) > 0:
        clause.append("%s in %%s" % expr)
      clause = " or ".join(clause)
      where.append(clause)
    else:
      where.append( '%s = %%s' % (self.select.nonaggs[0].expr ) )
    q = Query(self.db, select, self.fr, where)
    return q
1179768
def filter_by(self, **kwargs):
        
        ret = self.__class__(
            columns=self.columns, row_columns=self.row_columns, tab=self.tab,
            key_on=self.key_on)
        for row in self:
            if False not in [row[k] == v for k, v in kwargs.items()]:
                ret.append(row)
        return ret
592616
def _filter_queryset(self, queryset):
        
        entities = self.request.query_params.getlist('entity')
        labels = self.request.query_params.getlist('label')
        positions = self.request.query_params.getlist('position')

        if labels and len(labels) != len(entities):
            raise exceptions.ParseError(
                'If `labels` query parameter is given, also `entities` '
                'must be given and they must be of the same length.'
            )

        if positions and len(positions) != len(entities):
            raise exceptions.ParseError(
                'If `positions` query parameter is given, also `entities` '
                'must be given and they must be of the same length.'
            )

        if entities:
            for entity, label, position in zip_longest(entities, labels, positions):
                filter_params = {'entities__pk': entity}
                if label:
                    filter_params['relationpartition__label'] = label
                if position:
                    filter_params['relationpartition__position'] = position

                queryset = queryset.filter(**filter_params)

        return queryset
839494
function delegateFilter(filterContext) {
    if (isFunction(filterContext.sourceValue)) {
        var func = filterContext.sourceValue;
        var source = filterContext.source;
        filterContext.sourceValue = function() {
            return fastApply(func, source, arguments);
        };
    }
    return true;
}
313626
def _filter_or_exclude(self, negate, *args, **kwargs):
        
        from .models import Translation

        new_args = self.get_cleaned_args(args)
        new_kwargs = self.get_cleaned_kwargs(kwargs)

        translation_args = self.get_translation_args(args)
        translation_kwargs = self.get_translation_kwargs(kwargs)

        has_linguist_args = self.has_linguist_args(args)
        has_linguist_kwargs = self.has_linguist_kwargs(kwargs)

        if translation_args or translation_kwargs:
            ids = list(
                set(
                    Translation.objects.filter(
                        *translation_args, **translation_kwargs
                    ).values_list("object_id", flat=True)
                )
            )
            if ids:
                new_kwargs["id__in"] = ids

        has_kwargs = has_linguist_kwargs and not (new_kwargs or new_args)
        has_args = has_linguist_args and not (new_args or new_kwargs)

        # No translations but we looked for translations?
        # Returns empty queryset.
        if has_kwargs or has_args:
            return self._clone().none()

        return super(QuerySetMixin, self)._filter_or_exclude(
            negate, *new_args, **new_kwargs
        )
628895
def filter(self, *args, **kwargs):
        
        clone = self._clone()
        for f in args:
            clone.filter_obj.add_filter(f)
        for key, value in kwargs.items():
            clone.filter_obj.add_filter_param(key, value)
        return clone
87059
def filter(self, value=None, model=None, context=None):
        
        if value is None:
            return value
        for filter_obj in self.filters:
            value = filter_obj.filter(
                value=value,
                model=model,
                context=context if self.use_context else None
            )
        return value
871128
def aggregate(self, *args, **kwargs):
        
        if self.query.distinct_fields:
            raise NotImplementedError("aggregate() + distinct(fields) not implemented.")
        for arg in args:
            # The default_alias property may raise a TypeError, so we use
            # a try/except construct rather than hasattr in order to remain
            # consistent between PY2 and PY3 (hasattr would swallow
            # the TypeError on PY2).
            try:
                arg.default_alias
            except (AttributeError, TypeError):
                raise TypeError("Complex aggregates require an alias")
            kwargs[arg.default_alias] = arg

        if django.VERSION < (2, 0):
            query = self.query.clone(CTEAggregateQuery)
        else:
            query = self.query.chain(CTEAggregateQuery)
        for (alias, aggregate_expr) in kwargs.items():
            query.add_annotation(aggregate_expr, alias, is_summary=True)
            if not query.annotations[alias].contains_aggregate:
                raise TypeError("%s is not an aggregate expression" % alias)
        return query.get_aggregation(self.db, kwargs.keys())
1110837
def add_query_kwargs(kwargs, visitor, constraints, index):
    
    (query_const, filter_const) = constraints.remove_index(index)
    kwargs["key_condition_expr"] = query_const.build(visitor)
    if filter_const:
        kwargs["filter"] = filter_const.build(visitor)
    if index.name != "TABLE":
        kwargs["index"] = index.name
1297038
def filter_(stream_spec, filter_name, *args, **kwargs):
    
    return filter(stream_spec, filter_name, *args, **kwargs)
1223700
def mkCompoundFilter(parts):
    
    # Separate into a list of callables and a list of filter objects
    transformers = []
    filters = []
    for subfilter in parts:
        try:
            subfilter = list(subfilter)
        except TypeError:
            # If it's not an iterable
            if hasattr(subfilter, 'getServiceEndpoints'):
                # It's a full filter
                filters.append(subfilter)
            elif hasattr(subfilter, 'fromBasicServiceEndpoint'):
                # It's an endpoint object, so put its endpoint
                # conversion attribute into the list of endpoint
                # transformers
                transformers.append(subfilter.fromBasicServiceEndpoint)
            elif isinstance(subfilter, collections.Callable):
                # It's a simple callable, so add it to the list of
                # endpoint transformers
                transformers.append(subfilter)
            else:
                raise filter_type_error
        else:
            filters.append(mkCompoundFilter(subfilter))

    if transformers:
        filters.append(TransformFilterMaker(transformers))

    if len(filters) == 1:
        return filters[0]
    else:
        return CompoundFilter(filters)
518348
def _normalise_key_values(filter_obj, attr_map=None):
    
    new_filter = {}
    for key, constraints in filter_obj.items():
        aliased_key = key
        if attr_map is not None:
            aliased_key = attr_map.get(key)
            if aliased_key is None:
                raise CloudValueError(
                    'Invalid key %r for filter attribute; must be one of:\n%s' % (
                        key,
                        attr_map.keys()
                    )
                )
        if not isinstance(constraints, dict):
            constraints = {'eq': constraints}
        for operator, value in constraints.items():
            # FIXME: deprecate this $ nonsense
            canonical_operator = FILTER_OPERATOR_ALIASES.get(operator.lstrip('$'))
            if canonical_operator is None:
                raise CloudValueError(
                    'Invalid operator %r for filter key %s; must be one of:\n%s' % (
                        operator,
                        key,
                        FILTER_OPERATOR_ALIASES.keys()
                    )
                )
            canonical_key = str('%s__%s' % (aliased_key, canonical_operator))
            new_filter[canonical_key] = _normalise_value(value)
    return new_filter
83360
def get(cls, *args, **kwargs):
        
        if len(args) == 1:  # Guess it's a pk
            pk = args[0]
        elif kwargs:
            # special case to check for a simple pk
            if len(kwargs) == 1 and cls._field_is_pk(list(kwargs.keys())[0]):
                pk = list(kwargs.values())[0]
            else:  # case with many filters
                result = cls.collection(**kwargs).sort(by='nosort')
                if len(result) == 0:
                    raise DoesNotExist(u"No object matching filter: %s" % kwargs)
                elif len(result) > 1:
                    raise ValueError(u"More than one object matching filter: %s" % kwargs)
                else:
                    try:
                        pk = result[0]
                    except IndexError:
                        # object was deleted between the `len` check and now
                        raise DoesNotExist(u"No object matching filter: %s" % kwargs)

        else:
            raise ValueError("Invalid `get` usage with args %s and kwargs %s" % (args, kwargs))
        return cls(pk)
207207
def filterkeys(predicate, dict_):
    
    predicate = bool if predicate is None else ensure_callable(predicate)
    ensure_mapping(dict_)
    return dict_.__class__((k, v) for k, v in iteritems(dict_) if predicate(k))