from pathlib import Path
import re


def matches_filepath_pattern(filepath: Path, pattern: str) -> bool:
    """
    Check if filepath matches pattern

    Parameters
    ----------
    filepath
        The filepath to check

    pattern
        The pattern to search

    Returns
    -------
    rc
        A boolean indicating whether the pattern has been found in the filepath
    """

    assert isinstance(filepath, Path)  # noqa

    result = re.search(pattern, str(filepath))

    return True if result is not None else False