Adjusted some wizard code generators to output Black compatible code. eric7

Wed, 26 Oct 2022 11:50:03 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 26 Oct 2022 11:50:03 +0200
branch
eric7
changeset 9433
6df1aeaa4529
parent 9432
e2445fa08533
child 9434
ef86a77942f2

Adjusted some wizard code generators to output Black compatible code.

src/eric7/Plugins/PluginWizardQFileDialog.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/ColorDialogWizard/ColorDialogWizardDialog.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/EricMessageBoxWizard/EricMessageBoxWizardDialog.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/EricPluginWizard/PluginWizardDialog.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/EricPluginWizard/PluginWizardDialog.ui file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/EricPluginWizard/Templates.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/FileDialogWizard/FileDialogWizardDialog.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/InputDialogWizard/InputDialogWizardDialog.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/MessageBoxWizard/MessageBoxWizardDialog.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.py file | annotate | diff | comparison | revisions
src/eric7/UI/UserInterface.py file | annotate | diff | comparison | revisions
--- a/src/eric7/Plugins/PluginWizardQFileDialog.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/PluginWizardQFileDialog.py	Wed Oct 26 11:50:03 2022 +0200
@@ -80,7 +80,7 @@
         """
         self.qFileDialogAction = EricAction(
             self.tr("QFileDialog Wizard"),
-            self.tr("Q&FileDialog Wizard..."),
+            self.tr("QFileDialog Wizard..."),
             0,
             0,
             self,
--- a/src/eric7/Plugins/WizardPlugins/ColorDialogWizard/ColorDialogWizardDialog.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/ColorDialogWizard/ColorDialogWizardDialog.py	Wed Oct 26 11:50:03 2022 +0200
@@ -168,7 +168,7 @@
                 istring, self.eTitle.text(), os.linesep
             )
             code += "{0}QColorDialog.ColorDialogOption.ShowAlphaChannel".format(istring)
-            code += "{0}){0}".format(estring)
+            code += ",{0}){0}".format(estring)
         elif self.rRGBA.isChecked():
             code += "getColor({0}".format(os.linesep)
             if not self.eRGB.text():
@@ -187,6 +187,6 @@
                 istring, self.eTitle.text(), os.linesep
             )
             code += "{0}QColorDialog.ColorDialogOption.ShowAlphaChannel".format(istring)
-            code += "{0}){0}".format(estring)
+            code += ",{0}){0}".format(estring)
 
         return code
--- a/src/eric7/Plugins/WizardPlugins/EricMessageBoxWizard/EricMessageBoxWizardDialog.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/EricMessageBoxWizard/EricMessageBoxWizardDialog.py	Wed Oct 26 11:50:03 2022 +0200
@@ -428,7 +428,7 @@
         if len(buttons) == 0:
             return ""
 
-        joinstring = " |{0}{1}".format(os.linesep, istring)
+        joinstring = "{0}{1}| ".format(os.linesep, istring)
         intro = "," if withIntro else ""
         btnCode = "{0}{1}{2}{3}".format(
             intro, os.linesep, istring, joinstring.join(buttons)
@@ -568,5 +568,5 @@
             if not self.parentNone.isChecked():
                 msgdlg += ",{0}{1}parent={2}".format(os.linesep, istring, parent)
 
-        msgdlg += "{0}){0}".format(estring)
+        msgdlg += ",{0}){0}".format(estring)
         return msgdlg
--- a/src/eric7/Plugins/WizardPlugins/EricPluginWizard/PluginWizardDialog.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/EricPluginWizard/PluginWizardDialog.py	Wed Oct 26 11:50:03 2022 +0200
@@ -139,7 +139,9 @@
             "className": self.classNameEdit.text(),
             "packageName": self.packageNameEdit.text(),
             "shortDescription": self.shortDescriptionEdit.text(),
-            "longDescription": self.longDescriptionEdit.toPlainText(),
+            "longDescription": '"""\n    """'.join(
+                self.longDescriptionEdit.toPlainText().splitlines()
+            ),
             "needsRestart": self.restartCheckBox.isChecked(),
         }
 
--- a/src/eric7/Plugins/WizardPlugins/EricPluginWizard/PluginWizardDialog.ui	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/EricPluginWizard/PluginWizardDialog.ui	Wed Oct 26 11:50:03 2022 +0200
@@ -224,19 +224,6 @@
            </property>
           </widget>
          </item>
-         <item row="1" column="1">
-          <widget class="QCheckBox" name="python2CheckBox">
-           <property name="toolTip">
-            <string>Select to indicate Python 2 compatibility</string>
-           </property>
-           <property name="text">
-            <string>Python 2 compatible</string>
-           </property>
-           <property name="checked">
-            <bool>true</bool>
-           </property>
-          </widget>
-         </item>
         </layout>
        </item>
        <item>
@@ -516,7 +503,6 @@
   <tabstop>autoActivateCheckBox</tabstop>
   <tabstop>deactivateableCheckBox</tabstop>
   <tabstop>restartCheckBox</tabstop>
-  <tabstop>python2CheckBox</tabstop>
   <tabstop>pluginTypeCombo</tabstop>
   <tabstop>pluginTypeNameEdit</tabstop>
   <tabstop>configurationGroup</tabstop>
--- a/src/eric7/Plugins/WizardPlugins/EricPluginWizard/Templates.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/EricPluginWizard/Templates.py	Wed Oct 26 11:50:03 2022 +0200
@@ -37,7 +37,7 @@
 # End-Of-Header
 
 error = ""
-    
+
 
 {modulesetup}\
 {exeData}\
@@ -48,29 +48,30 @@
     """
     Class documentation goes here.
     """
+
 {config2}\
     def __init__(self, ui):
         """
         Constructor
