qmsk/irclogs/log_channel.py
changeset 140 6db2527b67cf
parent 90 275a675712f1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/qmsk/irclogs/log_channel.py	Sun Sep 13 01:15:56 2009 +0300
@@ -0,0 +1,54 @@
+"""
+    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, )
+