Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py

branch
Py2 comp.
changeset 2791
a9577f248f04
parent 2525
8b507a9a2d40
parent 2774
72fab2c15e28
child 2847
1843ef6e2656
--- a/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py	Mon Jul 08 21:47:26 2013 +0200
+++ b/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py	Mon Jul 08 22:36:10 2013 +0200
@@ -84,15 +84,15 @@
         self.nextButton.setEnabled(False)
         
         if fromEric:
-            self.buttonBox.button(QDialogButtonBox.Close).hide()
+            self.buttonBox.setStandardButtons(
+                QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
             self.copyButton = None
         else:
             self.copyButton = \
                 self.buttonBox.addButton(self.trUtf8("Copy"), QDialogButtonBox.ActionRole)
             self.copyButton.setToolTip(
                 self.trUtf8("Copy the regular expression to the clipboard"))
-            self.buttonBox.button(QDialogButtonBox.Ok).hide()
-            self.buttonBox.button(QDialogButtonBox.Cancel).hide()
+            self.buttonBox.setStandardButtons(QDialogButtonBox.Close)
             self.variableLabel.hide()
             self.variableLineEdit.hide()
             self.variableLine.hide()
@@ -379,21 +379,24 @@
         regex = self.regexpTextEdit.toPlainText()
         if regex:
             try:
+                flags = 0
+                if not self.caseSensitiveCheckBox.isChecked():
+                    flags |= re.IGNORECASE
+                if self.multilineCheckBox.isChecked():
+                    flags |= re.MULTILINE
+                if self.dotallCheckBox.isChecked():
+                    flags |= re.DOTALL
+                if self.verboseCheckBox.isChecked():
+                    flags |= re.VERBOSE
                 if self.py2Button.isChecked():
-                    re.compile(regex,
-                        (not self.caseSensitiveCheckBox.isChecked() and re.IGNORECASE or 0) | \
-                        self.multilineCheckBox.isChecked() and re.MULTILINE or 0 | \
-                        self.dotallCheckBox.isChecked() and re.DOTALL or 0 | \
-                        self.verboseCheckBox.isChecked() and re.VERBOSE or 0 | \
-                        self.localeCheckBox.isChecked() and re.LOCALE or 0 | \
-                        self.unicodeCheckBox.isChecked() and re.UNICODE or 0)
+                    if self.localeCheckBox.isChecked():
+                        flags |= re.LOCALE
+                    if self.unicodeCheckBox.isChecked():
+                        flags |= re.UNICODE
                 else:
-                    re.compile(regex,
-                        (not self.caseSensitiveCheckBox.isChecked() and re.IGNORECASE or 0) | \
-                        self.multilineCheckBox.isChecked() and re.MULTILINE or 0 | \
-                        self.dotallCheckBox.isChecked() and re.DOTALL or 0 | \
-                        self.verboseCheckBox.isChecked() and re.VERBOSE or 0 | \
-                        (not self.unicodeCheckBox.isChecked() and re.UNICODE or 0))
+                    if self.unicodeCheckBox.isChecked():
+                        flags |= re.ASCII
+                re.compile(regex, flags)
                 E5MessageBox.information(self,
                     self.trUtf8("Validation"),
                     self.trUtf8("""The regular expression is valid."""))
@@ -427,21 +430,24 @@
         text = self.textTextEdit.toPlainText()
         if regex and text:
             try:
+                flags = 0
+                if not self.caseSensitiveCheckBox.isChecked():
+                    flags |= re.IGNORECASE
+                if self.multilineCheckBox.isChecked():
+                    flags |= re.MULTILINE
+                if self.dotallCheckBox.isChecked():
+                    flags |= re.DOTALL
+                if self.verboseCheckBox.isChecked():
+                    flags |= re.VERBOSE
                 if self.py2Button.isChecked():
-                    regobj = re.compile(regex,
-                        (not self.caseSensitiveCheckBox.isChecked() and re.IGNORECASE or 0) | \
-                        self.multilineCheckBox.isChecked() and re.MULTILINE or 0 | \
-                        self.dotallCheckBox.isChecked() and re.DOTALL or 0 | \
-                        self.verboseCheckBox.isChecked() and re.VERBOSE or 0 | \
-                        self.localeCheckBox.isChecked() and re.LOCALE or 0 | \
-                        self.unicodeCheckBox.isChecked() and re.UNICODE or 0)
+                    if self.localeCheckBox.isChecked():
+                        flags |= re.LOCALE
+                    if self.unicodeCheckBox.isChecked():
+                        flags |= re.UNICODE
                 else:
-                    regobj = re.compile(regex,
-                        (not self.caseSensitiveCheckBox.isChecked() and re.IGNORECASE or 0) | \
-                        self.multilineCheckBox.isChecked() and re.MULTILINE or 0 | \
-                        self.dotallCheckBox.isChecked() and re.DOTALL or 0 | \
-                        self.verboseCheckBox.isChecked() and re.VERBOSE or 0 | \
-                        (not self.unicodeCheckBox.isChecked() and re.UNICODE or 0))
+                    if self.unicodeCheckBox.isChecked():
+                        flags |= re.ASCII
+                regobj = re.compile(regex, flags)
                 matchobj = regobj.search(text, startpos)
                 if matchobj is not None:
                     captures = len(matchobj.groups())

eric ide

mercurial