Ported the plug-in to PyQt6 for eric7. eric7

Fri, 28 May 2021 19:48:54 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 28 May 2021 19:48:54 +0200
branch
eric7
changeset 54
b43a0eccfc61
parent 53
a64adc8090ef
child 55
9ef5993d4f85

Ported the plug-in to PyQt6 for eric7.

.hgignore file | annotate | diff | comparison | revisions
ChangeLog file | annotate | diff | comparison | revisions
PluginToolGenerateHash.e4p file | annotate | diff | comparison | revisions
PluginToolGenerateHash.epj file | annotate | diff | comparison | revisions
PluginToolGenerateHash.py file | annotate | diff | comparison | revisions
PluginToolGenerateHash.zip file | annotate | diff | comparison | revisions
ToolGenerateHash/Documentation/source/Plugin_Tools_GenerateHash.PluginToolGenerateHash.html file | annotate | diff | comparison | revisions
ToolGenerateHash/i18n/generatehash_de.qm file | annotate | diff | comparison | revisions
ToolGenerateHash/i18n/generatehash_de.ts file | annotate | diff | comparison | revisions
ToolGenerateHash/i18n/generatehash_en.qm file | annotate | diff | comparison | revisions
ToolGenerateHash/i18n/generatehash_en.ts file | annotate | diff | comparison | revisions
ToolGenerateHash/i18n/generatehash_es.ts file | annotate | diff | comparison | revisions
ToolGenerateHash/i18n/generatehash_ru.ts file | annotate | diff | comparison | revisions
--- a/.hgignore	Fri May 28 19:40:05 2021 +0200
+++ b/.hgignore	Fri May 28 19:48:54 2021 +0200
@@ -1,11 +1,6 @@
 glob:.eric6project
-glob:_eric6project
-glob:.eric5project
-glob:_eric5project
-glob:.eric4project
-glob:_eric4project
+glob:.eric7project
 glob:.ropeproject
-glob:_ropeproject
 glob:.directory
 glob:**.pyc
 glob:**.pyo
--- a/ChangeLog	Fri May 28 19:40:05 2021 +0200
+++ b/ChangeLog	Fri May 28 19:48:54 2021 +0200
@@ -1,5 +1,10 @@
 ChangeLog
 ---------
+Version 1.0.0:
+- first release of the eric7 variant
+
+************************************************************
+
 Version 3.2.0:
 - implemented some code simplifications.
 
