def filter(self, *args, **kw):
        """Adds a where clause with keyword args.

        Example::

            qs = qs.filter(category='trees')
            qs = qs.filter(Q(type=1) | Q(name='foo'))

        """
        clone = self._clone()
        for arg in args:
            if isinstance(arg, Q):
                clone.base_query['where'].append(
                    '(%s)' % (clone._flatten_q(arg, clone._kw_clause_from_q)))
            else:
                raise TypeError(
                    'non keyword args should be Q objects, got %r' % arg)
        for field, val in kw.items():
            clone.base_query['where'].append(clone._kw_filter_to_clause(field,
                                                                        val))
        return clone
dataset/ETHPy150Open mozilla/addons-server/src/olympia/editors/sql_model.py/RawSQLManager.filter/original