Implemented some code simplifications. release-3.2.0

Mon, 26 Apr 2021 19:57:50 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 26 Apr 2021 19:57:50 +0200
changeset 46
c12f1feea96a
parent 45
896b66ba45f0
child 47
82b6c69429b8

Implemented some code simplifications.

ChangeLog file | annotate | diff | comparison | revisions
PluginSelectionEncloser.py file | annotate | diff | comparison | revisions
PluginSelectionEncloser.zip file | annotate | diff | comparison | revisions
SelectionEncloser.epj file | annotate | diff | comparison | revisions
SelectionEncloser/ConfigurationPage/SelectionEncloserPage.py file | annotate | diff | comparison | revisions
SelectionEncloser/Documentation/source/Plugin_Tools_Selection_Encloser.PluginSelectionEncloser.html file | annotate | diff | comparison | revisions
SelectionEncloser/Documentation/source/Plugin_Tools_Selection_Encloser.SelectionEncloser.ConfigurationPage.SelectionEncloserEditDialog.html file | annotate | diff | comparison | revisions
--- a/ChangeLog	Wed Dec 30 11:02:15 2020 +0100
+++ b/ChangeLog	Mon Apr 26 19:57:50 2021 +0200
@@ -1,5 +1,8 @@
 ChangeLog
 ---------
+Version 3.2.0:
+- implemented some code simplifications.
+
 Version 3.1.0:
 - changed exec_() into exec()
 
--- a/PluginSelectionEncloser.py	Wed Dec 30 11:02:15 2020 +0100
+++ b/PluginSelectionEncloser.py	Mon Apr 26 19:57:50 2021 +0200
@@ -7,6 +7,7 @@
 Module implementing the Selection Encloser plug-in.
 """
 
+import contextlib
 import os
 import json
 
@@ -22,7 +23,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "3.1.0"
+version = "3.2.0"
 className = "SelectionEncloserPlugin"
 packageName = "SelectionEncloser"
 shortDescription = "Enclose the selection with a string."
@@ -63,14 +64,12 @@
     try:
         usesDarkPalette = e5App().usesDarkPalette()
     except AttributeError:
+        # for eric6 < 20.4
         from PyQt5.QtGui import QPalette
         palette = e5App().palette()
         lightness = palette.color(QPalette.Window).lightness()
         usesDarkPalette = lightness <= 128
-    if usesDarkPalette:
-        iconSuffix = "dark"
-    else:
-        iconSuffix = "light"
+    iconSuffix = "dark" if usesDarkPalette else "light"
     
     return {
         "selectionEncloserPage": [
@@ -101,7 +100,7 @@
         
         @param ui reference to the user interface object (UI.UserInterface)
         """
-        QObject.__init__(self, ui)
+        super.__init__(ui)
         self.__ui = ui
         
         # menu is a list of lists; each list consists of a string for the
@@ -295,12 +294,10 @@
         
         @param editor reference to the editor (QScintilla.Editor)
         """
-        try:
+        with contextlib.suppress(KeyError):
             del self.__editors[editor]
             if not self.__editors:
                 self.__menu.setEnabled(False)
-        except KeyError:
-            pass
     
     def __editorShowMenu(self, menuName, menu, editor):
         """
