def _filter(self, **kwargs):
        params = self.extra_params.copy()
        headers = None
        uri = '/'.join([self.base_url, self.name])

        if kwargs:
            if 'since' in kwargs:
                val = kwargs['since']
                headers = self.prepare_filtering_date(val)
                del kwargs['since']

            def get_filter_params(key, value):
                last_key = key.split('_')[-1]
                if last_key.upper().endswith('ID'):
                    return 'Guid("%s")' % six.text_type(value)
                if key in self.BOOLEAN_FIELDS:
                    return 'true' if value else 'false'
                elif key in self.DATE_FIELDS:
                    return 'DateTime(%s,%s,%s)' % (value.year, value.month, value.day)
                elif key in self.DATETIME_FIELDS:
                    return value.isoformat()
                else:
                    return '"%s"' % six.text_type(value)

            def generate_param(key, value):
                parts = key.split("__")
                field = key.replace('_', '.')
                fmt = '%s==%s'
                if len(parts) == 2:
                    # support filters:
                    # Name__Contains=John becomes Name.Contains("John")
                    if parts[1] in ["contains", "startswith", "endswith"]:
                        field = parts[0]
                        fmt = ''.join(['%s.', parts[1], '(%s)'])
                    elif self.OPERATOR_MAPPINGS in parts[1]:
                        field = parts[0]
                        key = field
                        fmt = '%s' + self.OPERATOR_MAPPINGS[parts[1]] + '%s'
                    elif parts[1] in ["isnull"]:
                        sign = '=' if value else '!'
                        return '%s%s=null' % (parts[0], sign)
                    field = field.replace('_', '.')
                return fmt % (
                    field,
                    get_filter_params(key, value)
                )

            # Move any known parameter names to the query string
            KNOWN_PARAMETERS = ['order', 'offset', 'page', 'includeArchived']
            for param in KNOWN_PARAMETERS:
                if param in kwargs:
                    params[param] = kwargs.pop(param)

            filter_params = []

            if 'raw' in kwargs:
                raw = kwargs.pop('raw')
                filter_params.append(raw)

            # Treat any remaining arguments as filter predicates
            # Xero will break if you search without a check for null in the first position:
            # http://developer.xero.com/documentation/getting-started/http-requests-and-responses/#title3
            sortedkwargs = sorted(six.iteritems(kwargs),
                key=lambda item: -1 if 'isnull' in item[0] else 0)
            for key, value in sortedkwargs:
                filter_params.append(generate_param(key, value))

            if filter_params:
                params['where'] = '&&'.join(filter_params)

        return uri, params, 'get', None, headers, False
dataset/ETHPy150Open freakboy3742/pyxero/xero/basemanager.py/BaseManager._filter/swapped operands of `in`