diff -r 4a8ec9716e40 -r 60ef6c28f7fb PluginToolGenerateHash.py --- a/PluginToolGenerateHash.py Wed Jan 01 11:59:02 2020 +0100 +++ b/PluginToolGenerateHash.py Wed Jun 24 17:39:41 2020 +0200 @@ -7,12 +7,6 @@ Module implementing the 'Generate Hash' tool plug-in. """ -from __future__ import unicode_literals -try: - str = unicode # __IGNORE_WARNING__ -except NameError: - pass - import os import hashlib @@ -27,17 +21,17 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "2.1.3" +version = "3.0.0" className = "ToolGenerateHashPlugin" packageName = "ToolGenerateHash" shortDescription = "Generate a hash for a selectable file or directory" -longDescription = \ - """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"""\ +longDescription = ( + """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.""" +) needsRestart = False pyqtApi = 2 -python2Compatible = True # End-Of-Header error = "" @@ -319,8 +313,10 @@ fails = 0 hashes = [] for name in os.listdir(folder): - if not name.startswith(".") and \ - os.path.isfile(os.path.join(folder, name)): + if ( + not name.startswith(".") and + os.path.isfile(os.path.join(folder, name)) + ): try: f = open(os.path.join(folder, name), "rb") hashStr = self.Hashes[act.data()](f.read()).hexdigest() @@ -337,13 +333,6 @@ ) else: editor = e5App().getObject("ViewManager").activeWindow() - if (editor.getLanguage() in ['Python', 'Python2'] and - "from __future__ import unicode_literals" - not in editor.text()): - prefix = 'u' - else: - prefix = '' - line, index = editor.getCursorPosition() indLevel = (editor.indentation(line) // editor.indentationWidth()) @@ -354,8 +343,8 @@ indent = (indLevel + 1) * indString code = ["["] for name, hashStr in hashes: - code.append("{0}({1}'{2}', '{3}'),".format( - indent, prefix, name, hashStr)) + code.append("{0}('{1}', '{2}'),".format( + indent, name, hashStr)) code.append("{0}]".format(indLevel * indString)) self.__insertHash(os.linesep.join(code))