Replace QString with str

This commit is contained in:
Dpeta 2023-02-19 19:36:53 +01:00
parent 70ea19e839
commit f6c5c1e804
No known key found for this signature in database
GPG key ID: 51227517CEA0030C
4 changed files with 41 additions and 48 deletions

View file

@ -30,9 +30,6 @@ PchumLog = logging.getLogger("pchumLogger")
_valid_memo_msg_start = re.compile( _valid_memo_msg_start = re.compile(
r"^<c=((\d+,\d+,\d+)|(#([a-fA-F0-9]{6})|(#[a-fA-F0-9]{3})))>([A-Z]{3}):\s" r"^<c=((\d+,\d+,\d+)|(#([a-fA-F0-9]{6})|(#[a-fA-F0-9]{3})))>([A-Z]{3}):\s"
) )
# Python 3
QString = str
def delta2txt(d, format="pc"): def delta2txt(d, format="pc"):
if isinstance(d, mysteryTime): if isinstance(d, mysteryTime):
@ -1439,7 +1436,7 @@ class PesterMemo(PesterConvo):
irc_compatible=self.mainwindow.config.irc_compatibility_mode(), irc_compatible=self.mainwindow.config.irc_compatibility_mode(),
) )
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(str)
def namesUpdated(self, channel): def namesUpdated(self, channel):
c = str(channel) c = str(channel)
if c.lower() != self.channel.lower(): if c.lower() != self.channel.lower():
@ -1451,13 +1448,13 @@ class PesterMemo(PesterConvo):
for n in self.mainwindow.namesdb[self.channel]: for n in self.mainwindow.namesdb[self.channel]:
self.addUser(n) self.addUser(n)
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(str, str)
def modesUpdated(self, channel, modes): def modesUpdated(self, channel, modes):
PchumLog.debug("modesUpdated(%s, %s)", channel, modes) PchumLog.debug("modesUpdated(%s, %s)", channel, modes)
if channel.lower() == self.channel.lower(): if channel.lower() == self.channel.lower():
self.updateChanModes(modes, None) self.updateChanModes(modes, None)
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(str)
def closeInviteOnly(self, channel): def closeInviteOnly(self, channel):
c = str(channel) c = str(channel)
if c.lower() == self.channel.lower(): if c.lower() == self.channel.lower():
@ -1480,7 +1477,7 @@ class PesterMemo(PesterConvo):
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.exec() msgbox.exec()
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(str, str)
def closeForbidden(self, channel, reason): def closeForbidden(self, channel, reason):
c = str(channel) c = str(channel)
if c.lower() == self.channel.lower(): if c.lower() == self.channel.lower():
@ -1571,7 +1568,7 @@ class PesterMemo(PesterConvo):
self.mainwindow.chatlog.log(self.channel, msg) self.mainwindow.chatlog.log(self.channel, msg)
del self.netsplit del self.netsplit
@QtCore.pyqtSlot(QString, QString, QString) @QtCore.pyqtSlot(str, str, str)
def userPresentChange(self, handle, channel, update): def userPresentChange(self, handle, channel, update):
# print("handle: %s, channel: %s, update: %s" % (handle, channel, update)) # print("handle: %s, channel: %s, update: %s" % (handle, channel, update))
h = str(handle) h = str(handle)

View file

@ -19,7 +19,6 @@ from version import _pcVersion
from convo import PesterInput, PesterText from convo import PesterInput, PesterText
from parsetools import lexMessage from parsetools import lexMessage
QString = str
_datadir = ostools.getDataDir() _datadir = ostools.getDataDir()
# Logger # Logger
PchumLog = logging.getLogger("pchumLogger") PchumLog = logging.getLogger("pchumLogger")
@ -1815,7 +1814,7 @@ class PesterUserlist(QtWidgets.QDialog):
self.searchbox = QtWidgets.QLineEdit(self) self.searchbox = QtWidgets.QLineEdit(self)
# self.searchbox.setStyleSheet(theme["convo/input/style"]) # which style is better? # self.searchbox.setStyleSheet(theme["convo/input/style"]) # which style is better?
self.searchbox.setPlaceholderText("Search") self.searchbox.setPlaceholderText("Search")
self.searchbox.textChanged["QString"].connect(self.updateUsers) self.searchbox.textChanged[str].connect(self.updateUsers)
self.label = QtWidgets.QLabel("USERLIST") self.label = QtWidgets.QLabel("USERLIST")
self.userarea = RightClickList(self) self.userarea = RightClickList(self)
@ -1847,7 +1846,7 @@ class PesterUserlist(QtWidgets.QDialog):
self.mainwindow.namesUpdated.connect(self.updateUsers) self.mainwindow.namesUpdated.connect(self.updateUsers)
self.mainwindow.userPresentSignal["QString", "QString", "QString"].connect( self.mainwindow.userPresentSignal[str, str, str].connect(
self.updateUserPresent self.updateUserPresent
) )
self.updateUsers() self.updateUsers()
@ -1876,7 +1875,7 @@ class PesterUserlist(QtWidgets.QDialog):
self.userarea.addItem(item) self.userarea.addItem(item)
self.userarea.sortItems() self.userarea.sortItems()
@QtCore.pyqtSlot(QString, QString, QString) @QtCore.pyqtSlot(str, str, str)
def updateUserPresent(self, handle, channel, update): def updateUserPresent(self, handle, channel, update):
h = str(handle) h = str(handle)
c = str(channel) c = str(channel)
@ -1928,8 +1927,8 @@ class PesterUserlist(QtWidgets.QDialog):
return return
self.pesterChum.emit(cur.text()) self.pesterChum.emit(cur.text())
addChum = QtCore.pyqtSignal("QString") addChum = QtCore.pyqtSignal(str)
pesterChum = QtCore.pyqtSignal("QString") pesterChum = QtCore.pyqtSignal(str)
class MemoListItem(QtWidgets.QTreeWidgetItem): class MemoListItem(QtWidgets.QTreeWidgetItem):

