From af0f676ece887451466ccb09f2063b720b68feb9 Mon Sep 17 00:00:00 2001 From: Paula Date: Tue, 19 Dec 2023 16:36:07 +0100 Subject: [PATCH] Icon Validator --- .github/workflows/scripts/icon_validator.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/scripts/icon_validator.py b/.github/workflows/scripts/icon_validator.py index 82f0a70a..eceff712 100644 --- a/.github/workflows/scripts/icon_validator.py +++ b/.github/workflows/scripts/icon_validator.py @@ -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__':