Skip to content

Commit 41541e9

Browse files
authored
check item categories used in requires instead of ignoring them (#159)
1 parent 8a1de58 commit 41541e9

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

src/DataValidation.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,21 @@ def checkItemNamesInLocationRequires():
2727
if item.lower() == "or" or item.lower() == "and" or item == ")" or item == "(":
2828
continue
2929
else:
30-
# it's just a category, so ignore it
30+
# if it's a category, validate that the category exists
3131
if '@' in item:
32+
item = item.replace("|", "")
33+
item_parts = item.split(":")
34+
item_name = item
35+
36+
if len(item_parts) > 1:
37+
item_name = item_parts[0]
38+
39+
item_name = item_name[1:]
40+
item_category_exists = len([item for item in DataValidation.item_table if item_name in item.get('category', [])]) > 0
41+
42+
if not item_category_exists:
43+
raise ValidationError("Item category %s is required by location %s but is misspelled or does not exist." % (item_name, location["name"]))
44+
3245
continue
3346

3447
item = item.replace("|", "")
@@ -90,8 +103,21 @@ def checkItemNamesInRegionRequires():
90103
if item.lower() == "or" or item.lower() == "and" or item == ")" or item == "(":
91104
continue
92105
else:
93-
# it's just a category, so ignore it
106+
# if it's a category, validate that the category exists
94107
if '@' in item:
108+
item = item.replace("|", "")
109+
item_parts = item.split(":")
110+
item_name = item
111+
112+
if len(item_parts) > 1:
113+
item_name = item_parts[0]
114+
115+
item_name = item_name[1:]
116+
item_category_exists = len([item for item in DataValidation.item_table if item_name in item.get('category', [])]) > 0
117+
118+
if not item_category_exists:
119+
raise ValidationError("Item category %s is required by region %s but is misspelled or does not exist." % (item_name, region_name))
120+
95121
continue
96122

97123
item = item.replace("|", "")

0 commit comments

Comments
 (0)