posspack/.forgejo/scripts/update-wiki.py
Ashley Graves 9c7c9283a0
Some checks failed
Update wiki / test (push) Failing after 12s
test
2024-07-27 14:53:10 +02:00

38 lines
818 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
try:
print("MR: " + data.update.modrinth["mod-id"])
url = "https://modrinth.com/mod/" + data.update.modrinth["mod-id"]
except:
noop()
try:
print("CF: " + data.update.curseforge["mod-id"])
url = "http://dev.bukkit.org/bukkit-plugins/" + data.update.curseforge["mod-id"]
except:
noop()
mods[data.name] = url
with open("wiki/Modlist.md", "w") as f:
for mod in mods:
if mods[mod] != "":
f.write("- [" + mod + "](" + mods[mod] + ")\r\n")
else:
f.write("- " + mod + "\r\n")