A bunch of more fixes.

- Update README
- Remove some spurious comments here and there
- Fix flake8 errors.
This commit is contained in:
Abhilash Raj 2021-05-31 22:43:37 -07:00
parent eedb06f0ed
commit 7a3a48a56f
No known key found for this signature in database
GPG Key ID: 9D9B2BA061D0A67C
6 changed files with 21 additions and 22 deletions

View File

@ -25,13 +25,13 @@ Following packages are *required*:
* WeeChat (version >= 0.3.7) on local or remote machine, with relay plugin * WeeChat (version >= 0.3.7) on local or remote machine, with relay plugin
enabled and listening on a port with protocol "weechat" enabled and listening on a port with protocol "weechat"
* Python 2.x >= 2.6 * Python 3.7+
* PySide (recommended, packages: python.pyside.*) or PyQt4 (python-qt4) * PySide6
=== Install via source distribution === Install via source distribution
---- ----
$ python setup.py install $ pip install .
---- ----
== WeeChat setup == WeeChat setup

View File

@ -19,8 +19,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with QWeeChat. If not, see <http://www.gnu.org/licenses/>. # along with QWeeChat. If not, see <http://www.gnu.org/licenses/>.
# #
import traceback
from pkg_resources import resource_filename from pkg_resources import resource_filename
from qweechat.chat import ChatTextEdit from qweechat.chat import ChatTextEdit
from qweechat.input import InputLineEdit from qweechat.input import InputLineEdit
@ -169,7 +167,7 @@ class Buffer(QtCore.QObject):
try: try:
self.widget.set_title( self.widget.set_title(
color.remove(self.data['title'])) color.remove(self.data['title']))
except Exception as e: # noqa: E722 except Exception: # noqa: E722
# TODO: Debug print the exception to be fixed. # TODO: Debug print the exception to be fixed.
# traceback.print_exc() # traceback.print_exc()
self.widget.set_title(None) self.widget.set_title(None)
@ -178,7 +176,7 @@ class Buffer(QtCore.QObject):
"""Update prompt.""" """Update prompt."""
try: try:
self.widget.set_prompt(self.data['local_variables']['nick']) self.widget.set_prompt(self.data['local_variables']['nick'])
except Exception as e: # noqa: E722 except Exception: # noqa: E722
self.widget.set_prompt(None) self.widget.set_prompt(None)
def input_text_sent(self, text): def input_text_sent(self, text):

View File

@ -23,10 +23,8 @@
import struct import struct
from qweechat import config from qweechat import config
from PySide6 import QtCore, QtNetwork from PySide6 import QtCore, QtNetwork
from PySide6.QtCore import QObject, Signal from PySide6.QtCore import Signal
# QtCore = qt_compat.import_module('QtCore')
# QtNetwork = qt_compat.import_module('QtNetwork')
_PROTO_INIT_CMD = ['init password=%(password)s'] _PROTO_INIT_CMD = ['init password=%(password)s']

View File

