diff options
| author | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2005-10-09 00:23:49 +0000 |
|---|---|---|
| committer | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2005-10-09 00:23:49 +0000 |
| commit | ac2585b1cf9b605723d9fe593c04f138086976a6 (patch) | |
| tree | 1f73152d8f2c6403ec957d517175f2d2e51c19fc /lib | |
| parent | ee34dc9997d200a8021332dd639c2cf3a92b21cd (diff) | |
| download | enigma2-ac2585b1cf9b605723d9fe593c04f138086976a6.tar.gz enigma2-ac2585b1cf9b605723d9fe593c04f138086976a6.zip | |
user xml.sax instead of xml.dom for satellites.xml parsing
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/python/Components/NimManager.py | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index f91a4ea4..d826dbe4 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -11,6 +11,9 @@ from xml.dom import EMPTY_NAMESPACE from skin import elementsWithTag from Tools import XMLTools +from xml.sax import make_parser +from xml.sax.handler import ContentHandler + class boundFunction: def __init__(self, fnc, *args): self.fnc = fnc @@ -25,20 +28,41 @@ class nimSlot: self.name = name class NimManager: + class parseSats(ContentHandler): + def __init__(self, satList, satellites): + self.isPointsElement, self.isReboundsElement = 0, 0 + self.satList = satList + self.satellites = satellites + + def startElement(self, name, attrs): + if (name == "sat"): + #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) ) + def readSatsfromFile(self): self.satellites = { } - #FIXME: path ok??? - satdom = xml.dom.minidom.parse('/etc/tuxbox/satellites.xml') - - for entries in elementsWithTag(satdom.childNodes, "satellites"): - for x in elementsWithTag(entries.childNodes, "sat"): - #print "found sat " + x.getAttribute('name') + " " + str(x.getAttribute('position')) - tpos = x.getAttribute('position') - tname = x.getAttribute('name') - #tname.encode('utf8') - self.satellites[tpos] = tname - self.satList.append( (tname, tpos) ) + #FIXME: path ok??? + print "Reading satellites.xml" + parser = make_parser() + satHandler = self.parseSats(self.satList, self.satellites) + parser.setContentHandler(satHandler) + parser.parse('/etc/tuxbox/satellites.xml') + + #satdom = xml.dom.minidom.parse('/etc/tuxbox/satellites.xml') + + + #for entries in elementsWithTag(satdom.childNodes, "satellites"): + #for x in elementsWithTag(entries.childNodes, "sat"): + ##print "found sat " + x.getAttribute('name') + " " + str(x.getAttribute('position')) + #tpos = x.getAttribute('position') + #tname = x.getAttribute('name') + ##tname.encode('utf8') + #self.satellites[tpos] = tname + #self.satList.append( (tname, tpos) ) def getNimType(self, slotID): #FIXME get it from /proc @@ -69,7 +93,7 @@ class NimManager: self.readSatsfromFile() self.nimCount = self.getNimSocketCount() - + self.nimslots = [ ] x = 0 while x < self.nimCount: |
