chanlist
index
/usr/ports/multimedia/kbtv2-core/work/kbtv-2.0/Core/chanlist.py

MODULE
    chanlist -- classes for managing a TV channel list
 
COPYRIGHT
    (c) 2005-2008, Danny Pansters <danny@ricin.com>
    All rights reserved. Dit werk is auteursrechtelijk beschermd.
 
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:
 
    1. Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.
 
    THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE
    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
    OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
DESCRIPTION
    This module contains a set of classes for managing a TV channel list.
    Its main purpose is to associate TV channel frequencies with data
    such as a descriptive name and a number in Channel objects. There are 
    also PseudoChannels which are used for composite sources. The 
    ChannelList is an ordered list of such Channel objects and it can 
    be loaded from and saved as a cPickle.
 
CLASSES
    Channel
    ChannelList
    PseudoChannel
 
CONSTANTS
    dict CHANSETS
    Channel sets, these are a collection of known frequency tables for a
    bunch of countries. Organized in a dict with pairs like 'County': [].
 
EXAMPLES
    import chanlist
    dir(chanlist)                # to see available classes
    dir(chanlist.ChannelList)    # to see methods and attributes of ChannelList
    help(chanlist)               # to see this text
    cl = chanlist.ChannelList()  # to create an empty ChannelList object
    cl.load('/path/to/pickle')   # to unpickle a ChannelList object from disk

 
Modules
       
os
util

 
Classes
       
__builtin__.list(__builtin__.object)
ChannelList
Channel
PseudoChannel

 
class Channel
    -> Channel
 
DESCRIPTION
    Class that describes a TV (or possibly radio-) channel. Its 
    attributes are frequency, id and name (unicode).
 
CONSTRUCTOR
    Channel(int freq)
 
ATTRIBUTES
    int frequency
    unicode name
 
METHODS
    setName(unicode name)
    setName(str name)
 
EXAMPLES
    c = Channel(848000)
    c.name
    -> u''
    c.setName('Discovery')
    c.name
    -> u'Discovery'
 
  Methods defined here:
__init__(self, freq)
-> Channel
 
DESCRIPTION
    Creates a Channel object, characterized by the attributes name
    and frequency. Frequency (kHz) also serves as a (unique) id and 
    name can be set and changed later.
 
EXAMPLES
    c1, c2, c3 = Channel(184000), Channel(192000), Channel(200000)
setName(self, name)
-> void
 
DESCRIPTION
     Sets the Channel's name attribute, which may be supplied
     as a string (or other meaningful type) as well as unicode.
 
 EXAMPLES
     c1, c2, c3 = Channel(184000), Channel(192000), Channel(200000)
     c1.setName('Nederland 1')
     c2.setName(u'Nederland 2')
     c3.setName(3)              # works, but Don't Do This
     c1.name, c2.name, c3.name
     -> (u'Nederland 1', u'Nederland 2', u'3')

 
class ChannelList(__builtin__.list)
    -> ChannelList
 
DESCRIPTION
    Class that describes a list of (pseudo-) channels which can 
    be added, moved, deleted. There are methods for reading an 
    existing ChannelList object from disk and writing one to disk 
    (via cPickle).
    
    In kbtv1, tuning to channels was part of the channel list 
    functionality (and class), in retrospect this was a mistake.
 
CONSTRUCTOR
    ChannelList()
 
METHODS
    bool add(Channel chan)
    bool add(PseudoChannel pchan)
    bool delete(int ind)
    bool dump(str pfile)
    bool load(str pfile)
    bool move(int src, int dst)
 
EXAMPLES
    p0 = PseudoChannel(0)
    c1, c2 = Channel(848000), Channel(776000)
    p0.setName('Extern 0')
    c1.setName('Discovery')
    c2.setName('Animal Planet')
    l = ChannelList()
    l.add(p0)
    -> (True)
    l.add(c1), l.add(c2)
    -> (True, True)
    len(l)
    -> 3
    l.dump('~/mychanlist.cp')
    -> True
 
 
