5 from xml.sax import make_parser
6 from xml.sax.handler import ContentHandler
8 class parseXML(ContentHandler):
9 def __init__(self, attrlist):
10 self.isPointsElement, self.isReboundsElement = 0, 0
11 self.attrlist = attrlist
13 def startElement(self, name, attrs):
14 if (attrs.has_key('text')):
15 attrlist[attrs.get('text', "")] = "foo"
16 if (attrs.has_key('title')):
17 attrlist[attrs.get('title', "")] = "foo"
18 if (attrs.has_key('value')):
19 attrlist[attrs.get('value', "")] = "foo"
20 if (attrs.has_key('caption')):
21 attrlist[attrs.get('caption', "")] = "foo"
23 parser = make_parser()
27 contentHandler = parseXML(attrlist)
28 parser.setContentHandler(contentHandler)
30 dir = os.listdir(sys.argv[1])
32 if (str(x[-4:]) == ".xml"):
33 parser.parse(sys.argv[1] + str(x))
35 #parser.parse(sys.argv[1])
37 for k, v in attrlist.items():
39 print '#: ' + sys.argv[1]
40 string.replace(k, "\\n", "\"\n\"")
41 print 'msgid "' + str(k) + '"'