From 9925392e576717cc0df070ace822a6f392808bb7 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Thu, 17 Nov 2005 15:46:54 +0000 Subject: [PATCH] parsing for /etc/timezone.xml added --- lib/python/Components/Makefile.am | 2 +- lib/python/Components/SetupDevices.py | 1 + lib/python/Components/Timezones.py | 33 +++++++++++++++++++++++++++ lib/python/Components/__init__.py | 2 +- 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 lib/python/Components/Timezones.py diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am index 15073741..0e1894aa 100644 --- a/lib/python/Components/Makefile.am +++ b/lib/python/Components/Makefile.am @@ -9,4 +9,4 @@ install_PYTHON = \ GUIComponent.py MenuList.py TextInput.py __init__.py MovieList.py \ InputDevice.py ServicePosition.py SetupDevices.py Harddisk.py \ AVSwitch.py Network.py RFmod.py DiskInfo.py NimManager.py Lcd.py \ - EpgList.py ScrollLabel.py + EpgList.py ScrollLabel.py Timezones.py diff --git a/lib/python/Components/SetupDevices.py b/lib/python/Components/SetupDevices.py index cb2badb0..003bba54 100644 --- a/lib/python/Components/SetupDevices.py +++ b/lib/python/Components/SetupDevices.py @@ -5,6 +5,7 @@ from config import ConfigSubsection from config import ConfigSlider from config import configSelection from config import configText +from Components.Timezones import timezones def InitSetupDevices(): config.timezone = ConfigSubsection(); diff --git a/lib/python/Components/Timezones.py b/lib/python/Components/Timezones.py new file mode 100644 index 00000000..90b227f7 --- /dev/null +++ b/lib/python/Components/Timezones.py @@ -0,0 +1,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() diff --git a/lib/python/Components/__init__.py b/lib/python/Components/__init__.py index ebc7f49f..ed74427a 100644 --- a/lib/python/Components/__init__.py +++ b/lib/python/Components/__init__.py @@ -6,4 +6,4 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo", "components", "config", "TimerList", "TimeInput", "MovieList", "InputDevice", "ServicePosition", "IPAddress", "VariableIP", "IPGateway", "IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager", "TimerEntry", - "Lcd", "EpgList" "ScrollLabel"] + "Lcd", "EpgList" "ScrollLabel", "Timezones"] -- 2.30.2