Method resolution order:
ChannelList
__builtin__.list
__builtin__.object

Methods defined here:
__init__(self)
-> ChannelList
 
DESCRIPTION
    Creates a ChannelList object. While having a few extra or 
    shoehorning methods, a ChannelList is just a list, so any 
    built-in functions that work on lists and any of list's 
    methods can be used with it. The index of the list serves 
    as the channel number (use channel 0 for EXT0 or the like). 
    Init itself does nothing, only creates the parent list.
 
EXAMPLES
    l = ChannelList()
    l.add(Channel(184000)), l.add(Channel(192000)), l.add(Channel(200000))
    -> (True, True, True)
add(self, obj)
-> bool
 
DESCRIPTION
    Appends obj to the ChannelList and returns True if obj
    is a Channel or PseudoChannel instance, and obj's 
    frequency or id is not in the list yet. In all other
    cases it returns False and it doesn't append.
 
EXAMPLES
    l = ChannelList()
    l.add(Channel(200000))
    -> True
    l.add(Channel(200000))
    -> False
    len(l)
    -> 1
delete(self, ind)
-> bool
 
DESCRIPTION
    Deletes item by index. Returns False on IndexError.
 
EXAMPLES
    l = ChannelList()
    l.add(Channel(200000))
    -> True
    l.add(Channel(208000))
    -> True
    l.delete(-1)
    -> True
    len(l)
    -> 1
dump(self, pfile)
-> bool
 
DESCRIPTION
    Dumps the ChannelList to the file located at pfile as
    a cPickle. Uses util.Serializer, and returns its result.
 
EXAMPLES
    mynewchanlist = ChannelList()
    ...
    mynewchanlist.dump('~/mynewchanlist.cp')
    -> True
    mynewchanlist.dump('/root/hahaha')
    -> False
load(self, pfile)
-> bool
 
DESCRIPTION
    Loads a ChannelList from the cPickle in the file located at
    pfile. Uses util.Serializer, and returns its result. If 
    successful, the loaded list becomes this list ('self').
 
EXAMPLES
    myoldchanlist = ChannelList()
    myoldchanlist.load('~/myoldchanlist.cp')
    -> True
move(self, src, dst)
-> bool
 
DESCRIPTION
    Moves item by index, from src to dst. Returns False if src
    or dest is not an index of the ChannelList. It's worth noting
    that negative indices are not only allowed, they can be very 
    handy. To refer to the highest channel for example, just use 
    self[-1].
 
EXAMPLES
    l = ChannelList()
    l.add(Channel(200000))
    -> True
    l.add(Channel(208000))
    -> True
    l.move(0, -1)
    -> True
    l[0].frequency
    -> 208000
    l.move(1, 2)
    -> False

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from __builtin__.list:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iadd__(...)
x.__iadd__(y) <==> x+=y
__imul__(...)
x.__imul__(y) <==> x*=y
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__reversed__(...)
L.__reversed__() -- return a reverse iterator over the list
__rmul__(...)
x.__rmul__(n) <==> n*x
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
append(...)
L.append(object) -- append object to end
count(...)
L.count(value) -> integer -- return number of occurrences of value
extend(...)
L.extend(iterable) -- extend list by appending elements from the iterable
index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value
insert(...)
L.insert(index, object) -- insert object before index
pop(...)
L.pop([index]) -> item -- remove and return item at index (default last)
remove(...)
L.remove(value) -- remove first occurrence of value
reverse(...)
L.reverse() -- reverse *IN PLACE*
sort(...)
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1

Data and other attributes inherited from __builtin__.list:
__new__ = <built-in method __new__ of type object at 0x8109360>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class PseudoChannel
    -> PseudoChannel
 
