Skip to content

Commit

Permalink
Icon Validator
Browse files Browse the repository at this point in the history
  • Loading branch information
enthec-opensource committed Dec 19, 2023
1 parent 5bc3654 commit af0f676
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/scripts/icon_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,26 @@ def __init__(self):
self._FULL_IMAGES_DIR: Final[pathlib.Path] = pathlib.Path(self._SOURCE_DIR).joinpath(self._IMAGES_DIR).joinpath(self._ICONS_DIR)

def validate(self) -> None:
json_icons: list[str] = self.get_json_icons()
for file in self._FULL_IMAGES_DIR.iterdir():
if not self.validate_icon(file.name):
if file.name not in json_icons:
raise InvalidStructureException(f"{file.name} must be used, {file} isn't used!")

def validate_icon(self, icon: str) -> bool:
def get_json_icons(self) -> list[str]:
letters: list[str] = list(string.ascii_lowercase)
letters.insert(0, '_')
json_icons: list[str] = []

for letter in letters:
icon_path: pathlib.Path = self._FULL_TECH_DIR.joinpath(f"{letter}.json")
with icon_path.open("r", encoding="utf8") as json_file:
technologies: dict = json.load(json_file)

for tech, data in technologies.items():
for key, value in data.items():
if 'icon' == key:
if icon == data['icon']:
return True
else:
break
return False
print(value)
json_icons.append(value)
return json_icons


if __name__ == '__main__':
Expand Down

0 comments on commit af0f676

Please sign in to comment.