View file

@ -24,7 +24,6 @@ PchumLog = logging.getLogger("pchumLogger")
# I'll clean up the things that are no longer needed once the transition is # I'll clean up the things that are no longer needed once the transition is
# actually finished. # actually finished.
QString = str
_ctag_begin = re.compile(r"(?i)<c=(.*?)>") _ctag_begin = re.compile(r"(?i)<c=(.*?)>")
# _gtag_begin = re.compile(r"(?i)<g[a-f]>") # _gtag_begin = re.compile(r"(?i)<g[a-f]>")
@ -829,7 +828,7 @@ def kxhandleInput(ctx, text=None, flavor=None, irc_compatible=False):
# if ceased, rebegin # if ceased, rebegin
if hasattr(ctx, "chumopen") and not ctx.chumopen: if hasattr(ctx, "chumopen") and not ctx.chumopen:
if not irc_compatible: if not irc_compatible:
ctx.mainwindow.newConvoStarted.emit(QString(ctx.title()), True) ctx.mainwindow.newConvoStarted.emit(str(ctx.title()), True)
ctx.setChumOpen(True) ctx.setChumOpen(True)
# Post-process and send the messages. # Post-process and send the messages.

View file

@ -163,8 +163,6 @@ BOTNAMES.extend(SERVICES)
_CONSOLE = False _CONSOLE = False
_CONSOLE_ENV = {} _CONSOLE_ENV = {}
_CONSOLE_ENV["PAPP"] = None _CONSOLE_ENV["PAPP"] = None
# Python 3
QString = str
# Command line arguments # Command line arguments
_ARGUMENTS = parser.parse_args() _ARGUMENTS = parser.parse_args()
@ -1211,7 +1209,7 @@ class trollSlum(chumArea):
# TypeError: connect() failed between triggered(bool) and unblockChumSignal() # TypeError: connect() failed between triggered(bool) and unblockChumSignal()
# I'm not sure why this was here in the first place- # I'm not sure why this was here in the first place-
# Does removing it break anything else...? # Does removing it break anything else...?
# unblockChumSignal = QtCore.pyqtSignal('QString') # unblockChumSignal = QtCore.pyqtSignal(str)
class TrollSlumWindow(QtWidgets.QFrame): class TrollSlumWindow(QtWidgets.QFrame):
@ -1707,7 +1705,7 @@ class PesterWindow(MovingWindow):
# We probably tried to interact with a call not available on this kernel. # We probably tried to interact with a call not available on this kernel.
PchumLog.exception("") PchumLog.exception("")
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(str, str)
def updateMsg(self, ver, url): def updateMsg(self, ver, url):
if not hasattr(self, "updatemenu"): if not hasattr(self, "updatemenu"):
self.updatemenu = None self.updatemenu = None
@ -2032,13 +2030,13 @@ class PesterWindow(MovingWindow):
) )
convoWindow.windowClosed[str].connect(self.closeConvo) convoWindow.windowClosed[str].connect(self.closeConvo)
self.convos[chum.handle] = convoWindow self.convos[chum.handle] = convoWindow
if chum.handle.upper() in BOTNAMES or self.config.irc_compatibility_mode(): if chum.handle.upper() in BOTNAMES:
convoWindow.toggleQuirks(True) convoWindow.toggleQuirks(True)
convoWindow.quirksOff.setChecked(True) convoWindow.quirksOff.setChecked(True)
if str(chum.handle).upper() in CUSTOMBOTS: if not self.config.irc_compatibility_mode() or chum.handle.upper() in CUSTOMBOTS:
self.newConvoStarted.emit(QString(chum.handle), initiated) self.newConvoStarted.emit(chum.handle, initiated)
else: else:
self.newConvoStarted.emit(QString(chum.handle), initiated) self.newConvoStarted.emit(chum.handle, initiated)
convoWindow.show() convoWindow.show()
def createTabWindow(self): def createTabWindow(self):
@ -2608,7 +2606,7 @@ class PesterWindow(MovingWindow):
chum.color = color chum.color = color
self.newConversation(chum) self.newConversation(chum)
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(str)
def closeConvo(self, handle): def closeConvo(self, handle):
h = str(handle) h = str(handle)
try: try:
@ -2633,7 +2631,7 @@ class PesterWindow(MovingWindow):
self.chatlog.finish(h) self.chatlog.finish(h)
del self.convos[h] del self.convos[h]
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(str)
def closeMemo(self, channel): def closeMemo(self, channel):
c = str(channel) c = str(channel)
self.chatlog.finish(c) self.chatlog.finish(c)
@ -2656,28 +2654,28 @@ class PesterWindow(MovingWindow):
del self.tabmemo del self.tabmemo
self.tabmemo = None self.tabmemo = None
@QtCore.pyqtSlot(QString, Mood) @QtCore.pyqtSlot(str, Mood)
def updateMoodSlot(self, handle, mood): def updateMoodSlot(self, handle, mood):
h = str(handle) h = str(handle)
self.updateMood(h, mood) self.updateMood(h, mood)
@QtCore.pyqtSlot(QString, QtGui.QColor) @QtCore.pyqtSlot(str, QtGui.QColor)
def updateColorSlot(self, handle, color): def updateColorSlot(self, handle, color):
PchumLog.debug("updateColorSlot(%s, %s)", handle, color) PchumLog.debug("updateColorSlot(%s, %s)", handle, color)
self.changeColor(handle, color) self.changeColor(handle, color)
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(str, str)
def deliverMessage(self, handle, msg): def deliverMessage(self, handle, msg):
h = str(handle) h = str(handle)
m = str(msg) m = str(msg)
self.newMessage(h, m) self.newMessage(h, m)
@QtCore.pyqtSlot(QString, QString, QString) @QtCore.pyqtSlot(str, str, str)
def deliverMemo(self, chan, handle, msg): def deliverMemo(self, chan, handle, msg):
(c, h, m) = (str(chan), str(handle), str(msg)) (c, h, m) = (str(chan), str(handle), str(msg))
self.newMemoMsg(c, h, m) self.newMemoMsg(c, h, m)
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(str, str)
def deliverNotice(self, handle, msg): def deliverNotice(self, handle, msg):
h = str(handle) h = str(handle)
m = str(msg) m = str(msg)
@ -2710,7 +2708,7 @@ class PesterWindow(MovingWindow):
t = self.tm.Toast("%s:" % h, m) t = self.tm.Toast("%s:" % h, m)
t.show() t.show()
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(str, str)
def deliverInvite(self, handle, channel): def deliverInvite(self, handle, channel):
msgbox = QtWidgets.QMessageBox() msgbox = QtWidgets.QMessageBox()
msgbox.setText("You're invited!") msgbox.setText("You're invited!")
@ -2739,25 +2737,25 @@ class PesterWindow(MovingWindow):
if ret == QtWidgets.QMessageBox.StandardButton.Ok: if ret == QtWidgets.QMessageBox.StandardButton.Ok:
self.newMemo(str(channel), "+0:00") self.newMemo(str(channel), "+0:00")
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(str)
def chanInviteOnly(self, channel): def chanInviteOnly(self, channel):
self.inviteOnlyChan.emit(channel) self.inviteOnlyChan.emit(channel)
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(str, str)
def cannotSendToChan(self, channel, msg): def cannotSendToChan(self, channel, msg):
self.deliverMemo(channel, "ChanServ", msg) self.deliverMemo(channel, "ChanServ", msg)
# Unused and redefined. # Unused and redefined.
# @QtCore.pyqtSlot(QString, QString) # @QtCore.pyqtSlot(str, str)
# def modesUpdated(self, channel, modes): # def modesUpdated(self, channel, modes):
# self.modesUpdated.emit(channel, modes) # self.modesUpdated.emit(channel, modes)
@QtCore.pyqtSlot(QString, QString, QString) @QtCore.pyqtSlot(str, str, str)
def timeCommand(self, chan, handle, command): def timeCommand(self, chan, handle, command):
(c, h, cmd) = (str(chan), str(handle), str(command)) (c, h, cmd) = (str(chan), str(handle), str(command))
if self.memos[c]: if self.memos[c]:
self.memos[c].timeUpdate(h, cmd) self.memos[c].timeUpdate(h, cmd)
@QtCore.pyqtSlot(QString, QString, QString) @QtCore.pyqtSlot(str, str, str)
def quirkDisable(self, channel, msg, op): def quirkDisable(self, channel, msg, op):
(c, msg, op) = (str(channel), str(msg), str(op)) (c, msg, op) = (str(channel), str(msg), str(op))
if c not in self.memos: if c not in self.memos:
@ -2765,7 +2763,7 @@ class PesterWindow(MovingWindow):
memo = self.memos[c] memo = self.memos[c]
memo.quirkDisable(op, msg) memo.quirkDisable(op, msg)
@QtCore.pyqtSlot(QString, PesterList) @QtCore.pyqtSlot(str, PesterList)
def updateNames(self, channel, names): def updateNames(self, channel, names):
c = str(channel) c = str(channel)
# update name DB # update name DB
@ -2773,7 +2771,7 @@ class PesterWindow(MovingWindow):
# warn interested party of names # warn interested party of names
self.namesUpdated.emit(c) self.namesUpdated.emit(c)
@QtCore.pyqtSlot(QString, QString, QString) @QtCore.pyqtSlot(str, str, str)
def userPresentUpdate(self, handle, channel, update): def userPresentUpdate(self, handle, channel, update):
c = str(channel) c = str(channel)
n = str(handle) n = str(handle)
@ -2861,7 +2859,7 @@ class PesterWindow(MovingWindow):
self.addChum(chum) self.addChum(chum)
self.addchumdialog = None self.addchumdialog = None
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(str)
def removeChum(self, chumlisting): def removeChum(self, chumlisting):
self.config.removeChum(chumlisting) self.config.removeChum(chumlisting)
@ -2874,7 +2872,7 @@ class PesterWindow(MovingWindow):
if ok: if ok:
self.sendMessage.emit("REPORT {} {}".format(handle, reason), "calSprite") self.sendMessage.emit("REPORT {} {}".format(handle, reason), "calSprite")
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(str)
def blockChum(self, handle): def blockChum(self, handle):
h = str(handle) h = str(handle)
self.config.addBlocklist(h) self.config.addBlocklist(h)
@ -2897,7 +2895,7 @@ class PesterWindow(MovingWindow):
if not self.config.irc_compatibility_mode(): if not self.config.irc_compatibility_mode():
self.blockedChum.emit(handle) self.blockedChum.emit(handle)
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(str)
def unblockChum(self, handle): def unblockChum(self, handle):
h = str(handle) h = str(handle)
self.config.delBlocklist(h) self.config.delBlocklist(h)
@ -3103,13 +3101,13 @@ class PesterWindow(MovingWindow):
self.requestNames.emit("#pesterchum") self.requestNames.emit("#pesterchum")
self.allusers.show() self.allusers.show()
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(str)
def userListAdd(self, handle): def userListAdd(self, handle):
h = str(handle) h = str(handle)
chum = PesterProfile(h, chumdb=self.chumdb) chum = PesterProfile(h, chumdb=self.chumdb)
self.addChum(chum) self.addChum(chum)
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(str)
def userListPester(self, handle): def userListPester(self, handle):
h = str(handle) h = str(handle)
self.newConversation(h) self.newConversation(h)
@ -3724,7 +3722,7 @@ class PesterWindow(MovingWindow):
) )
) )
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(str, str)
def nickCollision(self, handle, tmphandle): def nickCollision(self, handle, tmphandle):
if hasattr(self, "loadingscreen"): if hasattr(self, "loadingscreen"):
if self.loadingscreen is not None: if self.loadingscreen is not None:
@ -3747,7 +3745,7 @@ class PesterWindow(MovingWindow):
h = str(handle) h = str(handle)
self.changeProfile(collision=h) self.changeProfile(collision=h)
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(str, str)
def getSvsnickedOn(self, oldhandle, newhandle): def getSvsnickedOn(self, oldhandle, newhandle):
if hasattr(self, "loadingscreen"): if hasattr(self, "loadingscreen"):
if self.loadingscreen is not None: if self.loadingscreen is not None:
@ -3765,7 +3763,7 @@ class PesterWindow(MovingWindow):
if not self.chooseprofile: if not self.chooseprofile:
self.changeProfile(svsnick=(oldhandle, newhandle)) self.changeProfile(svsnick=(oldhandle, newhandle))
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(str)
def myHandleChanged(self, handle): def myHandleChanged(self, handle):
# Update nick in channels # Update nick in channels
for memo in self.memos.keys(): for memo in self.memos.keys():
@ -3800,7 +3798,7 @@ class PesterWindow(MovingWindow):
# msg.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}") # msg.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")
msg.exec() msg.exec()
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(str, str)
def forbiddenchannel(self, channel, reason): def forbiddenchannel(self, channel, reason):
self.forbiddenChan.emit(channel, reason) self.forbiddenChan.emit(channel, reason)