DESCRIPTION
    Class that describes a pseudo channel, which is like a Channel but
    instead of a frequency it has an id that can be used to add 
    external video sources as if they were channels, that is any CVBS 
    that is not a tuner. The attributes are id and name. Id is the 
    video source number (0 to 4) as defined in the avctrl module. Care
    should be taken to exclude any PseudoChannel that uses the number
    corresponding with the tuner from a running ChannelList object 
    (usually DEV1), or the user will likely be confused.
 
CONSTRUCTOR
    PseudoChannel(int id)
 
ATTRIBUTES
    int id
    unicode name
 
METHODS
    setName(unicode name)
    setName(str name)
 
EXAMPLES
    p = PseudoChannel(0)
    p.name
    -> u''
    p.setName('Dreambox')
    p.name
    -> u'Dreambox'
 
  Methods defined here:
__init__(self, id)
-> PseudoChannel
 
DESCRIPTION
    Creates a PseudoChannel object, characterized by the attributes
    id and name. Id is set to -1 if id is not in 0-4.
                                                
EXAMPLES
    p0, p3, p4 = PseudoChannel(0), PseudoChannel(3), PseudoChannel(4)
    p5 = PseudoChannel(5)
    p5.id
    -> -1
setName(self, name)
-> void
 
DESCRIPTION
     Sets the PseudoChannel's name attribute, which may be supplied
     as a string (or other meaningful type) as well as unicode.
 
 EXAMPLES
     p0, p3, p4 = PseudoChannel(0), PseudoChannel(3), PseudoChannel(4)
     p0.setName('Satellite'), p3.setName('Camera'), p4.setName('Svideo')

 
Data
        CHANSETS = {'Argentina': [56250, 62250, 68250, 78250, 84250, 122250, 128250, 134250, 140250, 146250, 152250, 158250, 164250, 170250, 176250, 182250, 188250, 194250, 200250, 206250, ...], 'Australia': [46250, 57250, 64250, 86250, 95250, 102250, 138250, 175250, 182250, 189250, 196250, 209250, 216250, 527250, 534250, 541250, 548250, 555250, 562250, 569250, ...], 'China Broadcast': [49750, 57750, 65750, 77250, 85250, 112250, 120250, 128250, 136250, 144250, 152250, 160250, 168250, 176250, 184250, 192250, 200250, 208250, 216250, 224250, ...], 'Europe East': [48250, 49750, 55250, 59250, 62250, 69250, 76250, 77250, 83250, 85250, 93250, 105250, 111250, 112250, 119250, 126250, 127250, 133250, 135250, 140250, ...], 'Europe West': [48250, 55250, 62250, 69250, 76250, 83250, 105250, 112250, 119250, 126250, 133250, 140250, 147250, 154250, 161250, 168250, 175250, 182250, 189250, 196250, ...], 'France': [47750, 55750, 60050, 63750, 116750, 128750, 140750, 159750, 164750, 176000, 176750, 184000, 188750, 192000, 200000, 200750, 208000, 212750, 216000, 224750, ...], 'Ireland': [45750, 48000, 53750, 61750, 175250, 176000, 183250, 191250, 192000, 199250, 200000, 207250, 208000, 215250, 216000, 224000, 232000, 248000, 256000, 264000, ...], 'Italy': [53750, 62250, 82250, 175250, 183750, 192250, 201250, 210250, 217250, 224250, 471250, 479250, 487250, 495250, 503250, 511250, 519250, 527250, 535250, 543250, ...], 'Japan Broadcast': [91250, 97250, 103250, 171250, 177250, 183250, 189250, 193250, 199250, 205250, 211250, 217250, 471250, 477250, 483250, 489250, 495250, 501250, 507250, 513250, ...], 'Japan Cable': [109250, 115250, 121250, 127250, 133250, 139250, 145250, 151250, 157250, 165250, 223250, 231250, 237250, 243250, 249250, 253250, 259250, 265250, 271250, 277250, ...], ...}