当前位置: 首页>>代码示例>>Python>>正文


Python Network.desync_weechat方法代码示例

本文整理汇总了Python中network.Network.desync_weechat方法的典型用法代码示例。如果您正苦于以下问题:Python Network.desync_weechat方法的具体用法?Python Network.desync_weechat怎么用?Python Network.desync_weechat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在network.Network的用法示例。


在下文中一共展示了Network.desync_weechat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MainWindow

# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import desync_weechat [as 别名]

#.........这里部分代码省略.........
                renumber_queue.append((b, 1, None))
            if msgid in ['_buffer_moved', '_buffer_closing',
                         '_buffer_merged'] and n >= buf.data['number']:
                renumber_queue.append((b, -1, None))
            if msgid == '_buffer_moved' and n == item['number']:
                if n >= buf.data['number']:
                    renumber_queue.append((b, -1, None))
            if n == buf.data['number']:
                if msgid == '_buffer_closing' and b.pointer != buf.pointer:
                    return
                elif msgid == '_buffer_moved':
                    renumber_queue.append((b, None, item['number']))
        for b, mod, rep in renumber_queue:
            b.data['number'] = rep if rep else (b.data['number'] + mod)
        buf.data['number'] = item['number'] if 'number' in item else 0

    def parse_message(self, message):
        """Parse a WeeChat message."""
        if message.msgid.startswith('debug'):
            self.debug_display(0, '', '(debug message, ignored)')
        elif message.msgid == 'listbuffers':
            self._parse_listbuffers(message)
        elif message.msgid in ('listlines', '_buffer_line_added'):
            self._parse_line(message)
        elif message.msgid in ('_nicklist', 'nicklist'):
            self._parse_nicklist(message)
        elif message.msgid == '_nicklist_diff':
            self._parse_nicklist_diff(message)
        elif message.msgid == '_buffer_opened':
            self._parse_buffer_opened(message)
        elif message.msgid.startswith('_buffer_'):
            self._parse_buffer(message)
        elif message.msgid == '_upgrade':
            self.network.desync_weechat()
        elif message.msgid == '_upgrade_ended':
            self.network.sync_weechat()
        elif message.msgid == 'hotlist':
            self._parse_hotlist(message)
        elif message.msgid == '_pong':
            # Workaround for "hotlist" not being sent when empty before 1.6
            if self._last_msgid != "hotlist":
                self._parse_hotlist(message)
        elif message.msgid == 'id':
            self.network.set_info(message)
        self._last_msgid = message.msgid

    def create_buffer(self, item):
        """Create a new buffer."""
        buf = Buffer(item)
        buf.bufferInput.connect(self.buffer_input)
        buf.widget.input.bufferSwitchPrev.connect(
            self.switch_buffers.switch_prev_buffer)
        buf.widget.input.bufferSwitchNext.connect(
            self.switch_buffers.switch_next_buffer)
        buf.widget.input.bufferSwitchActive.connect(
            self.switch_buffers.switch_active_buffer)
        buf.widget.input.bufferSwitchActivePrevious.connect(
            self.switch_buffers.switch_active_buffer_previous)
        return buf

    def insert_buffer(self, index, buf):
        """Insert a buffer in list."""
        self.buffers.insert(index, buf)
        self.stacked_buffers.insertWidget(index, buf.widget)
        self.switch_buffers.insert(index, buf)
开发者ID:rickybrent,项目名称:qweechat,代码行数:69,代码来源:qweechat.py

示例2: MainWindow

# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import desync_weechat [as 别名]

#.........这里部分代码省略.........
                index = [i for i, b in enumerate(self.buffers)
                         if b.pointer() == item['__path'][0]]
                if not index:
                    continue
                index = index[0]
                if message.msgid == '_buffer_type_changed':
                    self.buffers[index].data['type'] = item['type']
                elif message.msgid in ('_buffer_moved', '_buffer_merged',
                                       '_buffer_unmerged'):
                    buf = self.buffers[index]
                    buf.data['number'] = item['number']
                    self.remove_buffer(index)
                    index2 = self.find_buffer_index_for_insert(
                        item['next_buffer'])
                    self.insert_buffer(index2, buf)
                elif message.msgid == '_buffer_renamed':
                    self.buffers[index].data['full_name'] = item['full_name']
                    self.buffers[index].data['short_name'] = item['short_name']
                elif message.msgid == '_buffer_title_changed':
                    self.buffers[index].data['title'] = item['title']
                    self.buffers[index].update_title()
                elif message.msgid == '_buffer_cleared':
                    self.buffers[index].widget.chat.clear()
                elif message.msgid.startswith('_buffer_localvar_'):
                    self.buffers[index].data['local_variables'] = \
                        item['local_variables']
                    self.buffers[index].update_prompt()
                elif message.msgid == '_buffer_closing':
                    self.remove_buffer(index)

    def parse_message(self, message):
        """Parse a WeeChat message."""
        if message.msgid.startswith('debug'):
            self.debug_display(0, '', '(debug message, ignored)')
        elif message.msgid == 'listbuffers':
            self._parse_listbuffers(message)
        elif message.msgid in ('listlines', '_buffer_line_added'):
            self._parse_line(message)
        elif message.msgid in ('_nicklist', 'nicklist'):
            self._parse_nicklist(message)
        elif message.msgid == '_nicklist_diff':
            self._parse_nicklist_diff(message)
        elif message.msgid == '_buffer_opened':
            self._parse_buffer_opened(message)
        elif message.msgid.startswith('_buffer_'):
            self._parse_buffer(message)
        elif message.msgid == '_upgrade':
            self.network.desync_weechat()
        elif message.msgid == '_upgrade_ended':
            self.network.sync_weechat()

    def create_buffer(self, item):
        """Create a new buffer."""
        buf = Buffer(item)
        buf.bufferInput.connect(self.buffer_input)
        buf.widget.input.bufferSwitchPrev.connect(
            self.list_buffers.switch_prev_buffer)
        buf.widget.input.bufferSwitchNext.connect(
            self.list_buffers.switch_next_buffer)
        return buf

    def insert_buffer(self, index, buf):
        """Insert a buffer in list."""
        self.buffers.insert(index, buf)
        self.list_buffers.insertItem(index, '%d. %s'
                                     % (buf.data['number'],
                                        buf.data['full_name'].decode('utf-8')))
        self.stacked_buffers.insertWidget(index, buf.widget)

    def remove_buffer(self, index):
        """Remove a buffer."""
        if self.list_buffers.currentRow == index and index > 0:
            self.list_buffers.setCurrentRow(index - 1)
        self.list_buffers.takeItem(index)
        self.stacked_buffers.removeWidget(self.stacked_buffers.widget(index))
        self.buffers.pop(index)

    def find_buffer_index_for_insert(self, next_buffer):
        """Find position to insert a buffer in list."""
        index = -1
        if next_buffer == '0x0':
            index = len(self.buffers)
        else:
            index = [i for i, b in enumerate(self.buffers)
                     if b.pointer() == next_buffer]
            if index:
                index = index[0]
        if index < 0:
            print('Warning: unable to find position for buffer, using end of '
                  'list by default')
            index = len(self.buffers)
        return index

    def closeEvent(self, event):
        """Called when QWeeChat window is closed."""
        self.network.disconnect_weechat()
        if self.debug_dialog:
            self.debug_dialog.close()
        config.write(self.config)
        QtGui.QMainWindow.closeEvent(self, event)
开发者ID:caustin,项目名称:qweechat,代码行数:104,代码来源:qweechat.py


注:本文中的network.Network.desync_weechat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。