forked from Soyweiser/CDDA-Wiki-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
materials.py
54 lines (50 loc) · 1.68 KB
/
materials.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import json
from pprint import pprint
from Tkinter import Tk
root = Tk()
root.withdraw()
#data is copied to clipboard, used for the http://cddawiki.chezzo.com/cdda_wiki/index.php?title=Materials page
with open('data/json/materials.json') as data_file:
data = json.load(data_file)
output = [ "" ]
for it in range(0, len(data)):
output.append("{{row/{{PAGENAME}}|mat=")
output.append(data[it]['ident'])
output.append("|name=")
output.append(data[it]['name'])
output.append("|bashdv=")
output.append(data[it]['bash_dmg_verb'])
output.append("|cutdv=")
output.append(data[it]['cut_dmg_verb'])
output.append("|dmgadj1=")
output.append(data[it]['dmg_adj'][0])
output.append("|dmgadj2=")
output.append(data[it]['dmg_adj'][1])
output.append("|dmgadj3=")
output.append(data[it]['dmg_adj'][2])
output.append("|dmgadj4=")
output.append(data[it]['dmg_adj'][3])
output.append("|density=")
output.append(str(data[it]['density']))
if('edible' in data[it]):
if(data[it]['edible'] == True):
output.append("|edible=Y")
if('soft' in data[it]):
if(data[it]['soft'] == True):
output.append("|soft=Y")
if('burn_products' in data[it]):
if (len(data[it]['burn_products']) > 0):
output.append("|burn_products=")
for ite in range (0, len(data[it]['burn_products'])):
if(ite > 0):
output.append(", ")
output.append(data[it]['burn_products'][ite][0])
output.append("}}\n\n")
text = "".join(output)
text.replace("\n", "\\n")
print text
root.clipboard_clear()
root.clipboard_append(text)
root.update()
root.destroy()
exit()