posspack/.forgejo/scripts/update-wiki.py

47 lines
1.2 KiB
Python
Raw Normal View History

2024-07-27 14:23:23 +02:00
#!/usr/bin/env python
2024-07-27 14:41:57 +02:00
from pip._vendor import tomli
2024-07-27 14:28:16 +02:00
import glob
import os
2024-07-27 14:52:33 +02:00
def noop():
return
2024-07-27 14:48:06 +02:00
mods = dict()
2024-07-27 14:31:45 +02:00
for mod in glob.glob("pack/mods/*.toml"):
2024-07-27 14:44:02 +02:00
with open(mod, "r") as f:
2024-07-27 14:41:57 +02:00
data = tomli.load(f)
2024-07-27 15:43:27 +02:00
moddata = dict()
moddata["url"] = ""
2024-07-27 14:52:33 +02:00
2024-07-27 14:55:11 +02:00
if "modrinth" in data["update"]:
2024-07-27 15:43:27 +02:00
moddata["url"] = "https://modrinth.com/mod/" + data["update"]["modrinth"]["mod-id"]
moddata["site"] = "Modrinth"
2024-07-27 14:55:11 +02:00
elif "curseforge" in data["update"]:
2024-07-27 15:43:27 +02:00
moddata["url"] = "https://legacy.curseforge.com/projects/" + str(data["update"]["curseforge"]["project-id"])
moddata["site"] = "CurseForge"
2024-07-27 14:52:33 +02:00
2024-07-27 15:38:21 +02:00
moddata["side"] = data["side"]
mods[data["name"]] = moddata
2024-07-27 14:48:06 +02:00
with open("wiki/Modlist.md", "w") as f:
2024-07-27 15:43:27 +02:00
f.write("<table>")
f.write("\r\n<tr>")
f.write("<th>Name</th>")
f.write("<th>Side</th>")
f.write("<th>Link</th>")
f.write("</tr>\r\n")
2024-07-27 14:48:06 +02:00
for mod in mods:
2024-07-27 15:43:27 +02:00
f.write("\r\n<tr>")
f.write("<td>" + mod + "</td>")
f.write("<td>" + mods[mod]["side"] + "</td>")
2024-07-27 15:38:21 +02:00
if mods[mod]["url"] != "":
2024-07-27 15:44:21 +02:00
f.write("<td><a href=\"" + mods[mod]["url"] + "\">" + mods[mod]["site"] + "</a></td>")
2024-07-27 14:49:15 +02:00
else:
2024-07-27 15:43:27 +02:00
f.write("<td>N/A</td>")
f.write("\r\n<tr>")