Mon, 26 Apr 2021 19:27:02 +0200
Implemented some code simplifications.
--- a/ChangeLog Wed Dec 30 11:02:12 2020 +0100 +++ b/ChangeLog Mon Apr 26 19:27:02 2021 +0200 @@ -1,5 +1,8 @@ ChangeLog --------- +Version 3.2.0: +- implemented some code simplifications + Version 3.1.0: - changed exec_() into exec()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ColorString.epj Mon Apr 26 19:27:02 2021 +0200 @@ -0,0 +1,263 @@ +{ + "header": { + "comment": "eric project file for project ColorString", + "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 select a color via a color selection dialog and insert it as a string at the current editor cursor position. Selected text is used to initialize the dialog and is replaced with the new color.\n", + "DOCSTRING": "", + "DOCUMENTATIONPARMS": { + "ERIC4DOC": { + "cssFile": "%PYTHON%/eric6/CSSs/default.css", + "ignoreDirectories": [ + ".eric5project", + "_eric5project", + ".ropeproject", + "_ropeproject", + ".hg", + ".eric6project", + "_eric6project" + ], + "ignoreFilePatterns": [ + "Ui_*.py" + ], + "noempty": true, + "outputDirectory": "ColorString/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": [ + "ColorString/ColorSelectionDialog.ui" + ], + "HASH": "bf7dfc760db7f57239ae96b215ea79bb0df717d5", + "IDLPARAMS": { + "DefinedNames": [], + "IncludeDirs": [], + "UndefinedNames": [] + }, + "INTERFACES": [], + "LEXERASSOCS": {}, + "MAINSCRIPT": "PluginColorString.py", + "MAKEPARAMS": { + "MakeEnabled": false, + "MakeExecutable": "", + "MakeFile": "", + "MakeParameters": "", + "MakeTarget": "", + "MakeTestOnly": true + }, + "MIXEDLANGUAGE": false, + "OTHERS": [ + ".hgignore", + "ChangeLog", + "ColorString.e4p", + "ColorString/Documentation/LICENSE.GPL3", + "ColorString/Documentation/source", + "PKGLIST", + "PluginColorString.zip", + "ColorString.epj" + ], + "OTHERTOOLSPARMS": {}, + "PACKAGERSPARMS": {}, + "PROGLANGUAGE": "Python3", + "PROJECTTYPE": "E6Plugin", + "PROJECTTYPESPECIFICDATA": {}, + "PROTOCOLS": [], + "RCCPARAMS": { + "CompressLevel": 0, + "CompressionDisable": false, + "CompressionThreshold": 70, + "PathPrefix": "" + }, + "RESOURCES": [], + "SOURCES": [ + "ColorString/ColorSelectionDialog.py", + "ColorString/__init__.py", + "PluginColorString.py", + "__init__.py" + ], + "SPELLEXCLUDES": "", + "SPELLLANGUAGE": "en_US", + "SPELLWORDS": "", + "TRANSLATIONEXCEPTIONS": [], + "TRANSLATIONPATTERN": "ColorString/i18n/colorstring_%language%.ts", + "TRANSLATIONS": [ + "ColorString/i18n/colorstring_de.qm", + "ColorString/i18n/colorstring_de.ts", + "ColorString/i18n/colorstring_en.qm", + "ColorString/i18n/colorstring_en.ts", + "ColorString/i18n/colorstring_es.qm", + "ColorString/i18n/colorstring_es.ts", + "ColorString/i18n/colorstring_ru.qm", + "ColorString/i18n/colorstring_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/ColorString/Documentation/source/Plugin_Tools_ColorString.ColorString.ColorSelectionDialog.html Wed Dec 30 11:02:12 2020 +0100 +++ b/ColorString/Documentation/source/Plugin_Tools_ColorString.ColorString.ColorSelectionDialog.html Mon Apr 26 19:27:02 2021 +0200 @@ -110,7 +110,7 @@ Public method to retrieve the selected color name. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> color name (string) </dd>
--- a/ColorString/Documentation/source/Plugin_Tools_ColorString.PluginColorString.html Wed Dec 30 11:02:12 2020 +0100 +++ b/ColorString/Documentation/source/Plugin_Tools_ColorString.PluginColorString.html Mon Apr 26 19:27:02 2021 +0200 @@ -222,7 +222,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> flag indicating a hex string (boolean) </dd> @@ -242,7 +242,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> flag indicating a valid color name (boolean) </dd> @@ -262,7 +262,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> flag indicating a valid RGBA color (boolean) and a list with the RGBA components of the color (three or four integers) @@ -322,7 +322,7 @@ Public method to activate this plugin. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> tuple of None and activation status (boolean) </dd>
--- a/PluginColorString.py Wed Dec 30 11:02:12 2020 +0100 +++ b/PluginColorString.py Mon Apr 26 19:27:02 2021 +0200 @@ -7,6 +7,7 @@ Module implementing the 'Color String' tool plug-in. """ +import contextlib import os from PyQt5.QtCore import QObject, QTranslator @@ -21,7 +22,7 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "3.1.0" +version = "3.2.0" className = "ColorStringPlugin" packageName = "ColorString" shortDescription = "Insert color as string" @@ -48,7 +49,7 @@ @param ui reference to the user interface object (UI.UserInterface) """ - QObject.__init__(self, ui) + super().__init__(ui) self.__ui = ui self.__translator = None @@ -186,12 +187,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): """ @@ -202,15 +201,17 @@ @param menu reference to the menu (QMenu) @param editor reference to the editor """ - if menuName == "Tools": - if self.__menu.menuAction() not in menu.actions(): - # Re-add our menu - self.__editors[editor] = [] - if not menu.isEmpty(): - act = menu.addSeparator() - self.__editors[editor].append(act) - act = menu.addMenu(self.__menu) + if ( + menuName == "Tools" and + self.__menu.menuAction() not in menu.actions() + ): + # Re-add our menu + self.__editors[editor] = [] + if not menu.isEmpty(): + act = menu.addSeparator() self.__editors[editor].append(act) + act = menu.addMenu(self.__menu) + self.__editors[editor].append(act) def __isHexString(self, text): """