def contains_non_printable_characters(path: str | Path) -> bool:
    r"""Check if path contains non-printable characters.

    Args:
        path: Path to check

    Returns:
        ``True`` if path contains non-printable chars, ``False`` otherwise

    Example:
        >>> contains_non_printable_characters("normal.txt")
        False
        >>> contains_non_printable_characters("test\x00.txt")
        True
    """
    printable_pattern = re.compile(r"^[\x20-\x7E]+$")
    return not printable_pattern.match(str(path))
Check if path contains non-printable characters.

    Args:
        path: Path to check

    Returns:
        ``True`` if path contains non-printable chars, ``False`` otherwise

    Example:
        >>> contains_non_printable_characters("normal.txt")
        False
        >>> contains_non_printable_characters("test\x00.txt")
        True
    
src/anomalib/data/utils/path.py