Repository navigation
Expand file tree
/
Copy pathcodegen_version
More file actions
executable file
·61 lines (54 loc) · 2.07 KB
/
Copy pathcodegen_version
File metadata and controls
executable file
·61 lines (54 loc) · 2.07 KB
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
61
#!/usr/bin/python
#
# This file is protected by Copyright. Please refer to the COPYRIGHT file
# distributed with this source distribution.
#
# This file is part of REDHAWK core.
#
# REDHAWK core is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# REDHAWK core is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
import os
import sys
from xml.dom import minidom
def codegenVersion(filename):
dom = minidom.parse(filename)
settings = {}
codegenVersion = "1.9 jinja"
for node in dom.getElementsByTagName('implSettings'):
implId = node.getAttribute('key')
implSettingsNode = node.getElementsByTagName('value')[0]
generatorId = implSettingsNode.getAttribute('generatorId')
template = implSettingsNode.getAttribute('template')
if template.find(".jet.") != -1 and generatorId.find(".jet.") != -1:
codegenVersion = "1.8 jet"
break
dom.unlink()
return codegenVersion
usage = """%s <SPD file>
Arguments:
<SPD file> Path to component .spd.xml
""" % os.path.basename(sys.argv[0])
if __name__ == '__main__':
try:
spdFile = sys.argv[1]
except:
raise SystemExit(usage)
# Read existing WaveDev settings file
wavedev = '.' + os.path.basename(spdFile).replace('.spd.xml', '.wavedev')
wavedev = os.path.join(os.path.dirname(spdFile), wavedev)
if os.path.exists(wavedev):
version = codegenVersion(wavedev)
print "version ****** " + str(version)
else:
raise SystemExit, 'Cannot determine codegen version because wavedev file does not exist'