log_channel.py
author Tero Marttila <terom@fixme.fi>
Sat, 14 Feb 2009 20:13:26 +0200
changeset 128 2a8a190f8aee
parent 90 275a675712f1
permissions -rw-r--r--
fix config.VERSION_LINK to use relpath('.')
"""
    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, )