in tools/validator.py [0:0]
def _validate_file_name(file_path: str) -> None:
"""Checks that the file name is allowed.
Args:
file_path: Relative path to a file.
Raises:
MarkdownDocumentationError:
- if the path is invalid since it e.g. starts with a dot.
- if the path is forbidden since it cannot be used by the SavedModel e.g.
when "vocab.txt" is located in "variables/" and not in "assets/".
"""
if not PATH_PATTERN.fullmatch(file_path):
raise MarkdownDocumentationError(f"Invalid filepath in asset: {file_path}")
if not any(
fnmatch.fnmatch(file_path, pattern)
for pattern in ALLOWED_SAVED_MODEL_PATHS):
raise MarkdownDocumentationError(
f"File cannot be used by SavedModel: {file_path}")