File: update_options_ts.py

package info (click to toggle)
psi 1.5%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 14,888 kB
  • sloc: cpp: 156,588; ansic: 15,068; javascript: 13,441; xml: 3,199; sh: 1,038; objc: 407; makefile: 396; python: 196; ruby: 171
file content (27 lines) | stat: -rwxr-xr-x 744 bytes parent folder | download | duplicates (14)
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
#!/usr/bin/python

from xml.dom.minidom import parse, parseString
import xml.dom
import sys

def rec_parse(node, context): # node : xml.dom.Node
	for i in node.childNodes:
		if i.nodeType == xml.dom.Node.ELEMENT_NODE:
			if i.hasAttribute("comment"):
				print 'QT_TRANSLATE_NOOP("' + context + '","' + i.getAttribute("comment") + '");';
			rec_parse(i,context)


if len(sys.argv) != 2:
	print "usage: %s options.xml > output.cpp" % sys.argv[0]
	sys.exit(1)

print "#define QT_TRANSLATE_NOOP(a,b)"

dom = parse(sys.argv[1]) # parse an XML file by name

toplevel = dom.getElementsByTagName("psi")[0]
options = toplevel.getElementsByTagName("options")[0]

shortcuts = options.getElementsByTagName("shortcuts")[0]
rec_parse(shortcuts,"Shortcuts")