change xml tags in webif hook
authorMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Tue, 8 Sep 2009 12:57:41 +0000 (12:57 +0000)
committerMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Tue, 8 Sep 2009 12:57:41 +0000 (12:57 +0000)
this makes the config file look a little weird for now but who cares :-)

epgrefresh/src/EPGRefresh.py
epgrefresh/src/EPGRefreshResource.py

index 48eba88..240b51e 100644 (file)
@@ -85,23 +85,32 @@ class EPGRefresh:
                                duration = duration and int(duration)
                                self.services[1].add(EPGRefreshService(value, duration))
 
-       def buildConfiguration(self):
+       def buildConfiguration(self, webif = False):
                list = ['<?xml version="1.0" ?>\n<epgrefresh>\n\n']
 
+               if webif:
+                       TAGSERVICE='e2servicereference'
+                       TAGBOUQUET='e2servicereference'
+                       TAGNAME='e2servicename'
+               else:
+                       TAGSERVICE='service'
+                       TAGBOUQUET='bouquet'
+                       TAGNAME='!--'
+
                for service in self.services[0]:
                        ref = ServiceReference(service.sref)
-                       list.extend([' <!-- ', stringToXML(ref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '')), ' -->\n'])
-                       list.append(' <service')
+                       list.extend((' <', TAGNAME, '>', stringToXML(ref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '')), '</', TAGNAME, '>\n'))
+                       list.extend((' <', TAGSERVICE))
                        if service.duration is not None:
-                               list.extend([' duration="', str(service.duration), '"'])
-                       list.extend(['>', stringToXML(service.sref), '</service>\n'])
+                               list.extend((' duration="', str(service.duration), '"'))
+                       list.extend(('>', stringToXML(service.sref), '</', TAGSERVICE, '>\n'))
                for bouquet in self.services[1]:
                        ref = ServiceReference(bouquet.sref)
-                       list.extend([' <!-- ', stringToXML(ref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '')), ' -->\n'])
-                       list.append(' <bouquet')
+                       list.extend((' <', TAGNAME, '>', stringToXML(ref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '')), '</', TAGNAME, '>\n'))
+                       list.extend((' <', TAGBOUQUET))
                        if bouquet.duration is not None:
-                               list.extend([' duration="', str(bouquet.duration), '"'])
-                       list.extend(['>', stringToXML(bouquet.sref), '</bouquet>\n'])
+                               list.extend((' duration="', str(bouquet.duration), '"'))
+                       list.extend(('>', stringToXML(bouquet.sref), '</', TAGBOUQUET, '>\n'))
 
                list.append('\n</epgrefresh>')
 
index c85a33f..406a7b3 100644 (file)
@@ -114,5 +114,5 @@ class EPGRefreshListServicesResource(resource.Resource):
                req.setResponseCode(http.OK)
                req.setHeader('Content-type', 'application; xhtml+xml')
                req.setHeader('charset', 'UTF-8')
-               return ''.join(epgrefresh.buildConfiguration())
+               return ''.join(epgrefresh.buildConfiguration(webif = True))