Simplified some code. eric7

Thu, 31 Aug 2023 18:10:28 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 31 Aug 2023 18:10:28 +0200
branch
eric7
changeset 10180
3a595df36c9a
parent 10179
c2125fcab4b8
child 10183
f47edf2b8954

Simplified some code.

src/eric7/DebugClients/Python/DebugVariables.py file | annotate | diff | comparison | revisions
src/eric7/EricWidgets/EricMainWindow.py file | annotate | diff | comparison | revisions
src/eric7/PipInterface/PipVulnerabilityChecker.py file | annotate | diff | comparison | revisions
src/eric7/QScintilla/Editor.py file | annotate | diff | comparison | revisions
src/eric7/QScintilla/EditorAssembly.py file | annotate | diff | comparison | revisions
src/eric7/QScintilla/Exporters/ExporterHTML.py file | annotate | diff | comparison | revisions
src/eric7/QScintilla/MiniEditor.py file | annotate | diff | comparison | revisions
src/eric7/Snapshot/SnapshotWaylandGrabber.py file | annotate | diff | comparison | revisions
src/eric7/Utilities/ClassBrowsers/__init__.py file | annotate | diff | comparison | revisions
src/eric7/Utilities/ModuleParser.py file | annotate | diff | comparison | revisions
src/eric7/Utilities/crypto/py3AES.py file | annotate | diff | comparison | revisions
src/eric7/WebBrowser/AdBlock/AdBlockRule.py file | annotate | diff | comparison | revisions
src/eric7/WebBrowser/ImageSearch/ImageSearchEngine.py file | annotate | diff | comparison | revisions
src/eric7/WebBrowser/Passwords/PasswordManager.py file | annotate | diff | comparison | revisions
--- a/src/eric7/DebugClients/Python/DebugVariables.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/DebugClients/Python/DebugVariables.py	Thu Aug 31 18:10:28 2023 +0200
@@ -854,7 +854,3 @@
             return resolver
 
     return defaultResolver
-
-
-#
-# eflag: noqa = Y113
--- a/src/eric7/EricWidgets/EricMainWindow.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/EricWidgets/EricMainWindow.py	Thu Aug 31 18:10:28 2023 +0200
@@ -40,8 +40,7 @@
         """
         # step 1: set the style
         style = None
-        if styleName != "System" and styleName in QStyleFactory.keys():
-            # __IGNORE_WARNING_Y118__
+        if styleName != "System" and styleName in QStyleFactory.keys():  # noqa: Y118
             style = QStyleFactory.create(styleName)
         if style is None:
             style = QStyleFactory.create(self.defaultStyleName)
--- a/src/eric7/PipInterface/PipVulnerabilityChecker.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/PipInterface/PipVulnerabilityChecker.py	Thu Aug 31 18:10:28 2023 +0200
@@ -127,7 +127,7 @@
         @rtype dict
         """
         if os.path.exists(self.__cacheFile):
-            with open(self.__cacheFile, "r") as f:  # __IGNORE_WARNING_Y117__
+            with open(self.__cacheFile, "r") as f:  # noqa: Y117
                 with contextlib.suppress(json.JSONDecodeError, OSError):
                     cachedData = json.load(f)
                     if dbName in cachedData and "cachedAt" in cachedData[dbName]:
--- a/src/eric7/QScintilla/Editor.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/QScintilla/Editor.py	Thu Aug 31 18:10:28 2023 +0200
@@ -2010,17 +2010,15 @@
         """
         if self.apiLanguage == "Guessed" or self.apiLanguage.startswith("Pygments|"):
             lang = self.lexer_.name()
-            if normalized:  # __IGNORE_WARNING_Y102__
+            if normalized and lang in ("Python 2.x", "Python"):
                 # adjust some Pygments lexer names
-                if lang in ("Python 2.x", "Python"):
-                    lang = "Python3"
+                lang = "Python3"
 
         else:
             lang = self.apiLanguage
-            if forPygments:  # __IGNORE_WARNING_Y102__
+            if forPygments and lang == "Python3":
                 # adjust some names to Pygments lexer names
-                if lang == "Python3":
-                    lang = "Python"
+                lang = "Python"
         return lang
 
     def getApiLanguage(self):
--- a/src/eric7/QScintilla/EditorAssembly.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/QScintilla/EditorAssembly.py	Thu Aug 31 18:10:28 2023 +0200
@@ -313,7 +313,7 @@
                 self.__membersBoundaries = {}
 
                 self.__globalsCombo.addItem("")
-                index = 0
+                index = 0  # noqa: Y113
 
                 # step 1: add modules
                 items = []
@@ -461,7 +461,3 @@
         )
 
         self.__sourceOutline.setVisible(supported)
-
-
-#
-# eflag: noqa = Y113
--- a/src/eric7/QScintilla/Exporters/ExporterHTML.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/QScintilla/Exporters/ExporterHTML.py	Thu Aug 31 18:10:28 2023 +0200
@@ -194,7 +194,6 @@
                                     QFontInfo(font).pointSize()
                                 )
                             html += "}\n"
-                            # __IGNORE_WARNING_Y113__
                     else:
                         styleIsUsed[istyle] = False
                 istyle += 1
--- a/src/eric7/QScintilla/MiniEditor.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/QScintilla/MiniEditor.py	Thu Aug 31 18:10:28 2023 +0200
@@ -3893,17 +3893,15 @@
         """
         if self.apiLanguage == "Guessed" or self.apiLanguage.startswith("Pygments|"):
             lang = self.lexer_.name()
