From: W. Trevor King Date: Fri, 30 May 2014 00:13:57 +0000 (-0700) Subject: irkerd: Make Dispatcher._target public (rename to .target) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4d67e3b41c2941036d4fef468cdb3240cbbe7d16;p=irker.git irkerd: Make Dispatcher._target public (rename to .target) We'll need this to find the dispatcher.target.connection() key to remove entries from IrkerProtocol._dispatchers. --- diff --git a/irkerd b/irkerd index 070e0e9..61803f4 100755 --- 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)