Update of /cvsroot/freevo/freevo/WIP/Ruelle
In directory sc8-pr-cvs1:/tmp/cvs-serv2253
Modified Files:
tvtime.py
Log Message:
now we merge stationlist if it already exists
Index: tvtime.py
===================================================================
RCS file: /cvsroot/freevo/freevo/WIP/Ruelle/tvtime.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** tvtime.py 2 Oct 2003 00:31:54 -0000 1.10
--- tvtime.py 14 Oct 2003 18:54:56 -0000 1.11
***************
*** 10,15 ****
# -----------------------------------------------------------------------
# $Log$
! # Revision 1.10 2003/10/02 00:31:54 mikeruelle
! # adding xmltv support for tvtime
#
# Revision 1.17 2003/09/03 17:54:38 dischi
--- 10,15 ----
# -----------------------------------------------------------------------
# $Log$
! # Revision 1.11 2003/10/14 18:54:56 mikeruelle
! # now we merge stationlist if it already exists
#
# Revision 1.17 2003/09/03 17:54:38 dischi
***************
*** 57,60 ****
--- 57,62 ----
import re
import popen2
+ from xml.dom.ext.reader import Sax2
+ from xml.dom.ext import PrettyPrint
import util # Various utilities
***************
*** 187,197 ****
def writeTvtimeXML(self):
configcmd = "tvtime-configure"
cf_norm, cf_input, cf_clist, cf_device = config.TV_SETTINGS.split()
s_norm = cf_norm.upper()
if self.xmltv_supported:
! daoptions = ' -d %s -n %s -t %s' % (cf_device, s_norm, config.XMLTV_FILE)
else:
! daoptions = ' -d %s -n %s' % (cf_device, s_norm)
os.system(configcmd+daoptions)
--- 189,205 ----
def writeTvtimeXML(self):
+ tvtimexml = os.path.join(os.environ['HOME'], '.tvtime', 'tvtime.xml')
+ #BUG take the tvtime binary and strip off its path and use that to
+ #prepend here
configcmd = "tvtime-configure"
cf_norm, cf_input, cf_clist, cf_device = config.TV_SETTINGS.split()
s_norm = cf_norm.upper()
+ daoptions = ''
+ if os.path.isfile(tvtimexml):
+ daoptions = ' -F ' + tvtimexml
if self.xmltv_supported:
! daoptions += ' -d %s -n %s -t %s' % (cf_device, s_norm,
config.XMLTV_FILE)
else:
! daoptions += ' -d %s -n %s' % (cf_device, s_norm)
os.system(configcmd+daoptions)
***************
*** 203,207 ****
tvnorm = tvnorm.upper()
tvtimefile = os.path.join(os.environ['HOME'], '.tvtime', 'stationlist.xml')
! fp = open(tvtimefile,'w')
fp.write('<?xml version="1.0"?>\n')
fp.write('<!DOCTYPE stationlist PUBLIC "-//tvtime//DTD stationlist 1.0//EN"
"http://tvtime.sourceforge.net/DTD/stationlist1.dtd">\n')
--- 211,271 ----
tvnorm = tvnorm.upper()
tvtimefile = os.path.join(os.environ['HOME'], '.tvtime', 'stationlist.xml')
! if os.path.isfile(tvtimefile):
! self.mergeStationListXML(tvtimefile, tvnorm, norm)
! else:
! self.writeNewStationListXML(tvtimefile, tvnorm, norm)
!
! def mergeStationListXML(self, tvtimefile, tvnorm, norm):
! try:
! os.rename(tvtimefile,tvtimefile+'.bak')
! except OSError:
! return
!
! reader = Sax2.Reader()
! doc = reader.fromStream(tvtimefile+'.bak')
! mystations = doc.getElementsByTagName('station')
! gotlist = 0
! freevonode = None
! for station in mystations:
! myparent = station.parentNode
! if myparent.getAttribute('norm') == tvnorm and
myparent.getAttribute('frequencies') == 'freevo':
! print 'found it'
! myparent.removeChild(station)
! freevonode = myparent
! gotlist=1
! if not gotlist:
! child = doc.createElement('list')
! freevonode = child
! child.setAttribute('norm', tvnorm)
! child.setAttribute('frequencies', 'freevo')
! doc.documentElement.appendChild(child)
! #put in the new children
! c = 0
! for m in config.TV_CHANNELS:
! mychan = m[2]
! myband = self.lookupChannelBand(mychan)
! if myband == "Custom":
! mychan = config.FREQUENCY_TABLE.get(mychan)
! mychan = float(mychan)
! mychan = mychan / 1000.0
! mychan = "%.2fMHz" % mychan
! fchild = doc.createElement('station')
! fchild.setAttribute('channel',mychan)
! fchild.setAttribute('band',myband)
! fchild.setAttribute('name',cgi.escape(m[1]))
! fchild.setAttribute('active','1')
! fchild.setAttribute('position',str(c))
! if self.xmltv_supported:
! fchild.setAttribute('xmltvid',m[0])
! freevonode.appendChild(fchild)
! c = c + 1
! #PrettyPrint the results to stationlistxml
! fp = open(tvtimefile,'wb')
! PrettyPrint(doc, fp)
! fp.close()
!
!
! def writeNewStationListXML(self, tvtimefile, tvnorm, norm):
! fp = open(tvtimefile,'wb')
fp.write('<?xml version="1.0"?>\n')
fp.write('<!DOCTYPE stationlist PUBLIC "-//tvtime//DTD stationlist 1.0//EN"
"http://tvtime.sourceforge.net/DTD/stationlist1.dtd">\n')
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog