log_channel.py
author Tero Marttila <terom@fixme.fi>
Fri, 13 Feb 2009 00:29:47 +0200
changeset 121 86aebc9cb60b
parent 90 275a675712f1
permissions -rw-r--r--
some quickfixes to fix deployment errors
41
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
"""
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
    A channel represents a series of log events, stored in some log source
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
"""
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
65
8b50694f841e improve search further
Tero Marttila <terom@fixme.fi>
parents: 46
diff changeset
     5
import log_search
8b50694f841e improve search further
Tero Marttila <terom@fixme.fi>
parents: 46
diff changeset
     6
41
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
class LogChannel (object) :
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
    """
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
        A single IRC channel, logged to some specific place
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
    """
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
    def __init__ (self, id, network, name, source) :
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
        """
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
            Initialize this channel from the given identifier key, network name, channel name, and LogSource
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
        """
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
        
86
645cf9c4441e implement full parser+formatter for irssi
Tero Marttila <terom@fixme.fi>
parents: 65
diff changeset
    17
        # store
41
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
        self.id = id
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
        self.network = network
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
        self.name = name
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
        self.source = source
86
645cf9c4441e implement full parser+formatter for irssi
Tero Marttila <terom@fixme.fi>
parents: 65
diff changeset
    22
645cf9c4441e implement full parser+formatter for irssi
Tero Marttila <terom@fixme.fi>
parents: 65
diff changeset
    23
        # bind source
645cf9c4441e implement full parser+formatter for irssi
Tero Marttila <terom@fixme.fi>
parents: 65
diff changeset
    24
        self.source.bind_channel(self)
42
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    25
    
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    26
    @property
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    27
    def title (self) :
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    28
        """
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    29
            Title is 'Network - #channel'
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    30
        """
41
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
42
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    32
        return "%s - %s" % (self.network, self.name)
65
8b50694f841e improve search further
Tero Marttila <terom@fixme.fi>
parents: 46
diff changeset
    33
    
8b50694f841e improve search further
Tero Marttila <terom@fixme.fi>
parents: 46
diff changeset
    34
    def search (self, query) :
8b50694f841e improve search further
Tero Marttila <terom@fixme.fi>
parents: 46
diff changeset
    35
        """
8b50694f841e improve search further
Tero Marttila <terom@fixme.fi>
parents: 46
diff changeset
    36
            Perform a search on this channel, returning a sequence of LogLines
8b50694f841e improve search further
Tero Marttila <terom@fixme.fi>
parents: 46
diff changeset
    37
        """
42
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    38
65
8b50694f841e improve search further
Tero Marttila <terom@fixme.fi>
parents: 46
diff changeset
    39
        return log_search.index.search_simple(self, query)
8b50694f841e improve search further
Tero Marttila <terom@fixme.fi>
parents: 46
diff changeset
    40
90
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    41
    def __str__ (self) :
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    42
        """
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    43
            Returns self.title
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    44
        """
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    45
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    46
        return self.title
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    47
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    48
    def __repr__ (self) :
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    49
        """
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    50
            Uses self.id
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    51
        """
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    52
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    53
        return "LogChannel(%s)" % (self.id, )
275a675712f1 clean up repr(LogLine) output
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    54