irkerd: Make Dispatcher._target public (rename to .target)
authorW. Trevor King <wking@tremily.us>
Fri, 30 May 2014 00:13:57 +0000 (17:13 -0700)
committerW. Trevor King <wking@tremily.us>
Fri, 30 May 2014 23:24:18 +0000 (16:24 -0700)
We'll need this to find the dispatcher.target.connection() key to
remove entries from IrkerProtocol._dispatchers.

irkerd

diff --git a/irkerd b/irkerd
index 070e0e9e25048a03db422de8fe112e25f2915ad9..61803f45737ec65554a822e7563b6fa268b786e5 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -971,7 +971,7 @@ class Dispatcher(list):
     """
     def __init__(self, target, reconnect_delay=60, **kwargs):
         super(Dispatcher, self).__init__()
-        self._target = target
+        self.target = target
         self._reconnect_delay = reconnect_delay
         self._kwargs = kwargs
         self._channels = Channels()
@@ -979,16 +979,16 @@ class Dispatcher(list):
 
     def __str__(self):
         "Represent this instance as a string"
-        return str(self._target)
+        return str(self.target)
 
     def __repr__(self):
         "Represent this instance as a detailed string"
-        return '<{} {}>'.format(type(self).__name__, self._target)
+        return '<{} {}>'.format(type(self).__name__, self.target)
 
     def send_message(self, target, message):
-        if target.connection() != self._target.connection():
+        if target.connection() != self.target.connection():
             raise ValueError('target missmatch: {} != {}'.format(
-                target, self._target))
+                target, self.target))
         try:
             channel = self._channels[target.channel]
         except KeyError:
@@ -1025,17 +1025,17 @@ class Dispatcher(list):
         loop = asyncio.get_event_loop()
         coroutine = loop.create_connection(
             protocol_factory=lambda: IRCProtocol(
-                name=str(self._target),
-                password=self._target.password,
-                username=self._target.username,
+                name=str(self.target),
+                password=self.target.password,
+                username=self.target.username,
                 ready_callbacks=[self._join_channels],
                 channel_join_callbacks=[self._drain_queue],
                 channel_part_callbacks=[self._remove_channel],
                 connection_lost_callbacks=[self._remove_connection],
                 **self._kwargs),
-            host=self._target.hostname,
-            port=self._target.port,
-            ssl=self._target.ssl)
+            host=self.target.hostname,
+            port=self.target.port,
+            ssl=self.target.ssl)
         task = asyncio.Task(coroutine)
         task.add_done_callback(self._connection_created)