Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 2).

Tue, 13 Apr 2021 18:02:59 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 13 Apr 2021 18:02:59 +0200
changeset 8234
fcb6b4b96274
parent 8233
bad78a592cc2
child 8235
78e6d29eb773

Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 2).

eric6/DataViews/CodeMetrics.py file | annotate | diff | comparison | revisions
eric6/E5Gui/E5SingleApplication.py file | annotate | diff | comparison | revisions
eric6/E5Gui/E5TreeWidget.py file | annotate | diff | comparison | revisions
eric6/E5Gui/E5ZoomWidget.py file | annotate | diff | comparison | revisions
eric6/E5Network/E5SslInfoWidget.py file | annotate | diff | comparison | revisions
eric6/Graphics/AssociationItem.py file | annotate | diff | comparison | revisions
eric6/Graphics/ClassItem.py file | annotate | diff | comparison | revisions
eric6/Graphics/ImportsDiagramBuilder.py file | annotate | diff | comparison | revisions
eric6/Graphics/ModuleItem.py file | annotate | diff | comparison | revisions
eric6/MicroPython/EspFirmwareSelectionDialog.py file | annotate | diff | comparison | revisions
eric6/MicroPython/MicroPythonFileManagerWidget.py file | annotate | diff | comparison | revisions
eric6/MicroPython/MicroPythonFileSystemUtilities.py file | annotate | diff | comparison | revisions
eric6/MicroPython/MicroPythonWidget.py file | annotate | diff | comparison | revisions
eric6/MultiProject/MultiProject.py file | annotate | diff | comparison | revisions
eric6/Network/IRC/IrcNetworkEditDialog.py file | annotate | diff | comparison | revisions
eric6/Network/IRC/IrcNetworkListDialog.py file | annotate | diff | comparison | revisions
eric6/Network/IRC/IrcNetworkManager.py file | annotate | diff | comparison | revisions
eric6/PipInterface/Pip.py file | annotate | diff | comparison | revisions
eric6/PluginManager/PluginRepositoryDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py file | annotate | diff | comparison | revisions
eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/GoogleV1Engine.py file | annotate | diff | comparison | revisions
eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/MyMemoryEngine.py file | annotate | diff | comparison | revisions
eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/__init__.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsGit/git.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/HgClient.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffGenerator.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/HgRepoConfigDataDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/HgServeDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditPlanEditor.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/RebaseExtension/HgRebaseDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/hg.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsPySvn/SvnLogBrowserDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsPySvn/SvnRepoBrowserDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsPySvn/subversion.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsSubversion/SvnRepoBrowserDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsSubversion/subversion.py file | annotate | diff | comparison | revisions
eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardRepeatDialog.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/DebuggerPython3Page.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/EditorAPIsPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/EditorSearchPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/QtPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/WebBrowserVirusTotalPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/PreferencesLexer.py file | annotate | diff | comparison | revisions
eric6/Preferences/__init__.py file | annotate | diff | comparison | revisions
eric6/eric6_sqlbrowser.py file | annotate | diff | comparison | revisions
eric6/eric6_trpreviewer.py file | annotate | diff | comparison | revisions
eric6/eric6_uipreviewer.py file | annotate | diff | comparison | revisions
--- a/eric6/DataViews/CodeMetrics.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/DataViews/CodeMetrics.py	Tue Apr 13 18:02:59 2021 +0200
@@ -153,6 +153,7 @@
         @param row the row, the identifier is defined in (int)
         """
         if len(self.active) > 1 and self.indent_level > self.active[-1][1]:
+            # __IGNORE_WARNING_Y108__
             qualified = self.active[-1][0] + '.' + identifier
         else:
             qualified = identifier
--- a/eric6/E5Gui/E5SingleApplication.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/E5Gui/E5SingleApplication.py	Tue Apr 13 18:02:59 2021 +0200
@@ -123,10 +123,7 @@
         # flag indicating '--' options was found
         ddseen = False
         
-        if Utilities.isWindowsPlatform():
-            argChars = ['-', '/']
-        else:
-            argChars = ['-']
+        argChars = ['-', '/'] if Utilities.isWindowsPlatform() else ['-']
         
         for arg in args:
             if arg == '--' and not ddseen:
--- a/eric6/E5Gui/E5TreeWidget.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/E5Gui/E5TreeWidget.py	Tue Apr 13 18:02:59 2021 +0200
@@ -269,16 +269,10 @@
         
         @param parent parent item to iterate (QTreeWidgetItem)
         """
