"""
A channel represents a series of log events, stored in some log source
"""
import log_search
class LogChannel (object) :
"""
A single IRC channel, logged to some specific place
"""
def __init__ (self, id, network, name, source) :
"""
Initialize this channel from the given identifier key, network name, channel name, and LogSource
"""
# store
self.id = id
self.network = network
self.name = name
self.source = source
# bind source
self.source.bind_channel(self)
@property
def title (self) :
"""
Title is 'Network - #channel'
"""
return "%s - %s" % (self.network, self.name)
def search (self, query) :
"""
Perform a search on this channel, returning a sequence of LogLines
"""
return log_search.index.search_simple(self, query)
def __str__ (self) :
"""
Returns self.title
"""
return self.title
def __repr__ (self) :
"""
Uses self.id
"""
return "LogChannel(%s)" % (self.id, )