--- a/PluginToolGenerateHash.e4p	Fri May 28 19:40:05 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,512 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE Project SYSTEM "Project-5.1.dtd">
-<!-- eric project file for project PluginToolGenerateHash -->
-<!-- Copyright (C) 2020 Detlev Offenbach, detlev@die-offenbachs.de -->
-<Project version="5.1">
-  <Language>en_US</Language>
-  <Hash>e12a2faac47650641bab7c4e2ba3e72e34c1a040</Hash>
-  <ProgLanguage mixed="0">Python3</ProgLanguage>
-  <ProjectType>E6Plugin</ProjectType>
-  <Description>Plug-in to generate a hash for a selectable file or directory. The hash string will be inserted at the cursor position of the current editor. The menu will be disabled, if no editor is open.</Description>
-  <Version>2.x</Version>
-  <Author>Detlev Offenbach</Author>
-  <Email>detlev@die-offenbachs.de</Email>
-  <TranslationPattern>ToolGenerateHash/i18n/generatehash_%language%.ts</TranslationPattern>
-  <Eol index="1"/>
-  <Sources>
-    <Source>PluginToolGenerateHash.py</Source>
-    <Source>ToolGenerateHash/__init__.py</Source>
-    <Source>__init__.py</Source>
-  </Sources>
-  <Translations>
-    <Translation>ToolGenerateHash/i18n/generatehash_de.qm</Translation>
-    <Translation>ToolGenerateHash/i18n/generatehash_de.ts</Translation>
-    <Translation>ToolGenerateHash/i18n/generatehash_en.qm</Translation>
-    <Translation>ToolGenerateHash/i18n/generatehash_en.ts</Translation>
-    <Translation>ToolGenerateHash/i18n/generatehash_es.qm</Translation>
-    <Translation>ToolGenerateHash/i18n/generatehash_es.ts</Translation>
-    <Translation>ToolGenerateHash/i18n/generatehash_ru.qm</Translation>
-    <Translation>ToolGenerateHash/i18n/generatehash_ru.ts</Translation>
-  </Translations>
-  <Others>
-    <Other>.hgignore</Other>
-    <Other>ChangeLog</Other>
-    <Other>PKGLIST</Other>
-    <Other>PluginToolGenerateHash.e4p</Other>
-    <Other>PluginToolGenerateHash.zip</Other>
-    <Other>ToolGenerateHash/Documentation/LICENSE.GPL3</Other>
-    <Other>ToolGenerateHash/Documentation/source</Other>
-  </Others>
-  <MainScript>PluginToolGenerateHash.py</MainScript>
-  <Vcs>
-    <VcsType>Mercurial</VcsType>
-    <VcsOptions>
-      <dict>
-        <key>
-          <string>add</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-        <key>
-          <string>checkout</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-        <key>
-          <string>commit</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-        <key>
-          <string>diff</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-        <key>
-          <string>export</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-        <key>
-          <string>global</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-        <key>
-          <string>history</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-        <key>
-          <string>log</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-        <key>
-          <string>remove</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-        <key>
-          <string>status</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-        <key>
-          <string>tag</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-        <key>
-          <string>update</string>
-        </key>
-        <value>
-          <list>
-            <string></string>
-          </list>
-        </value>
-      </dict>
-    </VcsOptions>
-  </Vcs>
-  <FiletypeAssociations>
-    <FiletypeAssociation pattern="*.idl" type="INTERFACES"/>
-    <FiletypeAssociation pattern="*.py" type="SOURCES"/>
-    <FiletypeAssociation pattern="*.py3" type="SOURCES"/>
-    <FiletypeAssociation pattern="*.pyw" type="SOURCES"/>
-    <FiletypeAssociation pattern="*.pyw3" type="SOURCES"/>
-    <FiletypeAssociation pattern="*.qm" type="TRANSLATIONS"/>
-    <FiletypeAssociation pattern="*.qrc" type="RESOURCES"/>
-    <FiletypeAssociation pattern="*.ts" type="TRANSLATIONS"/>
-    <FiletypeAssociation pattern="*.ui" type="FORMS"/>
-    <FiletypeAssociation pattern="*.ui.h" type="FORMS"/>
-    <FiletypeAssociation pattern="Ui_*.py" type="__IGNORE__"/>
-  </FiletypeAssociations>
-  <Documentation>
-    <DocumentationParams>
-      <dict>
-        <key>
-          <string>ERIC4DOC</string>
-        </key>
-        <value>
-          <dict>
-            <key>
-              <string>cssFile</string>
-            </key>
-            <value>
-              <string>%PYTHON%/eric6/CSSs/default.css</string>
-            </value>
-            <key>
-              <string>ignoreDirectories</string>
-            </key>
-            <value>
-              <list>
-                <string>.eric5project</string>
-                <string>.hg</string>
-                <string>.ropeproject</string>
-                <string>_eric5project</string>
-                <string>_ropeproject</string>
-                <string>.eric6project</string>
-                <string>_eric6project</string>
-              </list>
-            </value>
-            <key>
-              <string>ignoreFilePatterns</string>
-            </key>
-            <value>
-              <list>
-                <string>Ui_*.py</string>
-              </list>
-            </value>
-            <key>
-              <string>noempty</string>
-            </key>
-            <value>
-              <bool>True</bool>
-            </value>
-            <key>
-              <string>outputDirectory</string>
-            </key>
-            <value>
-              <string>ToolGenerateHash/Documentation/source</string>
-            </value>
-            <key>
-              <string>qtHelpEnabled</string>
-            </key>
-            <value>
-              <bool>False</bool>
-            </value>
-            <key>
-              <string>useRecursion</string>
-            </key>
-            <value>
-              <bool>True</bool>
-            </value>
-          </dict>
-        </value>
-      </dict>
-    </DocumentationParams>
-  </Documentation>
-  <Checkers>
-    <CheckersParams>
-      <dict>
-        <key>
-          <string>Pep8Checker</string>
-        </key>
-        <value>
-          <dict>
-            <key>
-              <string>AnnotationsChecker</string>
-            </key>
-            <value>
-              <dict>
-                <key>
-                  <string>MaximumComplexity</string>
-                </key>
-                <value>
-                  <int>3</int>
-                </value>
-                <key>
-                  <string>MinimumCoverage</string>
-                </key>
-                <value>
-                  <int>75</int>
-                </value>
-              </dict>
-            </value>
-            <key>
-              <string>BlankLines</string>
-            </key>
-            <value>
-              <tuple>
-                <int>2</int>
-                <int>1</int>
-              </tuple>
-            </value>
-            <key>
-              <string>BuiltinsChecker</string>
-            </key>
-            <value>
-              <dict>
-                <key>
-                  <string>bytes</string>
-                </key>
-                <value>
-                  <list>
-                    <string>unicode</string>
-                  </list>
-                </value>
-                <key>
-                  <string>chr</string>
-                </key>
-                <value>
-                  <list>
-                    <string>unichr</string>
-                  </list>
-                </value>
-                <key>
-                  <string>str</string>
-                </key>
-                <value>
-                  <list>
-                    <string>unicode</string>
-                  </list>
-                </value>
-              </dict>
-            </value>
-            <key>
-              <string>CommentedCodeChecker</string>
-            </key>
-            <value>
-              <dict>
-                <key>
-                  <string>Aggressive</string>
-                </key>
-                <value>
-                  <bool>False</bool>
-                </value>
-              </dict>
-            </value>
-            <key>
-              <string>CopyrightAuthor</string>
-            </key>
-            <value>
-              <string></string>
-            </value>
-            <key>
-              <string>CopyrightMinFileSize</string>
-            </key>
-            <value>
-              <int>0</int>
-            </value>
-            <key>
-              <string>DocstringType</string>
-            </key>
-            <value>
-              <string>eric</string>
-            </value>
-            <key>
-              <string>EnabledCheckerCategories</string>
-            </key>
-            <value>
-              <string>C, D, E, M, N, S, W</string>
-            </value>
-            <key>
-              <string>ExcludeFiles</string>
-            </key>
-            <value>
-              <string>*/Ui_*.py, */*_rc.py</string>
-            </value>
-            <key>
-              <string>ExcludeMessages</string>
-            </key>
-            <value>
-              <string>C101,E265,E266,E305,E402,M811,N802,N803,N807,N808,N821,W293,W504</string>
-            </value>
-            <key>
-              <string>FixCodes</string>
-            </key>
-            <value>
-              <string></string>
-            </value>
-            <key>
-              <string>FixIssues</string>
-            </key>
-            <value>
-              <bool>False</bool>
-            </value>
-            <key>
-              <string>FutureChecker</string>
-            </key>
-            <value>
-              <string></string>
-            </value>
-            <key>
-              <string>HangClosing</string>
-            </key>
-            <value>
-              <bool>False</bool>
-            </value>
-            <key>
-              <string>IncludeMessages</string>
-            </key>
-            <value>
-              <string></string>
-            </value>
-            <key>
-              <string>LineComplexity</string>
-            </key>
-            <value>
-              <int>20</int>
-            </value>
-            <key>
-              <string>LineComplexityScore</string>
-            </key>
-            <value>
-              <int>10</int>
-            </value>
-            <key>
-              <string>MaxCodeComplexity</string>
-            </key>
-            <value>
-              <int>10</int>
-            </value>
-            <key>
-              <string>MaxDocLineLength</string>
-            </key>
-            <value>
-              <int>79</int>
-            </value>
-            <key>
-              <string>MaxLineLength</string>
-            </key>
-            <value>
-              <int>79</int>
-            </value>
-            <key>
-              <string>NoFixCodes</string>
-            </key>
-            <value>
-              <string>E501</string>
-            </value>
-            <key>
-              <string>RepeatMessages</string>
-            </key>
-            <value>
-              <bool>True</bool>
-            </value>
-            <key>
-              <string>SecurityChecker</string>
-            </key>
-            <value>
-              <dict>
-                <key>
-                  <string>CheckTypedException</string>
-                </key>
-                <value>
-                  <bool>False</bool>
-                </value>
-                <key>
-                  <string>HardcodedTmpDirectories</string>
-                </key>
-                <value>
-                  <list>
-                    <string>/tmp</string>
-                    <string>/var/tmp</string>
-                    <string>/dev/shm</string>
-                    <string>~/tmp</string>
-                  </list>
-                </value>
-                <key>
-                  <string>InsecureHashes</string>
-                </key>
-                <value>
-                  <list>
-                    <string>md4</string>
-                    <string>md5</string>
-                    <string>sha</string>
-                    <string>sha1</string>
-                  </list>
-                </value>
-                <key>
-                  <string>InsecureSslProtocolVersions</string>
-                </key>
-                <value>
-                  <list>
-                    <string>PROTOCOL_SSLv2</string>
-                    <string>SSLv2_METHOD</string>
-                    <string>SSLv23_METHOD</string>
-                    <string>PROTOCOL_SSLv3</string>
-                    <string>PROTOCOL_TLSv1</string>
-                    <string>SSLv3_METHOD</string>
-                    <string>TLSv1_METHOD</string>
-                  </list>
-                </value>
-                <key>
-                  <string>WeakKeySizeDsaHigh</string>
-                </key>
-                <value>
-                  <string>1024</string>
-                </value>
-                <key>
-                  <string>WeakKeySizeDsaMedium</string>
-                </key>
-                <value>
-                  <string>2048</string>
-                </value>
-                <key>
-                  <string>WeakKeySizeEcHigh</string>
-                </key>
-                <value>
-                  <string>160</string>
-                </value>
-                <key>
-                  <string>WeakKeySizeEcMedium</string>
-                </key>
-                <value>
-                  <string>224</string>
-                </value>
-                <key>
-                  <string>WeakKeySizeRsaHigh</string>
-                </key>
-                <value>
-                  <string>1024</string>
-                </value>
-                <key>
-                  <string>WeakKeySizeRsaMedium</string>
-                </key>
-                <value>
-                  <string>2048</string>
-                </value>
-              </dict>
-            </value>
-            <key>
-              <string>ShowIgnored</string>
-            </key>
-            <value>
-              <bool>False</bool>
-            </value>
-            <key>
-              <string>ValidEncodings</string>
-            </key>
-            <value>
-              <string>latin-1, utf-8</string>
-            </value>
-          </dict>
-        </value>
-      </dict>
-    </CheckersParams>
-  </Checkers>
-</Project>
--- a/PluginToolGenerateHash.epj	Fri May 28 19:40:05 2021 +0200
+++ b/PluginToolGenerateHash.epj	Fri May 28 19:48:54 2021 +0200
@@ -113,15 +113,12 @@
     "DOCSTRING": "",
     "DOCUMENTATIONPARMS": {
       "ERIC4DOC": {
-        "cssFile": "%PYTHON%/eric6/CSSs/default.css",
+        "cssFile": "%PYTHON%/eric7/CSSs/default.css",
         "ignoreDirectories": [
-          ".eric5project",
           ".hg",
           ".ropeproject",
-          "_eric5project",
-          "_ropeproject",
           ".eric6project",
-          "_eric6project"
+          ".eric7project"
         ],
         "ignoreFilePatterns": [
           "Ui_*.py"
@@ -135,17 +132,25 @@
     "EMAIL": "detlev@die-offenbachs.de",
     "EOL": 1,
     "FILETYPES": {
+      "*.epj": "OTHERS",
       "*.idl": "INTERFACES",
+      "*.md": "OTHERS",
+      "*.proto": "PROTOCOLS",
       "*.py": "SOURCES",
       "*.py3": "SOURCES",
       "*.pyw": "SOURCES",
       "*.pyw3": "SOURCES",
       "*.qm": "TRANSLATIONS",
-      "*.qrc": "RESOURCES",
+      "*.rst": "OTHERS",
       "*.ts": "TRANSLATIONS",
+      "*.txt": "OTHERS",
       "*.ui": "FORMS",
-      "*.ui.h": "FORMS",
-      "Ui_*.py": "__IGNORE__"
+      "GNUmakefile": "OTHERS",
+      "Makefile": "OTHERS",
+      "README": "OTHERS",
+      "README.*": "OTHERS",
+      "Ui_*.py": "SOURCES",
+      "makefile": "OTHERS"
     },
     "FORMS": [],
     "HASH": "e12a2faac47650641bab7c4e2ba3e72e34c1a040",
@@ -170,7 +175,6 @@
       ".hgignore",
       "ChangeLog",
       "PKGLIST",
-      "PluginToolGenerateHash.e4p",
       "PluginToolGenerateHash.zip",
       "ToolGenerateHash/Documentation/LICENSE.GPL3",
       "ToolGenerateHash/Documentation/source",
@@ -179,7 +183,7 @@
     "OTHERTOOLSPARMS": {},
     "PACKAGERSPARMS": {},
     "PROGLANGUAGE": "Python3",
-    "PROJECTTYPE": "E6Plugin",
+    "PROJECTTYPE": "E7Plugin",
     "PROJECTTYPESPECIFICDATA": {},
     "PROTOCOLS": [],
     "RCCPARAMS": {
@@ -255,6 +259,6 @@
       ]
     },
     "VCSOTHERDATA": {},
-    "VERSION": "2.x"
+    "VERSION": ""
   }
 }
\ No newline at end of file
--- a/PluginToolGenerateHash.py	Fri May 28 19:40:05 2021 +0200
+++ b/PluginToolGenerateHash.py	Fri May 28 19:48:54 2021 +0200
@@ -11,18 +11,19 @@
 import os
 import hashlib
 
-from PyQt5.QtCore import QObject, QTranslator
-from PyQt5.QtWidgets import QMenu
+from PyQt6.QtCore import pyqtSlot, QObject, QTranslator
+from PyQt6.QtGui import QAction
+from PyQt6.QtWidgets import QMenu
 
-from E5Gui.E5Application import e5App
-from E5Gui import E5FileDialog, E5MessageBox
+from EricWidgets.EricApplication import ericApp
+from EricWidgets import EricFileDialog, EricMessageBox
 
 # Start-Of-Header
 name = "Generate Hash Tool Plug-in"
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "3.2.0"
+version = "1.0.0"
 className = "ToolGenerateHashPlugin"
 packageName = "ToolGenerateHash"
 shortDescription = "Generate a hash for a selectable file or directory"
@@ -42,14 +43,11 @@
     """
     Class implementing the 'Generate Hash' tool plug-in.
     """
-    Hashes = {
-        "MD5": hashlib.md5,
-        "SHA1": hashlib.sha1,
-        "SHA224": hashlib.sha224,
-        "SHA256": hashlib.sha256,
-        "SHA384": hashlib.sha384,
-        "SHA512": hashlib.sha512,
-    }
+    Hashes = [
+        h for h in ("md5", "sha1", "sha224", "sha256", "sha384", "sha512",
+                    "sha3_224", "sha3_256", "sha3_384", "sha3_512")
+        if h in hashlib.algorithms_guaranteed
+    ]
     
     def __init__(self, ui):
         """
@@ -72,7 +70,8 @@
         """
         Public method to activate this plugin.
         
-        @return tuple of None and activation status (boolean)
+        @return tuple of None and activation status
+        @rtype bool
         """
         global error
         error = ""     # clear previous error
@@ -89,12 +88,12 @@
             act = menu.addMenu(self.__dirMenu)
             self.__mainActions.append(act)
         
-        e5App().getObject("ViewManager").editorOpenedEd.connect(
+        ericApp().getObject("ViewManager").editorOpenedEd.connect(
             self.__editorOpened)
-        e5App().getObject("ViewManager").editorClosedEd.connect(
+        ericApp().getObject("ViewManager").editorClosedEd.connect(
             self.__editorClosed)
         
-        for editor in e5App().getObject("ViewManager").getOpenEditors():
+        for editor in ericApp().getObject("ViewManager").getOpenEditors():
             self.__editorOpened(editor)
         
         return None, True
@@ -111,9 +110,9 @@
                 menu.removeAction(act)
         self.__mainActions = []
 
-        e5App().getObject("ViewManager").editorOpenedEd.disconnect(
+        ericApp().getObject("ViewManager").editorOpenedEd.disconnect(
             self.__editorOpened)
-        e5App().getObject("ViewManager").editorClosedEd.disconnect(
+        ericApp().getObject("ViewManager").editorClosedEd.disconnect(
             self.__editorClosed)
         
         for editor, acts in self.__editors.items():
@@ -138,7 +137,7 @@
                 loaded = translator.load(translation, locale_dir)
                 if loaded:
                     self.__translator = translator
-                    e5App().installTranslator(self.__translator)
+                    ericApp().installTranslator(self.__translator)
                 else:
                     print("Warning: translation file '{0}' could not be"
                           " loaded.".format(translation))
@@ -149,40 +148,32 @@
         Private method to initialize the hash generation menus.
         """
         self.__fileMenu = QMenu(self.tr("Generate File Hash"))
-        self.__fileMenu.addAction("MD5", self.__hashFile).setData("MD5")
-        self.__fileMenu.addAction("SHA1", self.__hashFile).setData("SHA1")
-        self.__fileMenu.addAction("SHA224", self.__hashFile).setData("SHA224")
-        self.__fileMenu.addAction("SHA256", self.__hashFile).setData("SHA256")
-        self.__fileMenu.addAction("SHA384", self.__hashFile).setData("SHA384")
-        self.__fileMenu.addAction("SHA512", self.__hashFile).setData("SHA512")
+        for hash in self.Hashes:
+            self.__fileMenu.addAction(
+                hash.upper().replace("_", ":")).setData(hash)
         self.__fileMenu.setEnabled(False)
+        self.__fileMenu.triggered.connect(self.__hashFile)
         
         self.__dirMenu = QMenu(self.tr("Generate Directory Hash"))
-        self.__dirMenu.addAction(
-            "MD5", self.__hashDirectory).setData("MD5")
-        self.__dirMenu.addAction(
-            "SHA1", self.__hashDirectory).setData("SHA1")
-        self.__dirMenu.addAction(
-            "SHA224", self.__hashDirectory).setData("SHA224")
-        self.__dirMenu.addAction(
-            "SHA256", self.__hashDirectory).setData("SHA256")
-        self.__dirMenu.addAction(
-            "SHA384", self.__hashDirectory).setData("SHA384")
-        self.__dirMenu.addAction(
-            "SHA512", self.__hashDirectory).setData("SHA512")
+        for hash in self.Hashes:
+            self.__dirMenu.addAction(
+                hash.upper().replace("_", ":")).setData(hash)
         self.__dirMenu.setEnabled(False)
+        self.__dirMenu.triggered.connect(self.__hashDirectory)
     
     def __populateMenu(self, name, menu):
         """
         Private slot to populate the tools menu with our entries.
         
-        @param name name of the menu (string)
-        @param menu reference to the menu to be populated (QMenu)
+        @param name name of the menu
+        @type str
+        @param menu reference to the menu to be populated
+        @type QMenu
         """
         if name not in ["Tools", "PluginTools"]:
             return
         
-        editor = e5App().getObject("ViewManager").activeWindow()
+        editor = ericApp().getObject("ViewManager").activeWindow()
         
         if name == "Tools":
             if not menu.isEmpty():
@@ -200,7 +191,8 @@
         """
         Private slot called, when a new editor was opened.
         
-        @param editor reference to the new editor (QScintilla.Editor)
+        @param editor reference to the new editor
+        @type Editor
         """
         menu = editor.getMenu("Tools")
         if menu is not None:
@@ -221,7 +213,8 @@
         """
         Private slot called, when an editor was closed.
         
-        @param editor reference to the editor (QScintilla.Editor)
+        @param editor reference to the editor
+        @type Editor
         """
         with contextlib.suppress(KeyError):
             del self.__editors[editor]
@@ -234,9 +227,12 @@
         Private slot called, when the the editor context menu or a submenu is
         about to be shown.
         
-        @param menuName name of the menu to be shown (string)
-        @param menu reference to the menu (QMenu)
+        @param menuName name of the menu to be shown
+        @type str
+        @param menu reference to the menu
+        @type QMenu
         @param editor reference to the editor
+        @type Editor
         """
         if (
             menuName == "Tools" and
@@ -259,33 +255,37 @@
         """
         Private method to insert the generated hash string.
         
-        @param hashStr hash string (string)
+        @param hashStr hash string
+        @type str
         """
         if hashStr:
-            editor = e5App().getObject("ViewManager").activeWindow()
+            editor = ericApp().getObject("ViewManager").activeWindow()
             line, index = editor.getCursorPosition()
-            # It should be done on this way to allow undo
+            # It should be done this way to allow undo
             editor.beginUndoAction()
             editor.insertAt(hashStr, line, index)
             editor.endUndoAction()
     
-    def __hashFile(self):
+    @pyqtSlot(QAction)
+    def __hashFile(self, act):
         """
         Private slot to generate the hash for a file.
+        
+        @param act reference to the action that was triggered
+        @type QAction
         """
-        act = self.sender()
         if act is None:
             return
         
-        name = E5FileDialog.getOpenFileName(
+        name = EricFileDialog.getOpenFileName(
             self.__ui,
             self.tr("Generate File Hash"))
         if name:
             try:
                 with open(name, "rb") as f:
-                    hashStr = self.Hashes[act.data()](f.read()).hexdigest()
+                    hashStr = hashlib.new(act.data(), f.read()).hexdigest()
             except OSError as err:
-                E5MessageBox.critical(
+                EricMessageBox.critical(
                     self.__ui,
                     self.tr("Generate File Hash"),
                     self.tr("""<p>The hash for <b>{0}</b> could not"""
@@ -296,19 +296,22 @@
             
             self.__insertHash(hashStr)
     
-    def __hashDirectory(self):
+    @pyqtSlot(QAction)
+    def __hashDirectory(self, act):
         """
         Private slot to generate the hash for a directory.
+        
+        @param act reference to the action that was triggered
+        @type QAction
         """
-        act = self.sender()
         if act is None:
             return
         
-        folder = E5FileDialog.getExistingDirectory(
+        folder = EricFileDialog.getExistingDirectory(
             self.__ui,
             self.tr("Generate Directory Hash"),
             "",
-            E5FileDialog.Options(E5FileDialog.Option(0)))
+            EricFileDialog.Option(0))
         if folder and os.path.isdir(folder):
             fails = 0
             hashes = []
@@ -319,20 +322,20 @@
                 ):
                     try:
                         with open(os.path.join(folder, name), "rb") as f:
-                            hashStr = self.Hashes[act.data()](
-                                f.read()).hexdigest()
+                            hashStr = hashlib.new(
+                                act.data(), f.read()).hexdigest()
                         hashes.append((name, hashStr))
                     except OSError:
                         fails += 1
             if fails:
-                E5MessageBox.critical(
+                EricMessageBox.critical(
                     self.__ui,
                     self.tr("Generate Directory Hash"),
                     self.tr("""<p>The hash for some files could not"""
                             """ be generated.</p>""")
                 )
             else:
-                editor = e5App().getObject("ViewManager").activeWindow()
+                editor = ericApp().getObject("ViewManager").activeWindow()
                 line, index = editor.getCursorPosition()
                 indLevel = (editor.indentation(line) //
                             editor.indentationWidth())
Binary file PluginToolGenerateHash.zip has changed
--- a/ToolGenerateHash/Documentation/source/Plugin_Tools_GenerateHash.PluginToolGenerateHash.html	Fri May 28 19:40:05 2021 +0200
+++ b/ToolGenerateHash/Documentation/source/Plugin_Tools_GenerateHash.PluginToolGenerateHash.html	Fri May 28 19:48:54 2021 +0200
@@ -146,9 +146,9 @@
 </p>
 <dl>
 
-<dt><i>editor</i></dt>
+<dt><i>editor</i> (Editor)</dt>
 <dd>
-reference to the editor (QScintilla.Editor)
+reference to the editor
 </dd>
 </dl>
 <a NAME="ToolGenerateHashPlugin.__editorOpened" ID="ToolGenerateHashPlugin.__editorOpened"></a>
@@ -160,9 +160,9 @@
 </p>
 <dl>
 
-<dt><i>editor</i></dt>
+<dt><i>editor</i> (Editor)</dt>
 <dd>
-reference to the new editor (QScintilla.Editor)
+reference to the new editor
 </dd>
 </dl>
 <a NAME="ToolGenerateHashPlugin.__editorShowMenu" ID="ToolGenerateHashPlugin.__editorShowMenu"></a>
@@ -175,33 +175,47 @@
 </p>
 <dl>
 
-<dt><i>menuName</i></dt>
+<dt><i>menuName</i> (str)</dt>
 <dd>
-name of the menu to be shown (string)
+name of the menu to be shown
 </dd>
-<dt><i>menu</i></dt>
+<dt><i>menu</i> (QMenu)</dt>
 <dd>
-reference to the menu (QMenu)
+reference to the menu
 </dd>
-<dt><i>editor</i></dt>
+<dt><i>editor</i> (Editor)</dt>
 <dd>
 reference to the editor
 </dd>
 </dl>
 <a NAME="ToolGenerateHashPlugin.__hashDirectory" ID="ToolGenerateHashPlugin.__hashDirectory"></a>
 <h4>ToolGenerateHashPlugin.__hashDirectory</h4>
-<b>__hashDirectory</b>(<i></i>)
+<b>__hashDirectory</b>(<i>act</i>)
 
 <p>
         Private slot to generate the hash for a directory.
 </p>
+<dl>
+
+<dt><i>act</i> (QAction)</dt>
+<dd>
+reference to the action that was triggered
+</dd>
+</dl>
 <a NAME="ToolGenerateHashPlugin.__hashFile" ID="ToolGenerateHashPlugin.__hashFile"></a>
 <h4>ToolGenerateHashPlugin.__hashFile</h4>
-<b>__hashFile</b>(<i></i>)
+<b>__hashFile</b>(<i>act</i>)
 
 <p>
         Private slot to generate the hash for a file.
 </p>
+<dl>
+
+<dt><i>act</i> (QAction)</dt>
+<dd>
+reference to the action that was triggered
+</dd>
+</dl>
 <a NAME="ToolGenerateHashPlugin.__initMenus" ID="ToolGenerateHashPlugin.__initMenus"></a>
 <h4>ToolGenerateHashPlugin.__initMenus</h4>
 <b>__initMenus</b>(<i></i>)
@@ -218,9 +232,9 @@
 </p>
 <dl>
 
-<dt><i>hashStr</i></dt>
+<dt><i>hashStr</i> (str)</dt>
 <dd>
-hash string (string)
+hash string
 </dd>
 </dl>
 <a NAME="ToolGenerateHashPlugin.__loadTranslator" ID="ToolGenerateHashPlugin.__loadTranslator"></a>
@@ -239,13 +253,13 @@
 </p>
 <dl>
 
-<dt><i>name</i></dt>
+<dt><i>name</i> (str)</dt>
 <dd>
-name of the menu (string)
+name of the menu
 </dd>
-<dt><i>menu</i></dt>
+<dt><i>menu</i> (QMenu)</dt>
 <dd>
-reference to the menu to be populated (QMenu)
+reference to the menu to be populated
 </dd>
 </dl>
 <a NAME="ToolGenerateHashPlugin.activate" ID="ToolGenerateHashPlugin.activate"></a>
@@ -258,7 +272,13 @@
 <dl>
 <dt>Return:</dt>
 <dd>
-tuple of None and activation status (boolean)
+tuple of None and activation status
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+bool
 </dd>
 </dl>
 <a NAME="ToolGenerateHashPlugin.deactivate" ID="ToolGenerateHashPlugin.deactivate"></a>
Binary file ToolGenerateHash/i18n/generatehash_de.qm has changed
--- a/ToolGenerateHash/i18n/generatehash_de.ts	Fri May 28 19:40:05 2021 +0200
+++ b/ToolGenerateHash/i18n/generatehash_de.ts	Fri May 28 19:48:54 2021 +0200
@@ -1,26 +1,31 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="2.0" language="de_DE" sourcelanguage="">
-<context>
+<!DOCTYPE TS>
+<TS version="2.0" language="de_DE" sourcelanguage="">
+  <context>
     <name>ToolGenerateHashPlugin</name>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="288"/>
-        <source>Generate File Hash</source>
-        <translation>Datei Hash erzeugen</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="290" />
+      <location filename="../../PluginToolGenerateHash.py" line="282" />
+      <location filename="../../PluginToolGenerateHash.py" line="150" />
+      <source>Generate File Hash</source>
+      <translation>Datei Hash erzeugen</translation>
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="328"/>
-        <source>Generate Directory Hash</source>
-        <translation>Verzeichnis Hash erzeugen</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="333" />
+      <location filename="../../PluginToolGenerateHash.py" line="312" />
+      <location filename="../../PluginToolGenerateHash.py" line="157" />
+      <source>Generate Directory Hash</source>
+      <translation>Verzeichnis Hash erzeugen</translation>
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="288"/>
-        <source>&lt;p&gt;The hash for &lt;b&gt;{0}&lt;/b&gt; could not be generated.&lt;/p&gt;&lt;p&gt;Reason: {1}&lt;/p&gt;</source>
-        <translation>&lt;p&gt;Der Hash für &lt;b&gt;{0}&lt;/b&gt; konnte nicht erzeugt werden.&lt;/p&gt;&lt;p&gt;Ursache: {1}&lt;/p&gt;</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="291" />
+      <source>&lt;p&gt;The hash for &lt;b&gt;{0}&lt;/b&gt; could not be generated.&lt;/p&gt;&lt;p&gt;Reason: {1}&lt;/p&gt;</source>
+      <translation>&lt;p&gt;Der Hash für &lt;b&gt;{0}&lt;/b&gt; konnte nicht erzeugt werden.&lt;/p&gt;&lt;p&gt;Ursache: {1}&lt;/p&gt;</translation>
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="328"/>
-        <source>&lt;p&gt;The hash for some files could not be generated.&lt;/p&gt;</source>
-        <translation>&lt;p&gt;Der Hash für einige Dateien konnte nicht erzeugt werden.&lt;/p&gt;</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="334" />
+      <source>&lt;p&gt;The hash for some files could not be generated.&lt;/p&gt;</source>
+      <translation>&lt;p&gt;Der Hash für einige Dateien konnte nicht erzeugt werden.&lt;/p&gt;</translation>
     </message>
-</context>
+  </context>
 </TS>
Binary file ToolGenerateHash/i18n/generatehash_en.qm has changed
--- a/ToolGenerateHash/i18n/generatehash_en.ts	Fri May 28 19:40:05 2021 +0200
+++ b/ToolGenerateHash/i18n/generatehash_en.ts	Fri May 28 19:48:54 2021 +0200
@@ -1,26 +1,31 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="2.0" language="en_US" sourcelanguage="">
-<context>
+<!DOCTYPE TS>
+<TS version="2.0" language="en_US" sourcelanguage="">
+  <context>
     <name>ToolGenerateHashPlugin</name>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="288"/>
-        <source>Generate File Hash</source>
-        <translation type="unfinished"></translation>
+      <location filename="../../PluginToolGenerateHash.py" line="290" />
+      <location filename="../../PluginToolGenerateHash.py" line="282" />
+      <location filename="../../PluginToolGenerateHash.py" line="150" />
+      <source>Generate File Hash</source>
+      <translation type="unfinished" />
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="328"/>
-        <source>Generate Directory Hash</source>
-        <translation type="unfinished"></translation>
+      <location filename="../../PluginToolGenerateHash.py" line="333" />
+      <location filename="../../PluginToolGenerateHash.py" line="312" />
+      <location filename="../../PluginToolGenerateHash.py" line="157" />
+      <source>Generate Directory Hash</source>
+      <translation type="unfinished" />
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="288"/>
-        <source>&lt;p&gt;The hash for &lt;b&gt;{0}&lt;/b&gt; could not be generated.&lt;/p&gt;&lt;p&gt;Reason: {1}&lt;/p&gt;</source>
-        <translation type="unfinished"></translation>
+      <location filename="../../PluginToolGenerateHash.py" line="291" />
+      <source>&lt;p&gt;The hash for &lt;b&gt;{0}&lt;/b&gt; could not be generated.&lt;/p&gt;&lt;p&gt;Reason: {1}&lt;/p&gt;</source>
+      <translation type="unfinished" />
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="328"/>
-        <source>&lt;p&gt;The hash for some files could not be generated.&lt;/p&gt;</source>
-        <translation type="unfinished"></translation>
+      <location filename="../../PluginToolGenerateHash.py" line="334" />
+      <source>&lt;p&gt;The hash for some files could not be generated.&lt;/p&gt;</source>
+      <translation type="unfinished" />
     </message>
-</context>
+  </context>
 </TS>
--- a/ToolGenerateHash/i18n/generatehash_es.ts	Fri May 28 19:40:05 2021 +0200
+++ b/ToolGenerateHash/i18n/generatehash_es.ts	Fri May 28 19:48:54 2021 +0200
@@ -1,26 +1,31 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="2.0" language="es_ES" sourcelanguage="">
-<context>
+<!DOCTYPE TS>
+<TS version="2.0" language="es_ES" sourcelanguage="">
+  <context>
     <name>ToolGenerateHashPlugin</name>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="288"/>
-        <source>Generate File Hash</source>
-        <translation>Generar Hash de Archivo</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="290" />
+      <location filename="../../PluginToolGenerateHash.py" line="282" />
+      <location filename="../../PluginToolGenerateHash.py" line="150" />
+      <source>Generate File Hash</source>
+      <translation>Generar Hash de Archivo</translation>
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="328"/>
-        <source>Generate Directory Hash</source>
-        <translation>Generar Hash de Directorio</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="333" />
+      <location filename="../../PluginToolGenerateHash.py" line="312" />
+      <location filename="../../PluginToolGenerateHash.py" line="157" />
+      <source>Generate Directory Hash</source>
+      <translation>Generar Hash de Directorio</translation>
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="288"/>
-        <source>&lt;p&gt;The hash for &lt;b&gt;{0}&lt;/b&gt; could not be generated.&lt;/p&gt;&lt;p&gt;Reason: {1}&lt;/p&gt;</source>
-        <translation>&lt;p&gt;No se ha podido generar el hash para &lt;b&gt;{0}&lt;/b&gt;.&lt;/p&gt;&lt;p&gt;Razón: {1}&lt;/p&gt;</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="291" />
+      <source>&lt;p&gt;The hash for &lt;b&gt;{0}&lt;/b&gt; could not be generated.&lt;/p&gt;&lt;p&gt;Reason: {1}&lt;/p&gt;</source>
+      <translation>&lt;p&gt;No se ha podido generar el hash para &lt;b&gt;{0}&lt;/b&gt;.&lt;/p&gt;&lt;p&gt;Razón: {1}&lt;/p&gt;</translation>
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="328"/>
-        <source>&lt;p&gt;The hash for some files could not be generated.&lt;/p&gt;</source>
-        <translation>&lt;p&gt;No se ha podido generar el hash para algunos archivos.&lt;/p&gt;</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="334" />
+      <source>&lt;p&gt;The hash for some files could not be generated.&lt;/p&gt;</source>
+      <translation>&lt;p&gt;No se ha podido generar el hash para algunos archivos.&lt;/p&gt;</translation>
     </message>
-</context>
+  </context>
 </TS>
--- a/ToolGenerateHash/i18n/generatehash_ru.ts	Fri May 28 19:40:05 2021 +0200
+++ b/ToolGenerateHash/i18n/generatehash_ru.ts	Fri May 28 19:48:54 2021 +0200
@@ -1,26 +1,31 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="2.0" language="ru_RU" sourcelanguage="">
-<context>
+<!DOCTYPE TS>
+<TS version="2.0" language="ru_RU" sourcelanguage="">
+  <context>
     <name>ToolGenerateHashPlugin</name>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="288"/>
-        <source>Generate File Hash</source>
-        <translation>Генерация хэша файла</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="290" />
+      <location filename="../../PluginToolGenerateHash.py" line="282" />
+      <location filename="../../PluginToolGenerateHash.py" line="150" />
+      <source>Generate File Hash</source>
+      <translation>Генерация хэша файла</translation>
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="328"/>
-        <source>Generate Directory Hash</source>
-        <translation>Генерация хэша директории</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="333" />
+      <location filename="../../PluginToolGenerateHash.py" line="312" />
+      <location filename="../../PluginToolGenerateHash.py" line="157" />
+      <source>Generate Directory Hash</source>
+      <translation>Генерация хэша директории</translation>
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="288"/>
-        <source>&lt;p&gt;The hash for &lt;b&gt;{0}&lt;/b&gt; could not be generated.&lt;/p&gt;&lt;p&gt;Reason: {1}&lt;/p&gt;</source>
-        <translation>&lt;p&gt;Невозможно создать хэш для &lt;b&gt;{0}&lt;/b&gt;.&lt;/p&gt;&lt;p&gt;Причина: {1}&lt;/p&gt;</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="291" />
+      <source>&lt;p&gt;The hash for &lt;b&gt;{0}&lt;/b&gt; could not be generated.&lt;/p&gt;&lt;p&gt;Reason: {1}&lt;/p&gt;</source>
+      <translation>&lt;p&gt;Невозможно создать хэш для &lt;b&gt;{0}&lt;/b&gt;.&lt;/p&gt;&lt;p&gt;Причина: {1}&lt;/p&gt;</translation>
     </message>
     <message>
-        <location filename="../../PluginToolGenerateHash.py" line="328"/>
-        <source>&lt;p&gt;The hash for some files could not be generated.&lt;/p&gt;</source>
-        <translation>&lt;p&gt;Невозможно создать хэш для некоторых файлов.&lt;/p&gt;</translation>
+      <location filename="../../PluginToolGenerateHash.py" line="334" />
+      <source>&lt;p&gt;The hash for some files could not be generated.&lt;/p&gt;</source>
+      <translation>&lt;p&gt;Невозможно создать хэш для некоторых файлов.&lt;/p&gt;</translation>
     </message>
-</context>
+  </context>
 </TS>

eric ide

mercurial