Add log parsing capability to capture only enabled mods (#93)

* Add log parsing capability to capture only enabled mods

* Fix Python Black format complain

* Add fallback so that old logs without mod status can still be recognized

* stop Python Black complain again
This commit is contained in:
WilliamWsyHK 2024-05-15 22:59:37 +08:00 committed by GitHub
parent 41bc653bea
commit 9e395ffa10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -377,13 +377,19 @@ class LogAnalyser:
raise NotImplementedError(key)
def __get_mods(self):
mods_regex = re.compile(r"Found mod\s\'(.+?)\'\s(\[.+?\])")
mods_regex = re.compile(
r"Found\s(enabled|disabled)?\s?mod\s\'(.+?)\'\s(\[.+?\])"
)
matches = re.findall(mods_regex, self._log_text)
if matches:
mods = [{"mod": match[0], "status": match[1]} for match in matches]
mods = [
{"mod": match[1], "status": match[0], "type": match[2]}
for match in matches
]
mods_status = [
f" {i['mod']} ({'ExeFS' if i['status'] == '[E]' else 'RomFS'})"
f" {i['mod']} ({'ExeFS' if i['type'] == '[E]' else 'RomFS'})"
for i in mods
if i["status"] == "" or i["status"] == "enabled"
]
# Remove duplicated mods from output
mods_status = list(dict.fromkeys(mods_status))