def get_declared_filters(bases, attrs, with_base_filters=True):
    filters = []
    for (filter_name, obj) in list(attrs.items()):
        if isinstance(obj, Filter):
            obj = attrs.pop(filter_name)
            if (getattr(obj, 'name', None) is None):
                obj.name = filter_name
            filters.append((filter_name, obj))
    filters.sort(key=(lambda x: x[1].creation_counter))
    if with_base_filters:
        for base in bases[::(- 1)]:
            if hasattr(base, 'base_filters'):
                filters = (list(base.base_filters.items()) + filters)
    else:
        for base in bases[::(- 1)]:
            if hasattr(base, 'declared_filters'):
                filters = (list(base.declared_filters.items()) + filters)
    return OrderedDict(filters)
def get_declared_filters(bases, attrs, with_base_filters=True):
    filters = []
    for (filter_name, obj) in list(attrs.items()):
        if isinstance(obj, Filter):
            obj = attrs.pop(filter_name)
            if (getattr(obj, 'name', None) is None):
                obj.name = filter_name
            filters.append((filter_name, obj))
    filters.sort(key=(lambda x: x[1].creation_counter))
    if with_base_filters:
        for base in bases[::(- 1)]:
            if hasattr(base, 'base_filters'):
                filters = (list(base.base_filters.items()) + filters)
    else:
        for base in bases[::(- 1)]:
            if hasattr(base, 'declared_filters'):
                filters = (list(base.declared_filters.items()) + filters)
    return OrderedDict(filters)