eric6/Network/IRC/IrcChannelWidget.py

changeset 7255
d595f6f9cbf8
parent 7229
53054eb5b15a
child 7360
9190402e4505
--- a/eric6/Network/IRC/IrcChannelWidget.py	Sat Sep 21 17:41:22 2019 +0200
+++ b/eric6/Network/IRC/IrcChannelWidget.py	Sat Sep 21 18:30:02 2019 +0200
@@ -12,11 +12,14 @@
 
 import re
 
-from PyQt5.QtCore import pyqtSlot, pyqtSignal, QDateTime, QPoint, QFileInfo, \
-    QTimer, QUrl, QCoreApplication
+from PyQt5.QtCore import (
+    pyqtSlot, pyqtSignal, QDateTime, QPoint, QFileInfo, QTimer, QUrl,
+    QCoreApplication
+)
 from PyQt5.QtGui import QIcon, QPainter, QTextCursor, QDesktopServices
-from PyQt5.QtWidgets import QWidget, QListWidgetItem, QMenu, QApplication, \
-    QInputDialog, QLineEdit
+from PyQt5.QtWidgets import (
+    QWidget, QListWidgetItem, QMenu, QApplication, QInputDialog, QLineEdit
+)
 
 from E5Gui import E5MessageBox, E5FileDialog
 from E5Gui.E5Application import e5App
@@ -428,11 +431,15 @@
                 if cmd in ["MSG", "QUERY"]:
                     cmd = "PRIVMSG"
                     if len(msgList) > 1:
-                        if msgList[1].strip().lower() in \
-                                self.__serviceNamesLower:
-                            msg = "PRIVMSG " + \
-                                msgList[1].strip().lower() + \
+                        if (
+                            msgList[1].strip().lower() in
+                            self.__serviceNamesLower
+                        ):
+                            msg = (
+                                "PRIVMSG " +
+                                msgList[1].strip().lower() +
                                 " :" + " ".join(msgList[2:])
+                            )
                         else:
                             msg = "PRIVMSG {0} :{1}".format(
                                 msgList[1], " ".join(msgList[2:]))
@@ -681,8 +688,10 @@
                 self.__ui.showNotification(
                     UI.PixmapCache.getPixmap("irc48.png"),
                     self.tr("Channel Message"), msg)
-            elif Preferences.getIrc("NotifyNick") and \
-                    self.__userName.lower() in msg.lower():
+            elif (
+                Preferences.getIrc("NotifyNick") and
+                self.__userName.lower() in msg.lower()
+            ):
                 self.__ui.showNotification(
                     UI.PixmapCache.getPixmap("irc48.png"),
                     self.tr("Nick mentioned"), msg)
@@ -719,8 +728,10 @@
                     self.__name, match.group(2))
                 self.__addManagementMessage(
                     IrcChannelWidget.JoinIndicator, msg)
-            if Preferences.getIrc("ShowNotifications") and \
-               Preferences.getIrc("NotifyJoinPart"):
+            if (
+                Preferences.getIrc("ShowNotifications") and
+                Preferences.getIrc("NotifyJoinPart")
+            ):
                 self.__ui.showNotification(
                     UI.PixmapCache.getPixmap("irc48.png"),
                     self.tr("Join Channel"), msg)
@@ -752,8 +763,10 @@
                     match.group(1), self.__name, match.group(3))
                 self.__addManagementMessage(
                     IrcChannelWidget.LeaveIndicator, msg)
-            if Preferences.getIrc("ShowNotifications") and \
-               Preferences.getIrc("NotifyJoinPart"):
+            if (
+                Preferences.getIrc("ShowNotifications") and
+                Preferences.getIrc("NotifyJoinPart")
+            ):
                 self.__ui.showNotification(
                     UI.PixmapCache.getPixmap("irc48.png"),
                     self.tr("Leave Channel"), nmsg)
@@ -782,8 +795,10 @@
                     match.group(1), self.__name, ircFilter(match.group(2)))
                 self.__addManagementMessage(
                     IrcChannelWidget.MessageIndicator, msg)
