Mod: read name, description and authors from json if available

This commit is contained in:
Toast 2025-05-29 18:50:01 +02:00
parent 4d22e68a9b
commit 902227a8bd

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)