aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/Timezones.py
blob: 90b227f770e07d5abd38c40acd619d66ca3ecdf9 (plain)
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
from xml.sax import make_parser
from xml.sax.handler import ContentHandler

class Timezones:
	class parseTimezones(ContentHandler):
		def __init__(self, timezones):
			self.isPointsElement, self.isReboundsElement = 0, 0
			self.timezones = timezones
	
		def startElement(self, name, attrs):
			print "Name: " + str(name)
			if (name == "zone"):
				self.timezones[attrs.get('name',"")] = attrs.get('zone',"")
				#print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
				#tpos = attrs.get('position',"")
				#tname = attrs.get('name',"")
				#self.satellites[tpos] = tname
				#self.satList.append( (tname, tpos) )
				#self.parsedSat = int(tpos)
	
	def __init__(self):
		self.timezones = {}
		
		self.readTimezonesFromFile()

	def readTimezonesFromFile(self):
		parser = make_parser()
		timezonesHandler = self.parseTimezones(self.timezones)
		parser.setContentHandler(timezonesHandler)
		parser.parse('/etc/timezone.xml')
		

timezones = Timezones()