Changed some wizards to generate PEP-8 compliant code.

Sat, 30 Nov 2013 18:01:00 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 30 Nov 2013 18:01:00 +0100
changeset 3119
8b19074bb239
parent 3118
b1278ba1d7fe
child 3120
9dca9fecacab

Changed some wizards to generate PEP-8 compliant code.

Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Plugins.WizardPlugins.InputDialogWizard.InputDialogWizardDialog.html file | annotate | diff | comparison | revisions
Plugins/WizardPlugins/InputDialogWizard/InputDialogWizardDialog.py file | annotate | diff | comparison | revisions
Plugins/WizardPlugins/MessageBoxWizard/MessageBoxWizardDialog.py file | annotate | diff | comparison | revisions
Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py file | annotate | diff | comparison | revisions
Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.ui file | annotate | diff | comparison | revisions
Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py file | annotate | diff | comparison | revisions
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Sat Nov 30 16:33:11 2013 +0100
+++ b/Documentation/Help/source.qhp	Sat Nov 30 18:01:00 2013 +0100
@@ -6862,7 +6862,6 @@
       <keyword name="InputDialogWizardDialog" id="InputDialogWizardDialog" ref="eric5.Plugins.WizardPlugins.InputDialogWizard.InputDialogWizardDialog.html#InputDialogWizardDialog" />
       <keyword name="InputDialogWizardDialog (Constructor)" id="InputDialogWizardDialog (Constructor)" ref="eric5.Plugins.WizardPlugins.InputDialogWizard.InputDialogWizardDialog.html#InputDialogWizardDialog.__init__" />
       <keyword name="InputDialogWizardDialog (Module)" id="InputDialogWizardDialog (Module)" ref="eric5.Plugins.WizardPlugins.InputDialogWizard.InputDialogWizardDialog.html" />
-      <keyword name="InputDialogWizardDialog.__getCode4" id="InputDialogWizardDialog.__getCode4" ref="eric5.Plugins.WizardPlugins.InputDialogWizard.InputDialogWizardDialog.html#InputDialogWizardDialog.__getCode4" />
       <keyword name="InputDialogWizardDialog.getCode" id="InputDialogWizardDialog.getCode" ref="eric5.Plugins.WizardPlugins.InputDialogWizard.InputDialogWizardDialog.html#InputDialogWizardDialog.getCode" />
       <keyword name="InputDialogWizardDialog.on_bTest_clicked" id="InputDialogWizardDialog.on_bTest_clicked" ref="eric5.Plugins.WizardPlugins.InputDialogWizard.InputDialogWizardDialog.html#InputDialogWizardDialog.on_bTest_clicked" />
       <keyword name="InputDialogWizardDialog.on_buttonBox_clicked" id="InputDialogWizardDialog.on_buttonBox_clicked" ref="eric5.Plugins.WizardPlugins.InputDialogWizard.InputDialogWizardDialog.html#InputDialogWizardDialog.on_buttonBox_clicked" />
--- a/Documentation/Source/eric5.Plugins.WizardPlugins.InputDialogWizard.InputDialogWizardDialog.html	Sat Nov 30 16:33:11 2013 +0100
+++ b/Documentation/Source/eric5.Plugins.WizardPlugins.InputDialogWizard.InputDialogWizardDialog.html	Sat Nov 30 18:01:00 2013 +0100
@@ -63,12 +63,9 @@
 <td><a href="#InputDialogWizardDialog.__init__">InputDialogWizardDialog</a></td>
 <td>Constructor</td>
 </tr><tr>
-<td><a href="#InputDialogWizardDialog.__getCode4">__getCode4</a></td>
+<td><a href="#InputDialogWizardDialog.getCode">getCode</a></td>
 <td>Private method to get the source code for Qt4/Qt5.</td>
 </tr><tr>
-<td><a href="#InputDialogWizardDialog.getCode">getCode</a></td>
-<td>Public method to get the source code.</td>
-</tr><tr>
 <td><a href="#InputDialogWizardDialog.on_bTest_clicked">on_bTest_clicked</a></td>
 <td>Private method to test the selected options.</td>
 </tr><tr>