-            if normalized:  # __IGNORE_WARNING_Y102__
+            if normalized and lang in ("Python 2.x", "Python"):
                 # adjust some Pygments lexer names
-                if lang in ("Python 2.x", "Python"):
-                    lang = "Python3"
+                lang = "Python3"
 
         else:
             lang = self.apiLanguage
-            if forPygments:  # __IGNORE_WARNING_Y102__
+            if forPygments and lang == "Python3":
                 # adjust some names to Pygments lexer names
-                if lang == "Python3":
-                    lang = "Python"
+                lang = "Python"
         return lang
 
     def __checkLanguage(self):
--- a/src/eric7/Snapshot/SnapshotWaylandGrabber.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/Snapshot/SnapshotWaylandGrabber.py	Thu Aug 31 18:10:28 2023 +0200
@@ -65,20 +65,22 @@
         @return tuple of supported screenshot modes
         @rtype tuple of SnapshotModes
         """
-        if DBusAvailable and DesktopUtilities.isKdeDesktop():
-            # __IGNORE_WARNING_Y114__
-            return (
-                SnapshotModes.FULLSCREEN,
-                SnapshotModes.SELECTEDSCREEN,
-                SnapshotModes.SELECTEDWINDOW,
-            )
-        elif DBusAvailable and DesktopUtilities.isGnomeDesktop():
-            return (
-                SnapshotModes.FULLSCREEN,
-                SnapshotModes.SELECTEDSCREEN,
-                SnapshotModes.SELECTEDWINDOW,
-                SnapshotModes.RECTANGLE,
-            )
+        if DBusAvailable:
+            if DesktopUtilities.isKdeDesktop():
+                return (
+                    SnapshotModes.FULLSCREEN,
+                    SnapshotModes.SELECTEDSCREEN,
+                    SnapshotModes.SELECTEDWINDOW,
+                )
+            elif DesktopUtilities.isGnomeDesktop():
+                return (
+                    SnapshotModes.FULLSCREEN,
+                    SnapshotModes.SELECTEDSCREEN,
+                    SnapshotModes.SELECTEDWINDOW,
+                    SnapshotModes.RECTANGLE,
+                )
+            else:
+                return ()
         else:
             return ()
 
--- a/src/eric7/Utilities/ClassBrowsers/__init__.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/Utilities/ClassBrowsers/__init__.py	Thu Aug 31 18:10:28 2023 +0200
@@ -226,8 +226,7 @@
         for p in path:  # search in path
             pathname = os.path.join(p, name)
             if os.path.exists(pathname):
-                return (open(pathname), pathname, (ext, "r", sourceType))
-                # __IGNORE_WARNING_Y115__
+                return (open(pathname), pathname, (ext, "r", sourceType))  # noqa: Y115
         raise ImportError
     else:
         # standard Python module file
@@ -239,8 +238,7 @@
             raise ImportError
         if isinstance(spec.loader, importlib.machinery.SourceFileLoader):
             ext = os.path.splitext(spec.origin)[-1]
-            return (open(spec.origin), spec.origin, (ext, "r", PY_SOURCE))
-            # __IGNORE_WARNING_Y115__
+            return (open(spec.origin), spec.origin, (ext, "r", PY_SOURCE))  # noqa: Y115
 
     raise ImportError
 
--- a/src/eric7/Utilities/ModuleParser.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/Utilities/ModuleParser.py	Thu Aug 31 18:10:28 2023 +0200
@@ -1669,20 +1669,20 @@
                     if ext == ".ptl":
                         # Quixote page template
                         return (
-                            open(pathname),  # __IGNORE_WARNING_Y115__
+                            open(pathname),  # noqa: Y115
                             pathname,
                             (".ptl", "r", PTL_SOURCE),
                         )
                     elif ext == ".rb":
                         # Ruby source file
                         return (
-                            open(pathname),  # __IGNORE_WARNING_Y115__
+                            open(pathname),  # noqa: Y115
                             pathname,
                             (".rb", "r", RB_SOURCE),
                         )
                     else:
                         return (
-                            open(pathname),  # __IGNORE_WARNING_Y115__
+                            open(pathname),  # noqa: Y115
                             pathname,
                             (ext, "r", PY_SOURCE),
                         )
@@ -1697,8 +1697,7 @@
         raise ImportError
     if isinstance(spec.loader, importlib.machinery.SourceFileLoader):
         ext = os.path.splitext(spec.origin)[-1]
-        return (open(spec.origin), spec.origin, (ext, "r", PY_SOURCE))
-        # __IGNORE_WARNING_Y115__
+        return (open(spec.origin), spec.origin, (ext, "r", PY_SOURCE))  # noqa: Y115
 
     raise ImportError
 
--- a/src/eric7/Utilities/crypto/py3AES.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/Utilities/crypto/py3AES.py	Thu Aug 31 18:10:28 2023 +0200
@@ -944,7 +944,7 @@
             # key.
             for m in range(4):
                 expandedKey[currentSize] = expandedKey[currentSize - size] ^ t[m]
-                currentSize += 1  # __IGNORE_WARNING_Y113__
+                currentSize += 1  # noqa: Y113
 
         return expandedKey
 
--- a/src/eric7/WebBrowser/AdBlock/AdBlockRule.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/WebBrowser/AdBlock/AdBlockRule.py	Thu Aug 31 18:10:28 2023 +0200
@@ -1006,8 +1006,7 @@
         @return flag indicating a end of string match filter
         @rtype bool
         """