-        if parent:
-            count = parent.childCount()
-        else:
-            count = self.topLevelItemCount()
+        count = parent.childCount() if parent else self.topLevelItemCount()
         
         for index in range(count):
-            if parent:
-                itm = parent.child(index)
-            else:
-                itm = self.topLevelItem(index)
+            itm = parent.child(index) if parent else self.topLevelItem(index)
             
             if itm.childCount() == 0:
                 self.__allTreeItems.append(itm)
--- a/eric6/E5Gui/E5ZoomWidget.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/E5Gui/E5ZoomWidget.py	Tue Apr 13 18:02:59 2021 +0200
@@ -270,10 +270,7 @@
         
         @param value slider value (integer)
         """
-        if self.__mapped:
-            val = self.__mapping[value]
-        else:
-            val = value
+        val = self.__mapping[value] if self.__mapped else value
         fmtStr = "{0}%" if self.__percent else "{0}"
         self.valueLabel.setText(fmtStr.format(val))
         self.valueChanged.emit(val)
--- a/eric6/E5Network/E5SslInfoWidget.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/E5Network/E5SslInfoWidget.py	Tue Apr 13 18:02:59 2021 +0200
@@ -35,10 +35,7 @@
         self.setMinimumWidth(400)
         
         certList = self.__configuration.peerCertificateChain()
-        if certList:
-            cert = certList[0]
-        else:
-            cert = QSslCertificate()
+        cert = certList[0] if certList else QSslCertificate()
         
         layout = QGridLayout(self)
         rows = 0
--- a/eric6/Graphics/AssociationItem.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Graphics/AssociationItem.py	Tue Apr 13 18:02:59 2021 +0200
@@ -342,10 +342,7 @@
         elif region == East:
             px = x + ww
             py = y + ch
-        elif region == South:
-            px = x + cw
-            py = y + wh
-        elif region == Center:
+        elif region in (South, Center):
             px = x + cw
             py = y + wh
         
--- a/eric6/Graphics/ClassItem.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Graphics/ClassItem.py	Tue Apr 13 18:02:59 2021 +0200
@@ -143,10 +143,7 @@
             y += self.attrs.boundingRect().height() + self.margin
         else:
             self.attrs = None
-        if meths:
-            txt = "\n".join(meths)
-        else:
-            txt = " "
+        txt = "\n".join(meths) if meths else " "
         self.meths = QGraphicsSimpleTextItem(self)
         self.meths.setBrush(self._colors[0])
         self.meths.setFont(self.font)
--- a/eric6/Graphics/ImportsDiagramBuilder.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Graphics/ImportsDiagramBuilder.py	Tue Apr 13 18:02:59 2021 +0200
@@ -142,10 +142,8 @@
         for module in sortedkeys:
             impLst = []
             for i in modules[module].imports:
-                if i.startswith(self.package):
-                    n = i[len(self.package) + 1:]
-                else:
-                    n = i
+                n = (i[len(self.package) + 1:]
+                     if i.startswith(self.package) else i)
                 if i in modules:
                     impLst.append(n)
                 elif self.showExternalImports:
--- a/eric6/Graphics/ModuleItem.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Graphics/ModuleItem.py	Tue Apr 13 18:02:59 2021 +0200
@@ -99,10 +99,7 @@
         self.header.setText(self.model.getName())
         self.header.setPos(x, y)
         y += self.header.boundingRect().height() + self.margin
-        if classes:
-            txt = "\n".join(classes)
-        else:
-            txt = " "
+        txt = "\n".join(classes) if classes else " "
         self.classes = QGraphicsSimpleTextItem(self)
         self.classes.setBrush(self._colors[0])
         self.classes.setFont(self.font)
--- a/eric6/MicroPython/EspFirmwareSelectionDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/MicroPython/EspFirmwareSelectionDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -112,10 +112,7 @@
             address
         @rtype tuple of (str, str, str, str, str)
         """