Binary file PluginSelectionEncloser.zip has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SelectionEncloser.epj	Mon Apr 26 19:57:50 2021 +0200
@@ -0,0 +1,273 @@
+{
+  "header": {
+    "comment": "eric project file for project SelectionEncloser",
+    "copyright": "Copyright (C) 2021 Detlev Offenbach, detlev@die-offenbachs.de"
+  },
+  "project": {
+    "AUTHOR": "Detlev Offenbach",
+    "CHECKERSPARMS": {
+      "Pep8Checker": {
+        "AnnotationsChecker": {
+          "AllowUntypedDefs": false,
+          "AllowUntypedNested": false,
+          "DispatchDecorators": [
+            "singledispatch",
+            "singledispatchmethod"
+          ],
+          "MaximumComplexity": 3,
+          "MaximumLength": 7,
+          "MinimumCoverage": 75,
+          "MypyInitReturn": false,
+          "OverloadDecorators": [
+            "overload"
+          ],
+          "SuppressDummyArgs": false,
+          "SuppressNoneReturning": true
+        },
+        "BlankLines": [
+          2,
+          1
+        ],
+        "BuiltinsChecker": {
+          "bytes": [
+            "unicode"
+          ],
+          "chr": [
+            "unichr"
+          ],
+          "str": [
+            "unicode"
+          ]
+        },
+        "CommentedCodeChecker": {
+          "Aggressive": false,
+          "WhiteList": [
+            "pylint",
+            "pyright",
+            "noqa",
+            "type:\\s*ignore",
+            "fmt:\\s*(on|off)",
+            "TODO",
+            "FIXME",
+            "WARNING",
+            "NOTE",
+            "TEST",
+            "DOCU",
+            "XXX",
+            "- "
+          ]
+        },
+        "CopyrightAuthor": "",
+        "CopyrightMinFileSize": 0,
+        "DocstringType": "eric",
+        "EnabledCheckerCategories": "C, D, E, M, N, S, Y, W",
+        "ExcludeFiles": "*/Ui_*.py, */*_rc.py",
+        "ExcludeMessages": "C101,E265,E266,E305,E402,M201,M301,M302,M303,M304,M305,M306,M307,M308,M311,M312,M313,M314,M315,M321,M701,M702,M811,M834,N802,N803,N807,N808,N821,W293,W504,Y119,Y401,Y402",
+        "FixCodes": "",
+        "FixIssues": false,
+        "FutureChecker": "",
+        "HangClosing": false,
+        "IncludeMessages": "",
+        "LineComplexity": 25,
+        "LineComplexityScore": 10,
+        "MaxCodeComplexity": 10,
+        "MaxDocLineLength": 79,
+        "MaxLineLength": 79,
+        "NoFixCodes": "E501",
+        "RepeatMessages": true,
+        "SecurityChecker": {
+          "CheckTypedException": false,
+          "HardcodedTmpDirectories": [
+            "/tmp",
+            "/var/tmp",
+            "/dev/shm",
+            "~/tmp"
+          ],
+          "InsecureHashes": [
+            "md4",
+            "md5",
+            "sha",
+            "sha1"
+          ],
+          "InsecureSslProtocolVersions": [
+            "PROTOCOL_SSLv2",
+            "SSLv2_METHOD",
+            "SSLv23_METHOD",
+            "PROTOCOL_SSLv3",
+            "PROTOCOL_TLSv1",
+            "SSLv3_METHOD",
+            "TLSv1_METHOD"
+          ],
+          "WeakKeySizeDsaHigh": "1024",
+          "WeakKeySizeDsaMedium": "2048",
+          "WeakKeySizeEcHigh": "160",
+          "WeakKeySizeEcMedium": "224",
+          "WeakKeySizeRsaHigh": "1024",
+          "WeakKeySizeRsaMedium": "2048"
+        },
+        "ShowIgnored": false,
+        "ValidEncodings": "latin-1, utf-8"
+      }
+    },
+    "DESCRIPTION": "Plug-in to enclose the selection of the current editor in a selectable and configurable string.",
+    "DOCSTRING": "",
+    "DOCUMENTATIONPARMS": {
+      "ERIC4DOC": {
+        "cssFile": "%PYTHON%/eric6/CSSs/default.css",
+        "ignoreDirectories": [
+          ".eric5project",
+          ".ropeproject",
+          ".hg",
+          "_ropeproject",
+          "_eric5project",
+          ".eric6project",
+          "_eric6project"
+        ],
+        "ignoreFilePatterns": [
+          "Ui_*.py"
+        ],
+        "outputDirectory": "SelectionEncloser/Documentation/source",
+        "qtHelpEnabled": false,
+        "useRecursion": true
+      }
+    },
+    "EMAIL": "detlev@die-offenbachs.de",
+    "EOL": -1,
+    "FILETYPES": {
+      "*.idl": "INTERFACES",
+      "*.py": "SOURCES",
+      "*.py3": "SOURCES",
+      "*.pyw": "SOURCES",
+      "*.pyw3": "SOURCES",
+      "*.qm": "TRANSLATIONS",
+      "*.qrc": "RESOURCES",
+      "*.ts": "TRANSLATIONS",
+      "*.ui": "FORMS",
+      "*.ui.h": "FORMS",
+      "Ui_*.py": "__IGNORE__"
+    },
+    "FORMS": [
+      "SelectionEncloser/ConfigurationPage/SelectionEncloserEditDialog.ui",
+      "SelectionEncloser/ConfigurationPage/SelectionEncloserPage.ui"
+    ],
+    "HASH": "91f365d0cd272c85920259a5767cf6213841f57c",
+    "IDLPARAMS": {
+      "DefinedNames": [],
+      "IncludeDirs": [],
+      "UndefinedNames": []
+    },
+    "INTERFACES": [],
+    "LEXERASSOCS": {},
+    "MAINSCRIPT": "PluginSelectionEncloser.py",
+    "MAKEPARAMS": {
+      "MakeEnabled": false,
+      "MakeExecutable": "",
+      "MakeFile": "",
+      "MakeParameters": "",
+      "MakeTarget": "",
+      "MakeTestOnly": true
+    },
+    "MIXEDLANGUAGE": false,
+    "OTHERS": [
+      ".hgignore",
+      "ChangeLog",
+      "PKGLIST",
+      "PluginSelectionEncloser.zip",
+      "SelectionEncloser.e4p",
+      "SelectionEncloser/Documentation/LICENSE.GPL3",
+      "SelectionEncloser/Documentation/source",
+      "SelectionEncloser/icons/edit-dark.svg",
+      "SelectionEncloser/icons/edit-light.svg",
+      "SelectionEncloser/icons/selectionEncloser-dark.svg",
+      "SelectionEncloser/icons/selectionEncloser-light.svg",
+      "SelectionEncloser/icons/separatorAdd-dark.svg",
+      "SelectionEncloser/icons/separatorAdd-light.svg",
+      "SelectionEncloser/icons/topAdd-dark.svg",
+      "SelectionEncloser/icons/topAdd-light.svg",
+      "SelectionEncloser.epj"
+    ],
+    "OTHERTOOLSPARMS": {},
+    "PACKAGERSPARMS": {},
+    "PROGLANGUAGE": "Python3",
+    "PROJECTTYPE": "E6Plugin",
+    "PROJECTTYPESPECIFICDATA": {},
+    "PROTOCOLS": [],
+    "RCCPARAMS": {
+      "CompressLevel": 0,
+      "CompressionDisable": false,
+      "CompressionThreshold": 70,
+      "PathPrefix": ""
+    },
+    "RESOURCES": [],
+    "SOURCES": [
+      "PluginSelectionEncloser.py",
+      "SelectionEncloser/ConfigurationPage/SelectionEncloserEditDialog.py",
+      "SelectionEncloser/ConfigurationPage/SelectionEncloserPage.py",
+      "SelectionEncloser/ConfigurationPage/__init__.py",
+      "SelectionEncloser/__init__.py",
+      "__init__.py"
+    ],
+    "SPELLEXCLUDES": "",
+    "SPELLLANGUAGE": "en_US",
+    "SPELLWORDS": "",
+    "TRANSLATIONEXCEPTIONS": [],
+    "TRANSLATIONPATTERN": "SelectionEncloser/i18n/selectionencloser_%language%.ts",
+    "TRANSLATIONS": [
+      "SelectionEncloser/i18n/selectionencloser_de.qm",
+      "SelectionEncloser/i18n/selectionencloser_de.ts",
+      "SelectionEncloser/i18n/selectionencloser_en.qm",
+      "SelectionEncloser/i18n/selectionencloser_en.ts",
+      "SelectionEncloser/i18n/selectionencloser_es.qm",
+      "SelectionEncloser/i18n/selectionencloser_es.ts",
+      "SelectionEncloser/i18n/selectionencloser_ru.qm",
+      "SelectionEncloser/i18n/selectionencloser_ru.ts"
+    ],
+    "TRANSLATIONSBINPATH": "",
+    "UICPARAMS": {
+      "Package": "",
+      "PackagesRoot": "",
+      "RcSuffix": ""
+    },
+    "VCS": "Mercurial",
+    "VCSOPTIONS": {
+      "add": [
+        ""
+      ],
+      "checkout": [
+        ""
+      ],
+      "commit": [
+        ""
+      ],
+      "diff": [
+        ""
+      ],
+      "export": [
+        ""
+      ],
+      "global": [
+        ""
+      ],
+      "history": [
+        ""
+      ],
+      "log": [
+        ""
+      ],
+      "remove": [
+        ""
+      ],
+      "status": [
+        ""
+      ],
+      "tag": [
+        ""
+      ],
+      "update": [
+        ""
+      ]
+    },
+    "VCSOTHERDATA": {},
+    "VERSION": "2.x"
+  }
+}
\ No newline at end of file
--- a/SelectionEncloser/ConfigurationPage/SelectionEncloserPage.py	Wed Dec 30 11:02:15 2020 +0100
+++ b/SelectionEncloser/ConfigurationPage/SelectionEncloserPage.py	Mon Apr 26 19:57:50 2021 +0200
@@ -32,21 +32,19 @@
         
         @param plugin reference to the plugin object
         """
-        super(SelectionEncloserPage, self).__init__()
+        super().__init__()
         self.setupUi(self)
         self.setObjectName("SelectionEncloserPage")
         
         try:
             usesDarkPalette = e5App().usesDarkPalette()
         except AttributeError:
+            # for eric6 < 20.4
             from PyQt5.QtGui import QPalette
             palette = e5App().palette()
             lightness = palette.color(QPalette.Window).lightness()
             usesDarkPalette = lightness <= 128
-        if usesDarkPalette:
-            iconSuffix = "dark"
-        else:
-            iconSuffix = "light"
+        iconSuffix = "dark" if usesDarkPalette else "light"
         
         self.editButton.setIcon(UI.PixmapCache.getIcon(
             os.path.join("SelectionEncloser", "icons",
--- a/SelectionEncloser/Documentation/source/Plugin_Tools_Selection_Encloser.PluginSelectionEncloser.html	Wed Dec 30 11:02:15 2020 +0100
+++ b/SelectionEncloser/Documentation/source/Plugin_Tools_Selection_Encloser.PluginSelectionEncloser.html	Mon Apr 26 19:57:50 2021 +0200
@@ -258,7 +258,7 @@
         Public method to activate this plugin.
 </p>
 <dl>
-<dt>Returns:</dt>
+<dt>Return:</dt>
 <dd>
 tuple of None and activation status (boolean)
 </dd>
@@ -285,7 +285,7 @@
 </dd>
 </dl>
 <dl>
-<dt>Returns:</dt>
+<dt>Return:</dt>
 <dd>
 the requested setting
 </dd>
@@ -326,7 +326,7 @@
 </dd>
 </dl>
 <dl>
-<dt>Returns:</dt>
+<dt>Return:</dt>
 <dd>
 reference to the configuration page
 </dd>
@@ -342,7 +342,7 @@
     Module function returning data as required by the configuration dialog.
 </p>
 <dl>
-<dt>Returns:</dt>
+<dt>Return:</dt>
 <dd>
 dictionary containing the relevant data
 </dd>
--- a/SelectionEncloser/Documentation/source/Plugin_Tools_Selection_Encloser.SelectionEncloser.ConfigurationPage.SelectionEncloserEditDialog.html	Wed Dec 30 11:02:15 2020 +0100
+++ b/SelectionEncloser/Documentation/source/Plugin_Tools_Selection_Encloser.SelectionEncloser.ConfigurationPage.SelectionEncloserEditDialog.html	Mon Apr 26 19:57:50 2021 +0200
@@ -132,7 +132,7 @@
         Public method to get the dialog data.
 </p>
 <dl>
-<dt>Returns:</dt>
+<dt>Return:</dt>
 <dd>
 tuple with menu entry title (string) and enclosing string
             or string format expression (string)

eric ide

mercurial