Last active
April 18, 2016 22:30
-
-
Save Yoplitein/53cfa48a8f2d309da42001ad07631d71 to your computer and use it in GitHub Desktop.
Generates a list of mods in a Minecraft instance. Run from parent of mods directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import os | |
import re | |
import zipfile | |
nameRe = re.compile(r'"name"\s*:\s*"([^"]+)"') | |
mods = [] | |
def guess(jar): | |
return os.path.split(jar)[-1].split("-", 1)[0] | |
for jar in glob.glob("mods/*.jar"): | |
zip = zipfile.ZipFile(jar) | |
info = zip.read("mcmod.info").decode("utf-8") | |
matches = re.findall(nameRe, info) | |
if len(matches) == 0: | |
mods.append(guess(jar)) | |
continue | |
for name in matches: | |
mods.append(name) | |
print("\n".join(mods)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment