def general_filter_callback(general_filter, obj):
    if isinstance(general_filter, list):
        if not general_filter:
            return True
        return any([
            general_filter_callback(item, obj)
            for item in general_filter
        ])
    elif isinstance(general_filter, dict):
        if 'resp_eq' in general_filter:
            if not _obj_equal_or_subset(
                general_filter['resp_eq'], obj
            ):
                return False
        if 'resp_in' in general_filter:
            in_filters = general_filter['resp_in']
            if not any([
                _obj_equal_or_subset(in_filer, obj)
                for in_filer in in_filters
            ]):
                return False
        if 'resp_lt' in general_filter:
            if obj >= general_filter['resp_lt']:
                return False
        if 'resp_le' in general_filter:
            if obj > general_filter['resp_le']:
                return False
        if 'resp_gt' in general_filter:
            if obj <= general_filter['resp_gt']:
                return False
        if 'resp_ge' in general_filter:
            if obj < general_filter['resp_gt']:
                return False
        if 'resp_match' in general_filter:
            if not re.match(general_filter['resp_match'], obj):
                return False
        if 'resp_range' in general_filter:
            resp_range = general_filter['resp_range']
            if not isinstance(resp_range, list):
                resp_range = [resp_range]
            in_range = False
            for range_start, range_end in resp_range:
                if range_start <= obj <= range_end:
                    in_range = True
            if not in_range:
                return False
        return True
    else:
        return True
Mark the article as useful.
dataset/ETHPy150Open openstack/compass-core/compass/db/api/utils.py/general_filter_callback--crossover with--dataset/ETHPy150Open ducksboard/libsaas/libsaas/services/uservoice/articles.py/Article.useful