Skip to content

Instantly share code, notes, and snippets.

@auxiliary-character
Last active December 26, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save auxiliary-character/7077516 to your computer and use it in GitHub Desktop.
Save auxiliary-character/7077516 to your computer and use it in GitHub Desktop.
#!/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