parsing for /etc/timezone.xml added
[enigma2.git] / lib / python / Components / Timezones.py
1 from xml.sax import make_parser
2 from xml.sax.handler import ContentHandler
3
4 class Timezones:
5         class parseTimezones(ContentHandler):
6                 def __init__(self, timezones):
7                         self.isPointsElement, self.isReboundsElement = 0, 0
8                         self.timezones = timezones
9         
10                 def startElement(self, name, attrs):
11                         print "Name: " + str(name)
12                         if (name == "zone"):
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)
20         
21         def __init__(self):
22                 self.timezones = {}
23                 
24                 self.readTimezonesFromFile()
25
26         def readTimezonesFromFile(self):
27                 parser = make_parser()
28                 timezonesHandler = self.parseTimezones(self.timezones)
29                 parser.setContentHandler(timezonesHandler)
30                 parser.parse('/etc/timezone.xml')
31                 
32
33 timezones = Timezones()