Author: rshortt
Date: Wed Mar 8 18:51:48 2006
New Revision: 1256
Modified:
trunk/WIP/epg2/src/channel.py
trunk/WIP/epg2/src/client.py
Log:
Add new_channel() which returns a channel object that is not associated with the
EPG. This is useful for clients that have channels that do not appear in the
EPG but wish to handle them anyway.
Modified: trunk/WIP/epg2/src/channel.py
==============================================================================
--- trunk/WIP/epg2/src/channel.py (original)
+++ trunk/WIP/epg2/src/channel.py Wed Mar 8 18:51:48 2006
@@ -11,7 +11,10 @@
# kludge - remove
self.id = short_name
- self._epg = weakref.ref(epg)
+ if epg:
+ self._epg = weakref.ref(epg)
+ else:
+ self._epg = None
def get_epg(self):
return self._epg()
@@ -20,5 +23,8 @@
if not t:
t = time.time()
- return self.get_epg().search(time = t, channel = self)
+ if self._epg:
+ return self.get_epg().search(time = t, channel = self)
+ else:
+ return []
Modified: trunk/WIP/epg2/src/client.py
==============================================================================
--- trunk/WIP/epg2/src/client.py (original)
+++ trunk/WIP/epg2/src/client.py Wed Mar 8 18:51:48 2006
@@ -94,6 +94,35 @@
return self._program_rows_to_objects(data)
+ def new_channel(self, tuner_id=None, short_name=None, long_name=None):
+ """
+ Returns a channel object that is not associated with the EPG.
+ This is useful for clients that have channels that do not appear
+ in the EPG but wish to handle them anyway.
+ """
+
+ # require at least one field
+ if not tuner_id and not short_name and not long_name:
+ log.error('need at least one field to create a channel')
+ return None
+
+ if not short_name:
+ # then there must be one of the others
+ if tuner_id:
+ short_name = tuner_id
+ else:
+ short_name = long_name
+
+ if not long_name:
+ # then there must be one of the others
+ if short_name:
+ long_name = short_name
+ else:
+ long_name = tuner_id
+
+ return Channel(tuner_id, short_name, long_name, epg=None)
+
+
def get_channel(self, short_name):
if short_name not in self._channels_by_name:
return None
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog