import re


def _check_pattern(line, pattern, ignore_pattern):
    """
    Check a given line against both a pattern and an ignore_pattern and return
    True or False based on whether that line should be used.
    """
    keep = False

    if pattern is None:
        keep = True
    elif re.match(pattern, line):
        keep = True

    if ignore_pattern is not None and re.match(ignore_pattern, line):
        keep = False

    return keep