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

39 lines
818 B
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 14:48:06 +02:00
url = ""
2024-07-27 14:52:33 +02:00
# there has to be a better way to do this
try:
2024-07-27 14:52:51 +02:00
print("MR: " + data.update.modrinth["mod-id"])
2024-07-27 14:48:06 +02:00
url = "https://modrinth.com/mod/" + data.update.modrinth["mod-id"]
2024-07-27 14:53:10 +02:00
except:
2024-07-27 14:52:33 +02:00
noop()
try:
2024-07-27 14:52:51 +02:00
print("CF: " + data.update.curseforge["mod-id"])
2024-07-27 14:52:33 +02:00
url = "http://dev.bukkit.org/bukkit-plugins/" + data.update.curseforge["mod-id"]
2024-07-27 14:53:10 +02:00
except:
2024-07-27 14:52:33 +02:00
noop()
2024-07-27 14:48:06 +02:00
mods[data.name] = url
with open("wiki/Modlist.md", "w") as f:
for mod in mods:
2024-07-27 14:49:15 +02:00
if mods[mod] != "":
f.write("- [" + mod + "](" + mods[mod] + ")\r\n")
else:
f.write("- " + mod + "\r\n")