log_channel.py
changeset 140 6db2527b67cf
parent 139 9c7769850195
child 141 65c98c9e1716
equal deleted inserted replaced
139:9c7769850195 140:6db2527b67cf
     1 """
       
     2     A channel represents a series of log events, stored in some log source
       
     3 """
       
     4 
       
     5 import log_search
       
     6 
       
     7 class LogChannel (object) :
       
     8     """
       
     9         A single IRC channel, logged to some specific place
       
    10     """
       
    11 
       
    12     def __init__ (self, id, network, name, source) :
       
    13         """
       
    14             Initialize this channel from the given identifier key, network name, channel name, and LogSource
       
    15         """
       
    16         
       
    17         # store
       
    18         self.id = id
       
    19         self.network = network
       
    20         self.name = name
       
    21         self.source = source
       
    22 
       
    23         # bind source
       
    24         self.source.bind_channel(self)
       
    25     
       
    26     @property
       
    27     def title (self) :
       
    28         """
       
    29             Title is 'Network - #channel'
       
    30         """
       
    31 
       
    32         return "%s - %s" % (self.network, self.name)
       
    33     
       
    34     def search (self, query) :
       
    35         """
       
    36             Perform a search on this channel, returning a sequence of LogLines
       
    37         """
       
    38 
       
    39         return log_search.index.search_simple(self, query)
       
    40 
       
    41     def __str__ (self) :
       
    42         """
       
    43             Returns self.title
       
    44         """
       
    45 
       
    46         return self.title
       
    47 
       
    48     def __repr__ (self) :
       
    49         """
       
    50             Uses self.id
       
    51         """
       
    52 
       
    53         return "LogChannel(%s)" % (self.id, )
       
    54