in tools/validator.py [0:0]
def _consume_metadata(self) -> None:
"""Consumes all metadata."""
while self._current_index < len(
self._lines) and (not self._lines[self._current_index].startswith("#")):
if not self._lines[self._current_index]:
# Empty line is ok.
self._current_index += 1
continue
match = re.match(METADATA_LINE_PATTERN, self._lines[self._current_index])
if match:
# Add found metadata.
groups = match.groupdict()
key = groups.get("key")
value = groups.get("value")
if key is None or value is None:
raise MarkdownDocumentationError(
f"(key, value) must not be None but got ({key}, {value}).")
key = key.strip()
value = value.strip()
if key not in self._parsed_metadata:
self._parsed_metadata[key] = set()
self._parsed_metadata[key].add(value)
self._current_index += 1
continue
if self._lines[self._current_index].startswith("[![Icon URL]]"):
# Icon for publishers.
self._current_index += 1
continue
# Not an empty line and not expected metadata.
raise MarkdownDocumentationError(
f"Unexpected line found: '{self._lines[self._current_index]}'. "
"Please refer to "
"https://www.tensorflow.org/hub/writing_model_documentation for "
"information about markdown format.")