def _calculate_unpack_filter(cls, includes=None, excludes=None, spec=None):
    """Take regex patterns and return a filter function.

    :param list includes: List of include patterns to pass to _file_filter.
    :param list excludes: List of exclude patterns to pass to _file_filter.
    """
    include_patterns = cls.compile_patterns(includes or [],
                                            field_name='include_patterns',
                                            spec=spec)
    logger.debug('include_patterns: {}'
                 .format(list(p.pattern for p in include_patterns)))
    exclude_patterns = cls.compile_patterns(excludes or [],
                                            field_name='exclude_patterns',
                                            spec=spec)
    logger.debug('exclude_patterns: {}'
                 .format(list(p.pattern for p in exclude_patterns)))
    return lambda f: cls._file_filter(f, include_patterns, exclude_patterns)
Take regex patterns and return a filter function.

    :param list includes: List of include patterns to pass to _file_filter.
    :param list excludes: List of exclude patterns to pass to _file_filter.