@@ -93,29 +90,11 @@
 <dd>
 parent widget (QWidget)
 </dd>
-</dl><a NAME="InputDialogWizardDialog.__getCode4" ID="InputDialogWizardDialog.__getCode4"></a>
-<h4>InputDialogWizardDialog.__getCode4</h4>
-<b>__getCode4</b>(<i>indLevel, indString</i>)
-<p>
-        Private method to get the source code for Qt4/Qt5.
-</p><dl>
-<dt><i>indLevel</i></dt>
-<dd>
-indentation level (int)
-</dd><dt><i>indString</i></dt>
-<dd>
-string used for indentation (space or tab) (string)
-</dd>
-</dl><dl>
-<dt>Returns:</dt>
-<dd>
-generated code (string)
-</dd>
 </dl><a NAME="InputDialogWizardDialog.getCode" ID="InputDialogWizardDialog.getCode"></a>
 <h4>InputDialogWizardDialog.getCode</h4>
 <b>getCode</b>(<i>indLevel, indString</i>)
 <p>
-        Public method to get the source code.
+        Private method to get the source code for Qt4/Qt5.
 </p><dl>
 <dt><i>indLevel</i></dt>
 <dd>
--- a/Plugins/WizardPlugins/InputDialogWizard/InputDialogWizardDialog.py	Sat Nov 30 16:33:11 2013 +0100
+++ b/Plugins/WizardPlugins/InputDialogWizard/InputDialogWizardDialog.py	Sat Nov 30 18:01:00 2013 +0100
@@ -110,7 +110,7 @@
                 doubleTo,
                 self.sDoubleDecimals.value())
         
-    def __getCode4(self, indLevel, indString):
+    def getCode(self, indLevel, indString):
         """
         Private method to get the source code for Qt4/Qt5.
         
@@ -187,13 +187,3 @@
                 self.sCurrentItem.value(), self.cEditable.isChecked(), estring)
             
         return code
-        
-    def getCode(self, indLevel, indString):
-        """
-        Public method to get the source code.
-        
-        @param indLevel indentation level (int)
-        @param indString string used for indentation (space or tab) (string)
-        @return generated code (string)
-        """
-        return self.__getCode4(indLevel, indString)
--- a/Plugins/WizardPlugins/MessageBoxWizard/MessageBoxWizardDialog.py	Sat Nov 30 16:33:11 2013 +0100
+++ b/Plugins/WizardPlugins/MessageBoxWizard/MessageBoxWizardDialog.py	Sat Nov 30 18:01:00 2013 +0100
@@ -284,7 +284,7 @@
             return ""
         
         istring2 = istring + indString
-        joinstring = ' | \\{0}{1}'.format(os.linesep, istring2)
+        joinstring = ' |{0}{1}'.format(os.linesep, istring2)
         btnCode = ',{0}{1}QMessageBox.StandardButtons('.format(
             os.linesep, istring)
         btnCode += '{0}{1}{2})'.format(
@@ -320,24 +320,32 @@
                 parent = "None"
         
         if self.rAbout.isChecked():
-            msgdlg = "QMessageBox.about({0}".format(os.linesep)
+            msgdlg = "QMessageBox.about("
         elif self.rAboutQt.isChecked():
-            msgdlg = "QMessageBox.aboutQt({0}".format(os.linesep)
+            msgdlg = "QMessageBox.aboutQt("
         elif self.rInformation.isChecked():
-            msgdlg = "res = QMessageBox.information({0}".format(os.linesep)
+            msgdlg = "res = QMessageBox.information("
         elif self.rQuestion.isChecked():
-            msgdlg = "res = QMessageBox.question({0}".format(os.linesep)
+            msgdlg = "res = QMessageBox.question("
         elif self.rWarning.isChecked():
-            msgdlg = "res = QMessageBox.warning({0}".format(os.linesep)
+            msgdlg = "res = QMessageBox.warning("
         else:
-            msgdlg = "res = QMessageBox.critical({0}".format(os.linesep)
+            msgdlg = "res = QMessageBox.critical("
         
-        msgdlg += '{0}{1}{2}'.format(istring, parent, os.linesep)
-        msgdlg += '{0}self.trUtf8("{1}")'.format(istring, self.eCaption.text())
-        if not self.rAboutQt.isChecked():
+        if self.rAboutQt.isChecked():
+            if self.eCaption.text():
+                msgdlg += '{0}{1}{2}'.format(os.linesep, istring, parent)
+                msgdlg += ',{0}{1}self.trUtf8("{2}")'.format(
+                    os.linesep, istring, self.eCaption.text())
+            else:
+                msgdlg += parent
+        else:
+            msgdlg += '{0}{1}{2}'.format(os.linesep, istring, parent)
+            msgdlg += ',{0}{1}self.trUtf8("{2}")'.format(
+                os.linesep, istring, self.eCaption.text())
             msgdlg += ',{0}{1}self.trUtf8("""{2}""")'.format(
                 os.linesep, istring, self.eMessage.toPlainText())
-        if not self.rAbout.isChecked() and not self.rAboutQt.isChecked():
-            msgdlg += self.__getButtonCode(istring, indString)
+            if not self.rAbout.isChecked() and not self.rAboutQt.isChecked():
+                msgdlg += self.__getButtonCode(istring, indString)
         msgdlg += '){0}'.format(estring)
         return msgdlg
--- a/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py	Sat Nov 30 16:33:11 2013 +0100
+++ b/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py	Sat Nov 30 18:01:00 2013 +0100
@@ -613,7 +613,7 @@
         @param checked state of the Python 2 button (boolean)
         """
         # set the checkboxes