-        if self.__addon:
-            address = self.addressEdit.text()
-        else:
-            address = ""
+        address = self.addressEdit.text() if self.__addon else ""
         
         return (
             self.espComboBox.currentText().lower(),
--- a/eric6/MicroPython/MicroPythonFileManagerWidget.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/MicroPython/MicroPythonFileManagerWidget.py	Tue Apr 13 18:02:59 2021 +0200
@@ -657,10 +657,7 @@
         @param localDevice flag indicating device access via local file system
         @type bool
         """
-        if localDevice:
-            cwdWidget = self.deviceCwd
-        else:
-            cwdWidget = self.localCwd
+        cwdWidget = self.deviceCwd if localDevice else self.localCwd
         
         dirPath, ok = E5PathPickerDialog.getPath(
             self,
@@ -684,10 +681,7 @@
         @param localDevice flag indicating device access via local file system
         @type bool
         """
-        if localDevice:
-            cwdWidget = self.deviceCwd
-        else:
-            cwdWidget = self.localCwd
+        cwdWidget = self.deviceCwd if localDevice else self.localCwd
         
         dirPath, ok = QInputDialog.getText(
             self,
--- a/eric6/MicroPython/MicroPythonFileSystemUtilities.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/MicroPython/MicroPythonFileSystemUtilities.py	Tue Apr 13 18:02:59 2021 +0200
@@ -106,10 +106,7 @@
     @rtype list of tuple of (str, tuple)
     """
     try:
-        if dirname:
-            files = os.listdir(dirname)
-        else:
-            files = os.listdir()
+        files = os.listdir(dirname) if dirname else os.listdir()
     except OSError:
         return []
     
--- a/eric6/MicroPython/MicroPythonWidget.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/MicroPython/MicroPythonWidget.py	Tue Apr 13 18:02:59 2021 +0200
@@ -1328,10 +1328,7 @@
                 downloadMenu = None
         
         # populate the super menu
-        if self.__device:
-            hasTime = self.__device.hasTimeCommands()
-        else:
-            hasTime = False
+        hasTime = self.__device.hasTimeCommands() if self.__device else False
         
         act = self.__superMenu.addAction(
             self.tr("Show Version"), self.__showDeviceVersion)
--- a/eric6/MultiProject/MultiProject.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/MultiProject/MultiProject.py	Tue Apr 13 18:02:59 2021 +0200
@@ -912,10 +912,7 @@
         self.recentMenu.clear()
         
         for idx, rp in enumerate(self.recent, start=1):
-            if idx < 10:
-                formatStr = '&{0:d}. {1}'
-            else:
-                formatStr = '{0:d}. {1}'
+            formatStr = '&{0:d}. {1}' if idx < 10 else '{0:d}. {1}'
             act = self.recentMenu.addAction(
                 formatStr.format(
                     idx,
--- a/eric6/Network/IRC/IrcNetworkEditDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Network/IRC/IrcNetworkEditDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -68,10 +68,7 @@
         # channels
         for channelName in sorted(self.__network.getChannelNames()):
             channel = self.__network.getChannel(channelName)
-            if channel.autoJoin():
-                autoJoin = self.tr("Yes")
-            else:
-                autoJoin = self.tr("No")
+            autoJoin = self.tr("Yes") if channel.autoJoin() else self.tr("No")
             QTreeWidgetItem(self.channelList, [channelName, autoJoin])
         
         self.__updateOkButton()
@@ -215,10 +212,7 @@
         Private slot to handle changes of the selection of channels.
         """
         selectedItems = self.channelList.selectedItems()
-        if len(selectedItems) == 0:
-            enable = False
-        else:
-            enable = True
+        enable = bool(selectedItems)
         self.editChannelButton.setEnabled(enable)
         self.deleteChannelButton.setEnabled(enable)
     
--- a/eric6/Network/IRC/IrcNetworkListDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Network/IRC/IrcNetworkListDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -250,10 +250,8 @@
         dlg.exec()
         
         selectedNetwork = self.networksList.selectedItems()
-        if selectedNetwork:
-            selectedNetworkName = selectedNetwork[0].text(0)
-        else:
-            selectedNetworkName = ""
+        selectedNetworkName = (
+            selectedNetwork[0].text(0) if selectedNetwork else "")
         self.__refreshNetworksList()
         if selectedNetworkName:
             for index in range(self.networksList.topLevelItemCount()):
--- a/eric6/Network/IRC/IrcNetworkManager.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Network/IRC/IrcNetworkManager.py	Tue Apr 13 18:02:59 2021 +0200
@@ -680,10 +680,7 @@
         @return default network object (IrcNetwork)
         """
         # network
-        if ssl:
-            networkName = "Freenode (SSL)"
-        else:
-            networkName = "Freenode"
+        networkName = "Freenode (SSL)" if ssl else "Freenode"
         network = IrcNetwork(networkName)
         network.setIdentityName(IrcIdentity.DefaultIdentityName)
         
--- a/eric6/PipInterface/Pip.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/PipInterface/Pip.py	Tue Apr 13 18:02:59 2021 +0200
@@ -154,10 +154,7 @@
         # Unix, OS X:   $VIRTUAL_ENV/pip.conf
         # Windows:      %VIRTUAL_ENV%\pip.ini
         
-        if Globals.isWindowsPlatform():
-            pip = "pip.ini"
-        else:
-            pip = "pip.conf"
+        pip = "pip.ini" if Globals.isWindowsPlatform() else "pip.conf"
         
         venvManager = e5App().getObject("VirtualEnvManager")
         if venvManager.isGlobalEnvironment(venvName):
@@ -165,10 +162,7 @@
         else:
             venvDirectory = venvManager.getVirtualenvDirectory(venvName)
         
-        if venvDirectory:
-            config = os.path.join(venvDirectory, pip)
-        else:
-            config = ""
+        config = os.path.join(venvDirectory, pip) if venvDirectory else ""
         
         return config
     
--- a/eric6/PluginManager/PluginRepositoryDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/PluginManager/PluginRepositoryDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -236,10 +236,7 @@
             return
         
         url = current.data(0, PluginRepositoryWidget.UrlRole)
-        if url is None:
-            url = ""
-        else:
-            url = self.__changeScheme(url)
+        url = "" if url is None else self.__changeScheme(url)
         self.urlEdit.setText(url)
         self.descriptionEdit.setPlainText(
             current.data(0, PluginRepositoryWidget.DescrRole) and
@@ -345,10 +342,8 @@
         self.__downloadButton.setEnabled(len(self.__selectedItems()))
         self.__downloadInstallButton.setEnabled(len(self.__selectedItems()))
         self.__installButton.setEnabled(len(self.__selectedItems()))
-        if not self.__external:
-            ui = e5App().getObject("UserInterface")
-        else:
-            ui = None
+        ui = (e5App().getObject("UserInterface")
+              if not self.__external else None)
         if ui is not None:
             ui.showNotification(
                 UI.PixmapCache.getPixmap("plugin48"),
--- a/eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Tue Apr 13 18:02:59 2021 +0200
@@ -320,10 +320,7 @@
             ):
                 results.append((_fn, lineno, col, "", message, msg_args))
     except SyntaxError as err:
-        if err.text.strip():
-            msg = err.text.strip()
-        else:
-            msg = err.msg
+        msg = err.text.strip() if err.text.strip() else err.msg
         results.append((filename, err.lineno, 0, "FLAKES_ERROR", msg, []))
     
     return [{'warnings': results}]
--- a/eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/GoogleV1Engine.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/GoogleV1Engine.py	Tue Apr 13 18:02:59 2021 +0200
@@ -111,10 +111,8 @@
                         result += "<hr/><u><b>{0}</b> - {1}</u><br/>".format(
                             text, value["pos"])
                         for entry in value["entry"]:
-                            if "previous_word" in entry:
-                                previous = entry["previous_word"] + " "
-                            else:
-                                previous = ""
+                            previous = (entry["previous_word"] + " "
+                                        if "previous_word" in entry else "")
                             word = entry["word"]
                             reverse = entry["reverse_translation"]
                             result += "<br/>{0}<b>{1}</b> - {2}".format(
--- a/eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/MyMemoryEngine.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/MyMemoryEngine.py	Tue Apr 13 18:02:59 2021 +0200
@@ -76,15 +76,11 @@
             )
         
         myMemoryKey = self.plugin.getPreferences("MyMemoryKey")
-        if myMemoryKey:
-            keyParam = "&key={0}".format(myMemoryKey)
-        else:
-            keyParam = ""
+        keyParam = "&key={0}".format(myMemoryKey) if myMemoryKey else ""
+        
         myMemoryEmail = self.plugin.getPreferences("MyMemoryEmail")
-        if myMemoryEmail:
-            emailParam = "&de={0}".format(myMemoryEmail)
-        else:
-            emailParam = ""
+        emailParam = "&de={0}".format(myMemoryEmail) if myMemoryEmail else ""
+        
         params = "?of=json{3}{4}&langpair={0}|{1}&q={2}".format(
             originalLanguage, translationLanguage, text,
             keyParam, emailParam)
--- a/eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/__init__.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/__init__.py	Tue Apr 13 18:02:59 2021 +0200
@@ -108,10 +108,7 @@
     @return engine icon
     @rtype QIcon
     """
-    if e5App().usesDarkPalette():
-        iconSuffix = "dark"
-    else:
-        iconSuffix = "light"
+    iconSuffix = "dark" if e5App().usesDarkPalette() else "light"
     if name in supportedEngineNames():
         icon = UI.PixmapCache.getIcon(os.path.join(
             os.path.dirname(__file__), "..", "icons", "engines",
--- a/eric6/Plugins/VcsPlugins/vcsGit/git.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsGit/git.py	Tue Apr 13 18:02:59 2021 +0200
@@ -772,10 +772,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgClient.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgClient.py	Tue Apr 13 18:02:59 2021 +0200
@@ -370,19 +370,14 @@
         inputChannels = {}
         if prompt is not None:
             def func(size):
-                if outputBuffer is None:
-                    msg = ""
-                else:
-                    msg = outputBuffer.getvalue()
+                msg = "" if outputBuffer is None else outputBuffer.getvalue()
                 reply, isPassword = prompt(size, msg)
                 return reply, isPassword
             inputChannels["L"] = func
         else:
             def myprompt(size):
-                if outputBuffer is None:
-                    msg = self.tr("For message see output dialog.")
-                else:
-                    msg = outputBuffer.getvalue()
+                msg = (self.tr("For message see output dialog.")
+                       if outputBuffer is None else outputBuffer.getvalue())
                 reply, isPassword = self.__prompt(size, msg)
                 return reply, isPassword
             inputChannels["L"] = myprompt
@@ -391,14 +386,9 @@
         
         self.__cancel = False
         self.__runcommand(args, inputChannels, outputChannels)
-        if outputBuffer:
-            out = outputBuffer.getvalue()
-        else:
-            out = ""
-        if errorBuffer:
-            err = errorBuffer.getvalue()
-        else:
-            err = ""
+        
+        out = outputBuffer.getvalue() if outputBuffer else ""
+        err = errorBuffer.getvalue() if errorBuffer else ""
         
         self.__commandRunning = False
         
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffGenerator.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffGenerator.py	Tue Apr 13 18:02:59 2021 +0200
@@ -161,10 +161,7 @@
         """
         f = line.split(None, 1)[1]
         f = f.rsplit(None, 6)[0]
-        if f == "/dev/null":
-            f = "__NULL__"
-        else:
-            f = f.split("/", 1)[1]
+        f = "__NULL__" if f == "/dev/null" else f.split("/", 1)[1]
         return f
     
     def __processFileLine(self, lineno, line):
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -911,14 +911,9 @@
             msgtxt = "{0}...".format(msgtxt[:logMessageColumnWidth])
         
         rev, node = revision.split(":")
-        if rev in self.__closedBranchesRevs:
-            closedStr = self.ClosedIndicator
-        else:
-            closedStr = ""
-        if phase in self.phases:
-            phaseStr = self.phases[phase]
-        else:
-            phaseStr = phase
+        closedStr = (self.ClosedIndicator
+                     if rev in self.__closedBranchesRevs else "")
+        phaseStr = self.phases.get(phase, phase)
         columnLabels = [
             "",
             branches[0] + closedStr,
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgRepoConfigDataDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgRepoConfigDataDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -95,10 +95,7 @@
             defaultUrl.setUserName(username)
         if password:
             defaultUrl.setPassword(password)
-        if not defaultUrl.isValid():
-            defaultUrl = ""
-        else:
-            defaultUrl = defaultUrl.toString()
+        defaultUrl = defaultUrl.toString() if defaultUrl.isValid() else ""
         
         defaultPushUrl = QUrl.fromUserInput(self.defaultPushUrlEdit.text())
         username = self.defaultPushUserEdit.text()
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgServeDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgServeDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -48,10 +48,7 @@
         
         self.setWindowTitle(self.tr("Mercurial Server"))
         
-        if e5App().usesDarkPalette():
-            iconSuffix = "dark"
-        else:
-            iconSuffix = "light"
+        iconSuffix = "dark" if e5App().usesDarkPalette() else "light"
         
         self.__startAct = QAction(
             UI.PixmapCache.getIcon(
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditPlanEditor.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditPlanEditor.py	Tue Apr 13 18:02:59 2021 +0200
@@ -150,17 +150,12 @@
         action = parts[0]
         try:
             rev = int(parts[2])
-            if len(parts) > 3:
-                summary = parts[3]
-            else:
-                summary = ""
+            summary = parts[3] if len(parts) > 3 else ""
         except ValueError:
             rev = -1
             summary = " ".join(parts[2:])
-        if rev > -1:
-            revision = "{0:>7}:{1}".format(rev, parts[1])
-        else:
-            revision = parts[1]
+        revision = ("{0:>7}:{1}".format(rev, parts[1])
+                    if rev > -1 else parts[1])
         
         itm = QTreeWidgetItem(self.planTreeWidget, [
             action,
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/RebaseExtension/HgRebaseDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/RebaseExtension/HgRebaseDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -290,10 +290,7 @@
             indicator = "B"
         else:
             indicator = ""
-        if indicator:
-            rev1 = self.__getRevision(1)
-        else:
-            rev1 = ""
+        rev1 = self.__getRevision(1) if indicator else ""
         
         return (
             indicator,
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py	Tue Apr 13 18:02:59 2021 +0200
@@ -747,10 +747,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
@@ -1258,11 +1255,7 @@
         args.append('paths.default')
         
         output, error = self.__client.runcommand(args)
-        
-        if output:
-            url = output.splitlines()[0].strip()
-        else:
-            url = ""
+        url = output.splitlines()[0].strip() if output else ""
         
         return QCoreApplication.translate(
             'mercurial',
@@ -1457,10 +1450,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/SvnLogBrowserDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsPySvn/SvnLogBrowserDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -206,10 +206,7 @@
         else:
             rev = revision.number
             self.__lastRev = revision.number
-        if date == "":
-            dt = ""
-        else:
-            dt = formatTime(date)
+        dt = formatTime(date) if date else ""
         
         itm = QTreeWidgetItem(self.logTree)
         itm.setData(0, Qt.ItemDataRole.DisplayRole, rev)
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/SvnRepoBrowserDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsPySvn/SvnRepoBrowserDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -107,19 +107,10 @@
         @param url url of the entry (string)
         @return reference to the generated item (QTreeWidgetItem)
         """
-        if repopath == "/":
-            path = url
-        else:
-            path = url.split("/")[-1]
+        path = url if repopath == "/" else url.split("/")[-1]
         
-        if revision == "":
-            rev = ""
-        else:
-            rev = revision.number
-        if date == "":
-            dt = ""
-        else:
-            dt = formatTime(date)
+        rev = revision.number if revision else ""
+        dt = formatTime(date) if date else ""
         if author is None:
             author = ""
         
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -394,10 +394,8 @@
                             
                             fpath = Utilities.normcasepath(
                                 os.path.join(self.dname, file.path))
-                            if fpath in changelistsDict:
-                                changelist = changelistsDict[fpath]
-                            else:
-                                changelist = ""
+                            changelist = (changelistsDict[fpath]
+                                          if fpath in changelistsDict else "")
                             
                             hidePropertyStatusColumn = (
                                 hidePropertyStatusColumn and
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/subversion.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsPySvn/subversion.py	Tue Apr 13 18:02:59 2021 +0200
@@ -934,10 +934,8 @@
             if not target:
                 return False
         
-        if rx_prot.fullmatch(target) is None:
-            isDir = os.path.isdir(name)
-        else:
-            isDir = False
+        isDir = (os.path.isdir(name) if rx_prot.fullmatch(target) is None
+                 else False)
         
         if accepted:
             client = self.getClient()
@@ -992,10 +990,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
@@ -2036,10 +2031,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
@@ -2075,10 +2067,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
@@ -2364,11 +2353,7 @@
         
         @param projectPath path name of the project (string)
         """
-        if projectPath:
-            url = self.svnGetReposName(projectPath)
-        else:
-            url = None
-        
+        url = self.svnGetReposName(projectPath) if projectPath else None
         if url is None:
             url, ok = QInputDialog.getText(
                 None,
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/SvnRepoBrowserDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsSubversion/SvnRepoBrowserDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -122,19 +122,11 @@
         @param url url of the entry (string)
         @return reference to the generated item (QTreeWidgetItem)
         """
-        path = repopath
-        
-        if revision == "":
-            rev = ""
-        else:
-            rev = int(revision)
-        if size == "":
-            sz = ""
-        else:
-            sz = int(size)
+        rev = "" if revision == "" else int(revision)
+        sz = "" if size == "" else int(size)
         
         itm = QTreeWidgetItem(self.parentItem)
-        itm.setData(0, Qt.ItemDataRole.DisplayRole, path)
+        itm.setData(0, Qt.ItemDataRole.DisplayRole, repopath)
         itm.setData(1, Qt.ItemDataRole.DisplayRole, rev)
         itm.setData(2, Qt.ItemDataRole.DisplayRole, author)
         itm.setData(3, Qt.ItemDataRole.DisplayRole, sz)
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/subversion.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsSubversion/subversion.py	Tue Apr 13 18:02:59 2021 +0200
@@ -867,10 +867,8 @@
             if not target:
                 return False
         
-        if rx_prot.fullmatch(target) is None:
-            isDir = os.path.isdir(name)
-        else:
-            isDir = False
+        isDir = (os.path.isdir(name) if rx_prot.fullmatch(target) is None
+                 else False)
         
         if accepted:
             args = []
@@ -919,10 +917,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
@@ -1893,10 +1888,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
@@ -1929,10 +1921,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
@@ -2168,10 +2157,7 @@
         
         @param projectPath path name of the project (string)
         """
-        if projectPath:
-            url = self.svnGetReposName(projectPath)
-        else:
-            url = None
+        url = self.svnGetReposName(projectPath) if projectPath else None
         
         if url is None:
             url, ok = QInputDialog.getText(
--- a/eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardRepeatDialog.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardRepeatDialog.py	Tue Apr 13 18:02:59 2021 +0200
@@ -57,11 +57,8 @@
         
         @return ready formatted repeat string (string)
         """
-        if self.minimalCheckBox.isChecked():
-            minimal = "?"
-        else:
-            minimal = ""
-            
+        minimal = "?" if self.minimalCheckBox.isChecked() else ""
+        
         if self.unlimitedButton.isChecked():
             return "*" + minimal
         elif self.minButton.isChecked():
--- a/eric6/Preferences/ConfigurationPages/DebuggerPython3Page.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Preferences/ConfigurationPages/DebuggerPython3Page.py	Tue Apr 13 18:02:59 2021 +0200
@@ -68,10 +68,7 @@
         Preferences.setDebugger(
             "Python3VirtualEnv",
             self.venvComboBox.currentText())
-        if self.standardButton.isChecked():
-            dct = "standard"
-        else:
-            dct = "custom"
+        dct = "standard" if self.standardButton.isChecked() else "custom"
         Preferences.setDebugger("DebugClientType3", dct)
         Preferences.setDebugger(
             "DebugClient3",
--- a/eric6/Preferences/ConfigurationPages/EditorAPIsPage.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Preferences/ConfigurationPages/EditorAPIsPage.py	Tue Apr 13 18:02:59 2021 +0200
@@ -70,10 +70,7 @@
         @return key to be used
         @rtype str
         """
-        if projectType:
-            key = (language, projectType)
-        else:
-            key = (language, "")
+        key = (language, projectType) if projectType else (language, "")
         return key
     
     def save(self):
--- a/eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py	Tue Apr 13 18:02:59 2021 +0200
@@ -167,10 +167,8 @@
         @rtype tuple of (int, int)
         """
         itm = self.styleElementList.currentItem()
-        if itm is None:
-            styles = (0, -1)    # return default style
-        else:
-            styles = self.__stylesForItem(itm)
+        # return default style, if no current item
+        styles = (0, -1) if itm is None else self.__stylesForItem(itm)
         
         return styles
     
--- a/eric6/Preferences/ConfigurationPages/EditorSearchPage.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Preferences/ConfigurationPages/EditorSearchPage.py	Tue Apr 13 18:02:59 2021 +0200
@@ -65,10 +65,7 @@
             "MarkOccurrencesTimeout",
             self.markOccurrencesTimeoutSpinBox.value())
         
-        if self.regexpPosixButton.isChecked():
-            mode = 0
-        else:
-            mode = 1
+        mode = 0 if self.regexpPosixButton.isChecked() else 1
         Preferences.setEditor(
             "SearchRegexpMode", mode)
         
--- a/eric6/Preferences/ConfigurationPages/QtPage.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Preferences/ConfigurationPages/QtPage.py	Tue Apr 13 18:02:59 2021 +0200
@@ -164,10 +164,8 @@
         @param initial flag indicating an initial population
         @type bool
         """
-        if initial:
-            venvName = Preferences.getQt(envKey)
-        else:
-            venvName = comboBox.currentText()
+        venvName = (Preferences.getQt(envKey) if initial
+                    else comboBox.currentText())
         
         comboBox.clear()
         comboBox.addItems(
--- a/eric6/Preferences/ConfigurationPages/WebBrowserVirusTotalPage.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Preferences/ConfigurationPages/WebBrowserVirusTotalPage.py	Tue Apr 13 18:02:59 2021 +0200
@@ -74,10 +74,7 @@
         self.testResultLabel.setHidden(False)
         self.testResultLabel.setText(
             self.tr("Checking validity of the service key..."))
-        if self.vtSecureCheckBox.isChecked():
-            protocol = "https"
-        else:
-            protocol = "http"
+        protocol = "https" if self.vtSecureCheckBox.isChecked() else "http"
         self.__vt.checkServiceKeyValidity(
             self.vtServiceKeyEdit.text(), protocol)
     
--- a/eric6/Preferences/PreferencesLexer.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Preferences/PreferencesLexer.py	Tue Apr 13 18:02:59 2021 +0200
@@ -384,10 +384,8 @@
         @return whitespace separated list of words
         @rtype str
         """
-        if substyle >= 0:
-            words = self.__lex.substyleWords(style, substyle)
-        else:
-            words = ""
+        words = (self.__lex.substyleWords(style, substyle) if substyle >= 0
+                 else "")
         
         return words
     
@@ -478,10 +476,8 @@
         @return flag indicating the existence of a style definition
         @rtype bool
         """
-        if substyle >= 0:
-            ok = self.__lex.hasSubstyle(style, substyle)
-        else:
-            ok = True
+        ok = (self.__lex.hasSubstyle(style, substyle) if substyle >= 0
+              else True)
         
         return ok
     
--- a/eric6/Preferences/__init__.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/Preferences/__init__.py	Tue Apr 13 18:02:59 2021 +0200
@@ -2197,10 +2197,8 @@
     @param value the colour to be set
     @param prefClass preferences class used as the storage area
     """
-    if value.alpha() < 255:
-        val = "#{0:8x}".format(value.rgba())
-    else:
-        val = value.name()
+    val = ("#{0:8x}".format(value.rgba()) if value.alpha() < 255
+           else value.name())
     prefClass.settings.setValue("Editor/Colour/" + key, val)
     
 
@@ -2243,10 +2241,7 @@
     @return requested list of API files
     @rtype list of str
     """
-    if projectType:
-        key = "{0}_{1}".format(language, projectType)
-    else:
-        key = language
+    key = "{0}_{1}".format(language, projectType) if projectType else language
     apis = prefClass.settings.value("Editor/APIs/" + key)
     if apis is not None:
         if len(apis) and apis[0] == "":
@@ -2274,10 +2269,7 @@
     @param prefClass preferences class used as the storage area
     @type Prefs
     """
-    if projectType:
-        key = "{0}_{1}".format(language, projectType)
-    else:
-        key = language
+    key = "{0}_{1}".format(language, projectType) if projectType else language
     prefClass.settings.setValue("Editor/APIs/" + key, apilist)
     
 
@@ -3473,10 +3465,8 @@
     @param value the colour to be set
     @param prefClass preferences class used as the storage area
     """
-    if value.alpha() < 255:
-        val = "#{0:8x}".format(value.rgba())
-    else:
-        val = value.name()
+    val = ("#{0:8x}".format(value.rgba())
+           if value.alpha() < 255 else value.name())
     prefClass.settings.setValue("Diff/" + key, val)
 
 
--- a/eric6/eric6_sqlbrowser.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/eric6_sqlbrowser.py	Tue Apr 13 18:02:59 2021 +0200
@@ -45,12 +45,9 @@
     """
     from SqlBrowser.SqlBrowser import SqlBrowser
     
-    if len(argv) > 1:
-        connections = argv[1:]
-    else:
-        connections = []
+    connections = argv[1:] if len(argv) > 1 else []
+    browser = SqlBrowser(connections)
     
-    browser = SqlBrowser(connections)
     return browser
 
 
--- a/eric6/eric6_trpreviewer.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/eric6_trpreviewer.py	Tue Apr 13 18:02:59 2021 +0200
@@ -51,12 +51,9 @@
     """
     from Tools.TRPreviewer import TRPreviewer
     
-    if len(argv) > 1:
-        files = argv[1:]
-    else:
-        files = []
+    files = argv[1:] if len(argv) > 1 else []
+    previewer = TRPreviewer(files, None, 'TRPreviewer')
     
-    previewer = TRPreviewer(files, None, 'TRPreviewer')
     return previewer
 
 
--- a/eric6/eric6_uipreviewer.py	Tue Apr 13 17:49:05 2021 +0200
+++ b/eric6/eric6_uipreviewer.py	Tue Apr 13 18:02:59 2021 +0200
@@ -46,12 +46,9 @@
     """
     from Tools.UIPreviewer import UIPreviewer
     
-    if len(argv) > 1:
-        fn = argv[1]
-    else:
-        fn = None
+    fn = argv[1] if len(argv) > 1 else None
+    previewer = UIPreviewer(fn, None, 'UIPreviewer')
     
-    previewer = UIPreviewer(fn, None, 'UIPreviewer')
     return previewer
 
 

eric ide

mercurial