-            if Preferences.getIrc("ShowNotifications") and \
-               Preferences.getIrc("NotifyJoinPart"):
+            if (
+                Preferences.getIrc("ShowNotifications") and
+                Preferences.getIrc("NotifyJoinPart")
+            ):
                 self.__ui.showNotification(
                     UI.PixmapCache.getPixmap("irc48.png"),
                     self.tr("Quit"), msg)
@@ -983,8 +998,8 @@
                 elif mode == "a":
                     if isPlus:
                         message = self.tr(
-                            "{0} sets the channel mode to 'anonymous'.")\
-                            .format(nick)
+                            "{0} sets the channel mode to 'anonymous'."
+                        ).format(nick)
                     else:
                         message = self.tr(
                             "{0} removes the 'anonymous' mode from the"
@@ -1019,8 +1034,8 @@
                 elif mode == "i":
                     if isPlus:
                         message = self.tr(
-                            "{0} sets the channel mode to 'invite only'.")\
-                            .format(nick)
+                            "{0} sets the channel mode to 'invite only'."
+                        ).format(nick)
                     else:
                         message = self.tr(
                             "{0} removes the 'invite only' mode from the"
@@ -1044,12 +1059,12 @@
                 elif mode == "m":
                     if isPlus:
                         message = self.tr(
-                            "{0} sets the channel mode to 'moderated'.")\
-                            .format(nick)
+                            "{0} sets the channel mode to 'moderated'."
+                        ).format(nick)
                     else:
                         message = self.tr(
-                            "{0} sets the channel mode to 'unmoderated'.")\
-                            .format(nick)
+                            "{0} sets the channel mode to 'unmoderated'."
+                        ).format(nick)
                 elif mode == "n":
                     if isPlus:
                         message = self.tr(
@@ -1062,40 +1077,40 @@
                 elif mode == "p":
                     if isPlus:
                         message = self.tr(
-                            "{0} sets the channel mode to 'private'.")\
-                            .format(nick)
+                            "{0} sets the channel mode to 'private'."
+                        ).format(nick)
                     else:
                         message = self.tr(
-                            "{0} sets the channel mode to 'public'.")\
-                            .format(nick)
+                            "{0} sets the channel mode to 'public'."
+                        ).format(nick)
                 elif mode == "q":
                     if isPlus:
                         message = self.tr(
-                            "{0} sets the channel mode to 'quiet'.")\
-                            .format(nick)
+                            "{0} sets the channel mode to 'quiet'."
+                        ).format(nick)
                     else:
                         message = self.tr(
-                            "{0} removes the 'quiet' mode from the channel.")\
-                            .format(nick)
+                            "{0} removes the 'quiet' mode from the channel."
+                        ).format(nick)
                 elif mode == "r":
                     continue
                 elif mode == "s":
                     if isPlus:
                         message = self.tr(
-                            "{0} sets the channel mode to 'secret'.")\
-                            .format(nick)
+                            "{0} sets the channel mode to 'secret'."
+                        ).format(nick)
                     else:
                         message = self.tr(
-                            "{0} sets the channel mode to 'visible'.")\
-                            .format(nick)
+                            "{0} sets the channel mode to 'visible'."
+                        ).format(nick)
                 elif mode == "t":
                     if isPlus:
                         message = self.tr(
                             "{0} switches on 'topic protection'.").format(nick)
                     else:
                         message = self.tr(
-                            "{0} switches off 'topic protection'.")\
-                            .format(nick)
+                            "{0} switches off 'topic protection'."
+                        ).format(nick)
                 elif mode == "I":
                     if isPlus:
                         message = self.tr(
@@ -1271,9 +1286,11 @@
         
         @param message message to be appended (string)
         """
-        if self.__hidden and \
-           self.__markerLine == "" and \
-           Preferences.getIrc("MarkPositionWhenHidden"):
+        if (
+            self.__hidden and
+            self.__markerLine == "" and
+            Preferences.getIrc("MarkPositionWhenHidden")
+        ):
             self.setMarkerLine()
         self.messages.append(message)
     
@@ -1282,11 +1299,12 @@
         Public method to draw a line to mark the current position.
         """
         self.unsetMarkerLine()
-        self.__markerLine = \
-            '<span style=" color:{0}; background-color:{1};">{2}</span>'\
+        self.__markerLine = (
+            '<span style=" color:{0}; background-color:{1};">{2}</span>'
             .format(Preferences.getIrc("MarkerLineForegroundColour"),
                     Preferences.getIrc("MarkerLineBackgroundColour"),
                     self.tr('--- New From Here ---'))
+        )
         self.messages.append(self.__markerLine)
     
     def unsetMarkerLine(self):
@@ -1398,29 +1416,24 @@
         Private slot to initialize the context menu of the messages pane.
         """
         self.__messagesMenu = QMenu(self)
-        self.__copyMessagesAct = \
-            self.__messagesMenu.addAction(
-                UI.PixmapCache.getIcon("editCopy.png"),
-                self.tr("Copy"), self.__copyMessages)
+        self.__copyMessagesAct = self.__messagesMenu.addAction(
+            UI.PixmapCache.getIcon("editCopy.png"),
+            self.tr("Copy"), self.__copyMessages)
         self.__messagesMenu.addSeparator()
-        self.__cutAllMessagesAct = \
-            self.__messagesMenu.addAction(
-                UI.PixmapCache.getIcon("editCut.png"),
-                self.tr("Cut all"), self.__cutAllMessages)
-        self.__copyAllMessagesAct = \
-            self.__messagesMenu.addAction(
-                UI.PixmapCache.getIcon("editCopy.png"),
-                self.tr("Copy all"), self.__copyAllMessages)
+        self.__cutAllMessagesAct = self.__messagesMenu.addAction(
+            UI.PixmapCache.getIcon("editCut.png"),
+            self.tr("Cut all"), self.__cutAllMessages)
+        self.__copyAllMessagesAct = self.__messagesMenu.addAction(
+            UI.PixmapCache.getIcon("editCopy.png"),
+            self.tr("Copy all"), self.__copyAllMessages)
         self.__messagesMenu.addSeparator()
-        self.__clearMessagesAct = \
-            self.__messagesMenu.addAction(
-                UI.PixmapCache.getIcon("editDelete.png"),
-                self.tr("Clear"), self.__clearMessages)
+        self.__clearMessagesAct = self.__messagesMenu.addAction(
+            UI.PixmapCache.getIcon("editDelete.png"),
+            self.tr("Clear"), self.__clearMessages)
         self.__messagesMenu.addSeparator()
-        self.__saveMessagesAct = \
-            self.__messagesMenu.addAction(
-                UI.PixmapCache.getIcon("fileSave.png"),
-                self.tr("Save"), self.__saveMessages)
+        self.__saveMessagesAct = self.__messagesMenu.addAction(
+            UI.PixmapCache.getIcon("fileSave.png"),
+            self.tr("Save"), self.__saveMessages)
         self.__messagesMenu.addSeparator()
         self.__setMarkerMessagesAct = self.__messagesMenu.addAction(
             self.tr("Mark Current Position"), self.setMarkerLine)
@@ -1657,8 +1670,10 @@
         # group(5)  user flags
         # group(6)  real name
         if match.group(1).lower() == self.__name.lower():
-            away = self.tr(" (Away)") if match.group(5).startswith("G") \
-                else ""
+            away = (
+                self.tr(" (Away)")
+                if match.group(5).startswith("G") else ""
+            )
             self.__addManagementMessage(
                 self.tr("Who"),
                 self.tr("{0} is {1}@{2} ({3}){4}").format(
@@ -1711,8 +1726,10 @@
             for channel in channelList:
                 if channel.startswith(("*", "&")):
                     adminChannels.append(channel[1:])
-                elif channel.startswith(("!", "~")) and \
-                        self.__ircWidget.isChannelName(channel[1:]):
+                elif (
+                    channel.startswith(("!", "~")) and
+                    self.__ircWidget.isChannelName(channel[1:])
+                ):
                     ownerChannels.append(channel[1:])
                 elif channel.startswith("@+"):
                     opChannels.append(channel[2:])

eric ide

mercurial