-        
+
         @param ui reference to the user interface object
         @type UI.UserInterface
         """
         super({className}, self).__init__(ui)
         self.__ui = ui
-    
+
     def activate(self):
         """
         Public method to activate this plug-in.
-        
+
         @return tuple of None and activation status
         @rtype bool
         """
         global error
-        error = ""     # clear previous error
-        
+        error = ""  # clear previous error
+
         return None, True
-    
+
     def deactivate(self):
         """
         Public method to deactivate this plug-in.
@@ -85,13 +86,18 @@
 configTemplate1 = '''def getConfigData():
     """
     Module function returning data as required by the configuration dialog.
-    
+
     @return dictionary containing the relevant data
     @rtype dict
     """
     return {{
-        "<unique key>": ["<display string>", "<pixmap filename>",
-            pageCreationFunction, None, None],
+        "<unique key>": [
+            "<display string>",
+            "<pixmap filename>",
+            pageCreationFunction,
+            None,
+            None,
+        ],
     }}
 
 
@@ -105,26 +111,25 @@
 '''
 
 configTemplate2 = """    PreferencesKey = "{preferencesKey}"
-    
+
 """
 
-configTemplate3 = '''\
-    
+configTemplate3 = '''
     def getPreferences(self, key):
         """
         Public method to retrieve the various settings values.
-        
+
         @param key the key of the value to get
         @type str
         @return the requested setting value
         @rtype any
         """
         return None
-    
+
     def setPreferences(self, key, value):
         """
         Public method to store the various settings values.
-        
+
         @param key the key of the setting to be set
         @type str
         @param value the value to be set
@@ -140,22 +145,22 @@
 previewPixmapTemplate = '''def previewPix():
     """
     Module function to return a preview pixmap.
-    
+
     @return preview pixmap
     @rtype QPixmap
     """
     from PyQt6.QtGui import QPixmap
-    
+
     fname = "preview.png"
     return QPixmap(fname)
-    
+
 
 '''
 
 exeDisplayDataListTemplate = '''def exeDisplayDataList():
     """
     Module function to support the display of some executable info.
-    
+
     @return list of dictionaries containing the data to query the presence of
         the executable
     @rtype list of dict
@@ -185,7 +190,7 @@
 exeDisplayDataTemplate = '''def exeDisplayData():
     """
     Module function to support the display of some executable info.
-    
+
     @return dictionary containing the data to query the presence of
         the executable
     @rtype dict
@@ -202,7 +207,7 @@
         "versionCleanup": None,
         "exeModule": None,
     }
-    
+
     return data
 
 
@@ -211,7 +216,7 @@
 exeDisplayDataInfoTemplate = '''def exeDisplayData():
     """
     Module function to support the display of some executable info.
-    
+
     @return dictionary containing the data to be shown
     @rtype dict
     """
@@ -221,7 +226,7 @@
         "text": "<translated entry string>",
         "version": "",
     }
-    
+
     return data
 
 
@@ -239,19 +244,17 @@
 apiFilesTemplate = '''def apiFiles(language):
     """
     Module function to return the API files made available by this plug-in.
-    
+
     @param language language to get APIs for
     @type str
     @return list of API filenames
     @rtype list of str
     """
-    if language in ["Python3",  "Python"]:
-        apisDir = os.path.join(
-            os.path.dirname(__file__), "APIs", "Python")
-        apis = glob.glob(os.path.join(apisDir, '*.api'))
-        apisDir = os.path.join(
-            os.path.dirname(__file__), "APIs", "Python3")
-        apis.extend(glob.glob(os.path.join(apisDir, '*.api')))
+    if language in ("Python3", "Python"):
+        apisDir = os.path.join(os.path.dirname(__file__), "APIs", "Python")
+        apis = glob.glob(os.path.join(apisDir, "*.api"))
+        apisDir = os.path.join(os.path.dirname(__file__), "APIs", "Python3")
+        apis.extend(glob.glob(os.path.join(apisDir, "*.api")))
     else:
         apis = []
     return apis
--- a/src/eric7/Plugins/WizardPlugins/FileDialogWizard/FileDialogWizardDialog.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/FileDialogWizard/FileDialogWizardDialog.py	Wed Oct 26 11:50:03 2022 +0200
@@ -472,7 +472,7 @@
                 code += ",{0}{1}{2}".format(
                     os.linesep, istring, self.__prepareSchemesList()
                 )
-            code += "{0}){0}".format(estring)
+            code += ",{0}){0}".format(estring)
         elif (
             self.rOpenFiles.isChecked()
             or self.rfOpenFiles.isChecked()
@@ -548,7 +548,7 @@
                 code += ",{0}{1}{2}".format(
                     os.linesep, istring, self.__prepareSchemesList()
                 )
-            code += "{0}){0}".format(estring)
+            code += ",{0}){0}".format(estring)
         elif (
             self.rSaveFile.isChecked()
             or self.rfSaveFile.isChecked()
@@ -633,7 +633,7 @@
                     os.linesep, istring, self.__prepareSchemesList()
                 )
 
-            code += "{0}){0}".format(estring)
+            code += ",{0}){0}".format(estring)
         elif self.rDirectory.isChecked() or self.rDirectoryUrl.isChecked():
             if self.rDirectory.isChecked():
                 method = (
@@ -683,7 +683,7 @@
                 code += ",{0}{1}{2}".format(
                     os.linesep, istring, self.__prepareSchemesList()
                 )
-            code += "{0}){0}".format(estring)
+            code += ",{0}){0}".format(estring)
 
         return code
 
--- a/src/eric7/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/FontDialogWizard/FontDialogWizardDialog.py	Wed Oct 26 11:50:03 2022 +0200
@@ -186,8 +186,8 @@
                     options.append("QFontDialog.FontDialogOption.MonospacedFonts")
                 if self.fontOptions["proportionalFonts"]:
                     options.append("QFontDialog.FontDialogOption.ProportionalFonts")
-                fontOptionsString = " |{0}{1}".format(os.linesep, istring).join(options)
+                fontOptionsString = "{0}{1}| ".format(os.linesep, istring).join(options)
                 code += ",{0}{1}{2}".format(os.linesep, istring, fontOptionsString)
-        code += "{0}){0}".format(estring)
+        code += ",{0}){0}".format(estring)
 
         return code
--- a/src/eric7/Plugins/WizardPlugins/InputDialogWizard/InputDialogWizardDialog.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/InputDialogWizard/InputDialogWizardDialog.py	Wed Oct 26 11:50:03 2022 +0200
@@ -204,7 +204,7 @@
                     code += ',{0}{1}"{2}"'.format(
                         os.linesep, istring, self.eTextDefault.text()
                     )
-            code += "{0}){0}".format(estring)
+            code += ",{0}){0}".format(estring)
         elif self.rMultiLineText.isChecked():
             code += "getMultiLineText({0}{1}".format(os.linesep, istring)
             code += "{0},{1}{2}".format(parent, os.linesep, istring)
@@ -218,7 +218,7 @@
                     code += ',{0}{1}self.tr("{2}")'.format(os.linesep, istring, defTxt)
                 else:
                     code += ',{0}{1}"{2}"'.format(os.linesep, istring, defTxt)
-            code += "{0}){0}".format(estring)
+            code += ",{0}){0}".format(estring)
         elif self.rInteger.isChecked():
             code += "getInt({0}{1}".format(os.linesep, istring)
             code += "{0},{1}{2}".format(parent, os.linesep, istring)
@@ -234,7 +234,7 @@
                 self.sIntTo.value(),
                 self.sIntStep.value(),
             )
-            code += "{0}){0}".format(estring)
+            code += ",{0}){0}".format(estring)
         elif self.rDouble.isChecked():
             try:
                 doubleDefault = float(self.eDoubleDefault.text())
@@ -259,7 +259,7 @@
             code += "{0}, {1}, {2}, {3:d}".format(
                 doubleDefault, doubleFrom, doubleTo, self.sDoubleDecimals.value()
             )
-            code += "{0}){0}".format(estring)
+            code += ",{0}){0}".format(estring)
         elif self.rItem.isChecked():
             code += "getItem({0}{1}".format(os.linesep, istring)
             code += "{0},{1}{2}".format(parent, os.linesep, istring)
@@ -273,6 +273,6 @@
             code += "{0:d}, {1}".format(
                 self.sCurrentItem.value(), self.cEditable.isChecked()
             )
-            code += "{0}){0}".format(estring)
+            code += ",{0}){0}".format(estring)
 
         return code
--- a/src/eric7/Plugins/WizardPlugins/MessageBoxWizard/MessageBoxWizardDialog.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/MessageBoxWizard/MessageBoxWizardDialog.py	Wed Oct 26 11:50:03 2022 +0200
@@ -279,7 +279,7 @@
             return ""
 
         istring2 = istring + indString
-        joinstring = " |{0}{1}".format(os.linesep, istring2)
+        joinstring = "{0}{1}| ".format(os.linesep, istring2)
         btnCode = ",{0}{1}(".format(os.linesep, istring)
         btnCode += "{0}{1}{2})".format(os.linesep, istring2, joinstring.join(buttons))
         defaultIndex = self.defaultCombo.currentIndex()
@@ -347,5 +347,5 @@
             )
             if not self.rAbout.isChecked() and not self.rAboutQt.isChecked():
                 msgdlg += self.__getButtonCode(istring, indString)
-        msgdlg += "{0}){0}".format(estring)
+        msgdlg += ",{0}){0}".format(estring)
         return msgdlg
--- a/src/eric7/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py	Wed Oct 26 11:50:03 2022 +0200
@@ -650,14 +650,14 @@
 
         code = ""
         if self.importCheckBox.isChecked():
-            code += "import re{0}{1}".format(os.linesep, istring)
+            code += "import re{0}{0}{1}".format(os.linesep, istring)
         code += "{0} = re.compile(".format(reVar)
         code += '{0}{1}r"""{2}"""'.format(
             os.linesep, i1string, regexp.replace('"', '\\"')
         )
         if flags:
             code += ",{0}{1}{2}".format(os.linesep, i1string, flags)
-        code += "{0}){0}".format(estring)
+        code += ",{0}){0}".format(estring)
         return code
 
 
--- a/src/eric7/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py	Wed Oct 26 11:50:03 2022 +0200
@@ -793,7 +793,7 @@
             )
         if self.captureCheckBox.isChecked():
             options.append("QRegularExpression.PatternOption.DontCaptureOption")
-        options = " |{0}{1}".format(os.linesep, i1string).join(options)
+        options = "{0}{1}| ".format(os.linesep, i1string).join(options)
 
         code = "{0} = QRegularExpression(".format(reVar)
         if options:
@@ -803,7 +803,7 @@
             code += "{0}{1}{2}".format(os.linesep, i1string, options)
         else:
             code += 'r"""{0}"""'.format(regexp.replace('"', '\\"'))
-        code += "{0}){0}".format(estring)
+        code += ",{0}){0}".format(estring)
         return code
 
 
--- a/src/eric7/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.py	Wed Oct 26 11:50:03 2022 +0200
@@ -362,7 +362,7 @@
         platforms = self.platformsEdit.toPlainText().splitlines()
         if platforms:
             sourceCode += "{0}platforms=[{1}".format(istring, os.linesep)
-            sourceCode += '{0}"{1}"{2}'.format(
+            sourceCode += '{0}"{1}",{2}'.format(
                 i1string,
                 '",{0}{1}"'.format(os.linesep, i1string).join(platforms),
                 os.linesep,
@@ -383,7 +383,7 @@
         classifiers = [c for c in classifiers if bool(c)]
         if classifiers:
             sourceCode += "{0}classifiers=[{1}".format(istring, os.linesep)
-            sourceCode += '{0}"{1}"{2}'.format(
+            sourceCode += '{0}"{1}",{2}'.format(
                 i1string,
                 '",{0}{1}"'.format(os.linesep, i1string).join(classifiers),
                 os.linesep,
@@ -414,7 +414,7 @@
                 sourceCode += "{0}{1}".format(os.linesep, istring)
         if excludePatterns:
             sourceCode += "{0}{1}exclude=[{0}".format(os.linesep, i1string)
-            sourceCode += '{0}"{1}"{2}'.format(
+            sourceCode += '{0}"{1}",{2}'.format(
                 i2string,
                 '",{0}{1}"'.format(os.linesep, i2string).join(excludePatterns),
                 os.linesep,
@@ -432,7 +432,7 @@
             modules.append(self.modulesList.item(row).text())
         if modules:
             sourceCode += "{0}py_modules=[{1}".format(istring, os.linesep)
-            sourceCode += '{0}"{1}"{2}'.format(
+            sourceCode += '{0}"{1}",{2}'.format(
                 i1string,
                 '",{0}{1}"'.format(os.linesep, i1string).join(modules),
                 os.linesep,
--- a/src/eric7/UI/UserInterface.py	Tue Oct 25 17:25:51 2022 +0200
+++ b/src/eric7/UI/UserInterface.py	Wed Oct 26 11:50:03 2022 +0200
@@ -732,8 +732,8 @@
 
         # now redirect stdout and stderr
         # TODO: release - reenable redirection
-        ##        sys.stdout = self.stdout          # __IGNORE_WARNING_M891__
-        ##        sys.stderr = self.stderr          # __IGNORE_WARNING_M891__
+        ##sys.stdout = self.stdout          # __IGNORE_WARNING_M891__
+        ##sys.stderr = self.stderr          # __IGNORE_WARNING_M891__
 
         # now fire up the single application server
         if Preferences.getUI("SingleApplicationMode"):
@@ -4535,6 +4535,11 @@
         """
         Private slot to display the Wizards menu.
         """
+        actionsList = self.__menus["wizards"].actions()
+        self.__menus["wizards"].clear()
+        self.__menus["wizards"].addActions(
+            sorted(actionsList, key=lambda a: a.text().replace("&", ""))
+        )
         self.showMenu.emit("Wizards", self.__menus["wizards"])
 
     def __showHelpMenu(self):

eric ide

mercurial