-        self.localeCheckBox.setHidden(not checked)
+        self.localeCheckBox.setEnabled(checked)
         if checked:
             self.unicodeCheckBox.setText(self.trUtf8("Unicode"))
         else:
@@ -672,10 +672,11 @@
         code = ''
         if self.importCheckBox.isChecked():
             code += 'import re{0}{1}'.format(os.linesep, istring)
-        code += '{0} = re.compile(r"""{1}"""'.format(
-            reVar, regexp.replace('"', '\\"'))
+        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}{1}{2}'.format(os.linesep, i1string, flags)
         code += '){0}'.format(estring)
         return code
 
--- a/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.ui	Sat Nov 30 16:33:11 2013 +0100
+++ b/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.ui	Sat Nov 30 18:01:00 2013 +0100
@@ -511,6 +511,9 @@
        </item>
        <item row="1" column="1">
         <widget class="QCheckBox" name="localeCheckBox">
+         <property name="enabled">
+          <bool>false</bool>
+         </property>
          <property name="text">
           <string>Observe Locale</string>
          </property>
--- a/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py	Sat Nov 30 16:33:11 2013 +0100
+++ b/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py	Sat Nov 30 18:01:00 2013 +0100
@@ -756,12 +756,15 @@
             options.append("QRegularExpression.UseUnicodePropertiesOption")
         if self.captureCheckBox.isChecked():
             options.append("QRegularExpression.DontCaptureOption")
-        options = " | \\{0}{1}".format(os.linesep, i1string).join(options)
+        options = " |{0}{1}".format(os.linesep, i1string).join(options)
         
-        code = '{0} = QRegularExpression(r"""{1}"""'.format(
-            reVar, regexp.replace('"', '\\"'))
+        code = '{0} = QRegularExpression('.format(reVar)
         if options:
-            code += ', {0}{1}{2}'.format(os.linesep, i1string, options)
+            code += '{0}{1}r"""{2}""",'.format(
+                os.linesep, i1string, regexp.replace('"', '\\"'))
+            code += '{0}{1}{2}'.format(os.linesep, i1string, options)
+        else:
+            code += 'r"""{0}"""'.format(regexp.replace('"', '\\"'))
         code += '){0}'.format(estring)
         return code
 

eric ide

mercurial