-        for index, filterChar in enumerate(filterString):
-            # __IGNORE_WARNING_Y111__
+        for index, filterChar in enumerate(filterString):  # noqa: Y111
             if filterChar in ["^", "*"]:
                 return False
             elif filterChar == "|":
--- a/src/eric7/WebBrowser/ImageSearch/ImageSearchEngine.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/WebBrowser/ImageSearch/ImageSearchEngine.py	Thu Aug 31 18:10:28 2023 +0200
@@ -66,23 +66,19 @@
         @return search query URL
         @rtype QUrl
         """
+        searchEngineUrlTemplates = {
+            "google": "https://www.google.com/searchbyimage?site=search&image_url={0}",
+            "yandex": "https://yandex.com/images/search?&img_url={0}&rpt=imageview",
+            "tineye": "http://www.tineye.com/search?url={0}",
+        }
         if not searchEngine:
             searchEngine = self.searchEngine()
 
-        searchEngine_l = searchEngine.lower()
-        if searchEngine_l == "google":  # __IGNORE_WARNING_Y116__
-            return QUrl(
-                "https://www.google.com/searchbyimage?"
-                "site=search&image_url={0}".format(imageUrl.toString())
-            )
-        elif searchEngine_l == "yandex":
+        try:
             return QUrl(
-                "https://yandex.com/images/search?"
-                "&img_url={0}&rpt=imageview".format(imageUrl.toString())
+                searchEngineUrlTemplates[searchEngine.lower()].format(
+                    imageUrl.toString()
+                )
             )
-        elif searchEngine_l == "tineye":
-            return QUrl(
-                "http://www.tineye.com/search?url={0}".format(imageUrl.toString())
-            )
-        else:
+        except KeyError:
             return QUrl()
--- a/src/eric7/WebBrowser/Passwords/PasswordManager.py	Thu Aug 31 15:00:53 2023 +0200
+++ b/src/eric7/WebBrowser/Passwords/PasswordManager.py	Thu Aug 31 18:10:28 2023 +0200
@@ -403,7 +403,7 @@
         )
         progress.setMinimumDuration(0)
         progress.setWindowTitle(self.tr("Passwords"))
-        count = 0
+        count = 0  # noqa: Y113
 
         # step 1: do the logins
         for key in self.__logins:
@@ -426,7 +426,3 @@
         progress.setValue(len(self.__logins) + len(self.__loginForms))
         QCoreApplication.processEvents()
         self.changed.emit()
-
-
-#
-# eflag: noqa = Y113

eric ide

mercurial