-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmanifest-to-parameters.py
More file actions
executable file
·37 lines (32 loc) · 1017 Bytes
/
manifest-to-parameters.py
File metadata and controls
executable file
·37 lines (32 loc) · 1017 Bytes
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
#!/usr/bin/env python
from __future__ import print_function
import sys
import lxml.etree
f = open(sys.argv[1],'r')
contents = f.read()
f.close()
root = lxml.etree.fromstring(contents)
def convert(p,v):
if v in [ "True","true" ]:
v = 1
elif v in [ "False","false" ]:
v = 0
elif v == None:
return ""
return v
# Find our node and dump any labels:
for elm in root.getchildren():
if elm.tag.endswith("}label"):
print("%s=%s" % (elm.get("name").upper(),elm.text))
if elm.tag.endswith("}data_set"):
for elm2 in elm.getchildren():
if elm2.tag.endswith("}data_item"):
p = elm2.get("name")
v = str(convert(p,elm2.text))
if v.find(" ") > -1:
v = '"' + v + '"'
print("%s=%s" % (p.split(".")[-1].upper(),v))
if elm.tag.endswith("}data_item"):
p = elm.get("name")
print("%s=%s" % (p.split(".")[-1].upper(),str(convert(p,elm.text))))
sys.exit(0)