-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdump_json.py
56 lines (45 loc) · 2.1 KB
/
dump_json.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
55
56
import datamodel
import os
import json
data = {}
for filename in os.listdir('template/particles'):
particle = datamodel.load('template/particles/' + filename)
print('\n')
print(filename)
particleFile = open('template/particles/' + filename, "r+b")
data[filename] = {}
for ele in particle.find_elements(elemtype="DmeParticleSystemDefinition"):
print('\n')
print(ele.name)
for operator in ele.get('operators'):
if(operator.name == "Color Fade"):
if ele.name not in data[filename]:
data[filename][ele.name] = {}
print("color_fade")
data[filename][ele.name]['color_fade'] = operator.get("color_fade")
print(operator.get("color_fade")[0], end = '')
print(", ", end = '')
print(operator.get("color_fade")[1], end = '')
print(", ", end = '')
print(operator.get("color_fade")[2])
for initializer in ele.get('initializers'):
if(initializer.name == "Color Random"):
if ele.name not in data[filename]:
data[filename][ele.name] = {}
print("color1")
data[filename][ele.name]['color1'] = initializer.get("color1")
print(initializer.get("color1")[0], end = '')
print(", ", end = '')
print(initializer.get("color1")[1], end = '')
print(", ", end = '')
print(initializer.get("color1")[2])
print("color2")
data[filename][ele.name]['color2'] = initializer.get("color2")
print(initializer.get("color2")[0], end = '')
print(", ", end = '')
print(initializer.get("color2")[1], end = '')
print(", ", end = '')
print(initializer.get("color2")[2])
particleFile.close()
with open('output.json', 'w') as outfile:
json.dump(data, outfile)