Get metadata from meta.json, if it exists #12

Merged
Toast merged 5 commits from localMetadata into main 2025-05-30 22:00:06 +02:00
Showing only changes of commit da8749e1a7 - Show all commits

View file

@ -24,12 +24,18 @@ class Mod:
# Mod metadata # Mod metadata
@property @property
def name(self) -> str | None: def name(self) -> str | None:
if self.__has_meta_json:
if "name" in self.__meta:
return self.__meta.get("name", str)
if "name" not in self.__config: if "name" not in self.__config:
return None return None
return self.__config.get("name", str) return self.__config.get("name", str)
@property @property
def description(self) -> str | None: def description(self) -> str | None:
if self.__has_meta_json:
if "description" in self.__meta:
return self.__meta.get("description", str)
if "description" not in self.__config.keys(): if "description" not in self.__config.keys():
return None return None
else: else:
@ -37,6 +43,11 @@ class Mod:
@property @property
def author(self) -> str | None: def author(self) -> str | None:
# TODO: return list with authors
if self.__has_meta_json:
if "authors" in self.__meta:
authors: list[str] = self.__meta.get("authors", list[str])
return ", ".join(authors)
if "author" not in self.__config: if "author" not in self.__config:
return None return None
return self.__config.get("author", str) return self.__config.get("author", str)