Skip to content

Commit ca0b8e0

Browse files
committed
Add category check.
1 parent a340154 commit ca0b8e0

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Scripts/CI/common.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,19 @@ def flush_to_json_string(self) -> str:
377377

378378
return json.dumps(data, indent=4, sort_keys=True)
379379

380+
def check_category(self) -> None:
381+
"""
382+
Check if
383+
1. metadata contains a category.
384+
2. category is valid.
385+
386+
:return: None. Throws if exception occurs.
387+
"""
388+
if not self.category:
389+
raise Exception(f'Error category - Missing category.')
390+
elif self.category not in categories:
391+
raise Exception(f'Error category - Invalid category - "{self.category}".')
392+
380393

381394
class Readme:
382395
essential_headers = {

Scripts/CI/metadata_checker.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ def run_check(path: str) -> None:
7878
diff = '\n'.join(unified_diff(expected, actual))
7979
raise Exception(f'Error inconsistent metadata - {path} - {diff}')
8080

81+
# 4. Check category.
82+
try:
83+
checker.check_category()
84+
except Exception as err:
85+
raise Exception(f'{checker.folder_path} - {err}')
86+
8187

8288
def all_samples(path: str):
8389
"""

0 commit comments

Comments
 (0)