posspack/.forgejo/scripts/update-wiki.py
Ashley Graves 4efd46bb97
Some checks failed
Update wiki / test (push) Failing after 12s
test
2024-07-27 15:38:21 +02:00

38 lines
874 B
Python

#!/usr/bin/env python
from pip._vendor import tomli
import glob
import os
def noop():
return
mods = dict()
for mod in glob.glob("pack/mods/*.toml"):
with open(mod, "r") as f:
data = tomli.load(f)
url = ""
# there has to be a better way to do this
if "modrinth" in data["update"]:
url = "https://modrinth.com/mod/" + data["update"]["modrinth"]["mod-id"]
elif "curseforge" in data["update"]:
url = "https://legacy.curseforge.com/projects/" + str(data["update"]["curseforge"]["project-id"])
moddata = dict()
moddata["side"] = data["side"]
moddata["url"] = url
mods[data["name"]] = moddata
with open("wiki/Modlist.md", "w") as f:
for mod in mods:
if mods[mod]["url"] != "":
f.write("- [" + mod + "](" + mods[mod] + ")")
else:
f.write("- " + mod)
f.write("(" + mods[mod]["side"] + ")")