@ -46,9 +46,7 @@ from qweechat.debug import DebugDialog
from qweechat.about import AboutDialog from qweechat.about import AboutDialog
from qweechat.version import qweechat_version from qweechat.version import qweechat_version
from PySide6.QtWidgets import ( from PySide6.QtWidgets import QApplication
QApplication, QLabel, QPushButton, QVBoxLayout, QWidget)
from PySide6.QtCore import Qt, Slot
from PySide6 import QtGui, QtWidgets, QtCore from PySide6 import QtGui, QtWidgets, QtCore
@ -331,7 +329,7 @@ class MainWindow(QtWidgets.QMainWindow):
'message uncompressed (%d bytes):\n%s' 'message uncompressed (%d bytes):\n%s'
% (message.size_uncompressed, % (message.size_uncompressed,
protocol.hex_and_ascii(message.uncompressed, 20)), protocol.hex_and_ascii(message.uncompressed, 20)),
forcecolor='#008800') forcecolor='#008800')
self.debug_display(0, '', 'Message: %s' % message) self.debug_display(0, '', 'Message: %s' % message)
self.parse_message(message) self.parse_message(message)
except Exception: # noqa: E722 except Exception: # noqa: E722
@ -516,10 +514,14 @@ class MainWindow(QtWidgets.QMainWindow):
def insert_buffer(self, index, buf): def insert_buffer(self, index, buf):
"""Insert a buffer in list.""" """Insert a buffer in list."""
self.buffers.insert(index, buf) self.buffers.insert(index, buf)
self.list_buffers.insertItem(index, '%d. %s' self.list_buffers.insertItem(index, '%s'
% (buf.data['number'], % (buf.data['local_variables']['name']))
buf.data['full_name']))
self.stacked_buffers.insertWidget(index, buf.widget) self.stacked_buffers.insertWidget(index, buf.widget)
self._reorder_buffers()
def _reorder_buffers(self):
"""Order buffers by server."""
pass
def remove_buffer(self, index): def remove_buffer(self, index):
"""Remove a buffer.""" """Remove a buffer."""
@ -553,6 +555,7 @@ class MainWindow(QtWidgets.QMainWindow):
config.write(self.config) config.write(self.config)
QtWidgets.QMainWindow.closeEvent(self, event) QtWidgets.QMainWindow.closeEvent(self, event)
def main(): def main():
app = QApplication(sys.argv) app = QApplication(sys.argv)
app.setStyle(QtWidgets.QStyleFactory.create('Cleanlooks')) app.setStyle(QtWidgets.QStyleFactory.create('Cleanlooks'))

View File

@ -34,6 +34,7 @@ import collections
import struct import struct
import zlib import zlib
class WeechatDict(collections.OrderedDict): class WeechatDict(collections.OrderedDict):
def __str__(self): def __str__(self):
return '{%s}' % ', '.join( return '{%s}' % ', '.join(
@ -314,7 +315,7 @@ class Protocol:
uncompressed = zlib.decompress(self.data[5:]) uncompressed = zlib.decompress(self.data[5:])
size_uncompressed = len(uncompressed) + 5 size_uncompressed = len(uncompressed) + 5
uncompressed = b'%s%s%s' % (struct.pack('>i', size_uncompressed), uncompressed = b'%s%s%s' % (struct.pack('>i', size_uncompressed),
struct.pack('b', 0), uncompressed) struct.pack('b', 0), uncompressed)
self.data = uncompressed self.data = uncompressed
else: else:
uncompressed = self.data[:] uncompressed = self.data[:]
@ -343,7 +344,7 @@ def hex_and_ascii(data, bytes_per_line=10):
for i in range(num_lines): for i in range(num_lines):
str_hex = [] str_hex = []
str_ascii = [] str_ascii = []
for j in range(bytes_per_line): # data[i*bytes_per_line:(i*bytes_per_line)+bytes_per_line]: for j in range(bytes_per_line):
# We can't easily iterate over individual bytes, so we are going to # We can't easily iterate over individual bytes, so we are going to
# do it this way. # do it this way.
index = (i*bytes_per_line) + j index = (i*bytes_per_line) + j

View File

@ -24,8 +24,6 @@
Command-line program for testing WeeChat/relay protocol. Command-line program for testing WeeChat/relay protocol.
""" """
import argparse import argparse
import os import os
import select import select
@ -80,7 +78,8 @@ class TestProto(object):
if msg == b'quit': if msg == b'quit':
self.has_quit = True self.has_quit = True
self.sock.sendall(msg + b'\n') self.sock.sendall(msg + b'\n')
sys.stdout.write((b'\x1b[33m<-- ' + msg + b'\x1b[0m\n').decode()) sys.stdout.write(
(b'\x1b[33m<-- ' + msg + b'\x1b[0m\n').decode())
except: # noqa: E722 except: # noqa: E722
traceback.print_exc() traceback.print_exc()
print('Failed to send message') print('Failed to send message')