-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathformat_recipes.py
29 lines (24 loc) · 1020 Bytes
/
format_recipes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import xml.etree.ElementTree as et
import sys
if __name__ == "__main__":
if len(sys.argv[1]) > 0:
f = sys.argv[1]
else:
f = "D:\perforce\GameSDK\Scripts\Crafting\Recipes.xml"
tree = et.parse(f)
root = tree.getroot()
recipes = tree.findall("recipe")
file = open("formatted_recipes.txt", "w+")
for recipe in recipes:
recipe_name = recipe.attrib["name"]
for con_time in recipe:
construction_time = con_time.attrib["time"]
item_name = con_time.findall("item")[0].attrib["name"]
mats = con_time.findall("material")
materials = set()
file.write("Item Name: " + item_name + "\n")
file.write("Time to Construct: " + construction_time + "\n")
file.write("Name of Recipe: " + recipe_name + "\n")
for mat in mats:
file.write("Mats Needed: " + mat.attrib["name"] + "\n")
file.write("---------------------" + "\n")