Last active
December 26, 2015 02:19
-
-
Save auxiliary-character/7077516 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python3 | |
import xml.etree.ElementTree as etree | |
import readline | |
attribs=["name","version","url","file","website","donation","type","server","optional","download","description","done"] | |
def addTags(mods): | |
notDone = True | |
while notDone: | |
newMod = {} | |
for param in attribs: | |
response=input(param+"? ") | |
if param == "done" and response == "yes": | |
if response == "yes": | |
notDone=False | |
mods.append(etree.Element("mod",attrib=newMod)) | |
elif response != "": | |
newMod[param]=response | |
def main(): | |
tree = etree.parse(sys.argv[1]) | |
root=tree.getroot() | |
for tag in root.getchildren(): | |
if tag.tag == "mods": | |
mods=tag | |
addTags(mods) | |
tag=mods | |
tree.write(sys.argv[1]) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment