File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff 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
381394class Readme :
382395 essential_headers = {
Original file line number Diff line number Diff 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
8288def all_samples (path : str ):
8389 """
You can’t perform that action at this time.
0 commit comments