Source code for Channels
# CellTracking.py
# By MW, Jun 2013
# GPLv3+
#
# Class managing the Channels
import imp, logging
Channel = imp.load_source("Channel", './bin/Movies/Channels/Channel.py') # Loading the Movie class
channels_dict = {}
[docs]def new_channel(name) :
"""Function that initialize a new channel.
Takes a channel name as an input"""
# Check if name is not already used
if not (name in channels_dict.keys()) :
c = Channel.Channel(name) # Initialize an empty
channels_dict[name] = c
return c
else :
logging.error("Channel name already used")
[docs]def get_channel(name) :
"""Gets a channel given its name"""
try :
return channels_dict[name]
except :
logging.error("The channel '%s' does not exist in this movie", name)
[docs]def get_channels_dict() :
"""Returns the list of channels"""
return channels_dict
[docs]def get_save_dict() :
dic = {}
channels = channels_dict
channels_l = []
for ch in channels.keys() :
c = channels[ch]
d = {'descr' : 'a channel', 'value' : {}}
d['value']['name'] = {'descr' : 'name of the channel', 'value' : ch}
d['value']['channel'] = c.get_save_dict()
channels_l.append(d)
dic['channels_dict'] = {'descr' : 'A list describing the self.channels_dict object', 'value' : channels_l}
return {'descr' : 'Channels module', 'value' : dic}
[docs]def load_save_dict(dic) :
for ch in dic['value']['channels_dict']['value'] :
n = ch['value']['name']['value']
c = ch['value']['channel']
channel = new_channel(n)
channel.load_save_dict(c)