Source code for beansoup.importers.mixins
"""Mixins for importer classes."""
[docs]class FilterChain:
"""A mixin to pass imported entries through a pipeline of filters.
This mixin modifies the extract method of a concrete instance of
ImporterProtocol to run the extracted entries through a chain of
arbitrary filters.
"""
def __init__(self, *args, **kwargs):
"""Set up the filter chain and pass the rest of the arguments to the
base class.
Args:
filters: A list of callables taking a list of entries and returning
a subset of them.
"""
self.filters = kwargs.pop('filters', [])
super(FilterChain, self).__init__(*args, **kwargs)