from enum import Enum, auto class resource_name(Enum): DONT_STARVE_MINI_PNG = auto() DONT_STARVE_TOGETHER_MINI_PNG = auto() SUN_SVG = auto() MOON_SVG = auto() MOON2_SVG = auto() class ResourceError(Exception): """ Custom Exception for missing resource uses """ def __init__(self, resource: resource_name, message: str): self.resourceName = resource self.message = message super().__init__(self.message) class resources: IMAGE_PATHS: dict def __init__(self, *args, **kwargs): self.IMAGE_PATHS = dict() self.IMAGE_PATHS[resource_name.DONT_STARVE_MINI_PNG] = ":/assets/dont_starve_mini.svg" self.IMAGE_PATHS[resource_name.DONT_STARVE_TOGETHER_MINI_PNG] = ":/assets/DontStarveTogether_mini.png" self.IMAGE_PATHS[resource_name.SUN_SVG] = ":/assets/sun.svg" self.IMAGE_PATHS[resource_name.MOON_SVG] = ":/assets/moon.svg" self.IMAGE_PATHS[resource_name.MOON2_SVG] = ":/assets/moon2.svg" def getImagePath(self, res_name: resource_name) -> str: """ Output of real path of assets Args: res_name (resource_name): Enum-Name of resource Raises: ResourceError: Throws this error if resource is unknown or not registered (in resource_names) Returns: str: relativ-Path to resource """ if res_name in self.IMAGE_PATHS: return self.IMAGE_PATHS[res_name] else: raise ResourceError( resource=res_name, message="Error: Resource unknown." )