1 from xml.sax import make_parser
2 from xml.sax.handler import ContentHandler
5 class parseTimezones(ContentHandler):
6 def __init__(self, timezones):
7 self.isPointsElement, self.isReboundsElement = 0, 0
8 self.timezones = timezones
10 def startElement(self, name, attrs):
11 print "Name: " + str(name)
13 self.timezones[attrs.get('name',"")] = attrs.get('zone',"")
14 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
15 #tpos = attrs.get('position',"")
16 #tname = attrs.get('name',"")
17 #self.satellites[tpos] = tname
18 #self.satList.append( (tname, tpos) )
19 #self.parsedSat = int(tpos)
24 self.readTimezonesFromFile()
26 def readTimezonesFromFile(self):
27 parser = make_parser()
28 timezonesHandler = self.parseTimezones(self.timezones)
29 parser.setContentHandler(timezonesHandler)
30 parser.parse('/etc/timezone.xml')
33 timezones = Timezones()