-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples.py
60 lines (46 loc) · 1.56 KB
/
examples.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
57
58
59
60
import sys
import getopt
from mtdConstructionDBTools import mtdcdb
# get help with options
shrtopts = 'hwx:y:'
longopts = ['help', 'what', 'xml=', 'yetanotheroption=']
helpopts = ['shows this help',
'what?',
'specity an xml file',
'a dummy one'
]
try:
opts, args = getopt.getopt(sys.argv[1:], shrtopts, longopts)
except Exception as excptn:
print("Unexpected exception: " + str(excptn))
mtdcdb.mtdhelp(shrtopts, longopts, helpopts)
# upload a file to the dbloader
# mtdcdb.writeToDB(filename = 'gorgantini.xml', dryrun = True)
xml = mtdcdb.root()
attr = [{
'NAME': 'attr1',
'VALUE': 'val1'
},{
'NAME': 'attr2',
'VALUE': 'val2'
}
]
aPart = mtdcdb.part('01234567890123', 'type', batch = 'a batch', attributes = attr)
xml.append(aPart)
xmlstring = mtdcdb.mtdxml(xml)
print(xmlstring)
# ---------------------------------------------------------------------------
xml = mtdcdb.root()
xmlstring = mtdcdb.mtdxml(xml)
print(xmlstring)
dataset = {'01234567890': [{'NAME': 'name1', 'VALUE': 'value1'},
{'NAME': 'name2', 'VALUE': 'value2'},
{'NAME': 'name3', 'VALUE': 'value3'}],
'09876543210': [{'NAME': 'name1', 'VALUE': 'valuea'},
{'NAME': 'name2', 'VALUE': 'valueb'},
{'NAME': 'name3', 'VALUE': 'valuec'}]
}
cond = mtdcdb.newCondition(xml, 'CONDITION_NAME', dataset, run = 'A_RUN_WITH_A_NAME')
xml.append(cond)
xmlstring = mtdcdb.mtdxml(xml)
print(xmlstring)