aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/testing/coverage_utils/__init__.py
blob: 3313eee7b5065de4cb5dce40afd7ca5f0369bee3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import re


def make_filter(prefix_filter, exclude_regexp):
    filters = []
    if prefix_filter:
        filters.append(lambda x: x.startswith(prefix_filter))
    if exclude_regexp:
        regexp = re.compile(exclude_regexp)
        filters.append(lambda x: not regexp.search(x))

    if filters:
        return lambda x: all(pred(x) for pred in filters)
    return lambda x: True