eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py

branch
without_py2_and_pyqt4
changeset 7192
a22eee00b052
parent 6942
2602857055c5
child 7229
53054eb5b15a
equal deleted inserted replaced
7191:960850ec284c 7192:a22eee00b052
407 flags |= re.MULTILINE 407 flags |= re.MULTILINE
408 if self.dotallCheckBox.isChecked(): 408 if self.dotallCheckBox.isChecked():
409 flags |= re.DOTALL 409 flags |= re.DOTALL
410 if self.verboseCheckBox.isChecked(): 410 if self.verboseCheckBox.isChecked():
411 flags |= re.VERBOSE 411 flags |= re.VERBOSE
412 if self.py2Button.isChecked(): 412 if self.unicodeCheckBox.isChecked():
413 if self.localeCheckBox.isChecked(): 413 flags |= re.ASCII
414 flags |= re.LOCALE
415 if self.unicodeCheckBox.isChecked():
416 flags |= re.UNICODE
417 else:
418 if self.unicodeCheckBox.isChecked():
419 flags |= re.ASCII
420 re.compile(regex, flags) 414 re.compile(regex, flags)
421 E5MessageBox.information( 415 E5MessageBox.information(
422 self, 416 self,
423 self.tr("Validation"), 417 self.tr("Validation"),
424 self.tr("""The regular expression is valid.""")) 418 self.tr("""The regular expression is valid."""))
463 flags |= re.MULTILINE 457 flags |= re.MULTILINE
464 if self.dotallCheckBox.isChecked(): 458 if self.dotallCheckBox.isChecked():
465 flags |= re.DOTALL 459 flags |= re.DOTALL
466 if self.verboseCheckBox.isChecked(): 460 if self.verboseCheckBox.isChecked():
467 flags |= re.VERBOSE 461 flags |= re.VERBOSE
468 if self.py2Button.isChecked(): 462 if self.unicodeCheckBox.isChecked():
469 if self.localeCheckBox.isChecked(): 463 flags |= re.ASCII
470 flags |= re.LOCALE
471 if self.unicodeCheckBox.isChecked():
472 flags |= re.UNICODE
473 else:
474 if self.unicodeCheckBox.isChecked():
475 flags |= re.ASCII
476 regobj = re.compile(regex, flags) 464 regobj = re.compile(regex, flags)
477 matchobj = regobj.search(text, startpos) 465 matchobj = regobj.search(text, startpos)
478 if matchobj is not None: 466 if matchobj is not None:
479 captures = len(matchobj.groups()) 467 captures = len(matchobj.groups())
480 if captures is None: 468 if captures is None:
606 """ 594 """
607 Private slot called when the regexp changes. 595 Private slot called when the regexp changes.
608 """ 596 """
609 self.nextButton.setEnabled(False) 597 self.nextButton.setEnabled(False)
610 598
611 @pyqtSlot(bool)
612 def on_py2Button_toggled(self, checked):
613 """
614 Private slot called when the Python version was selected.
615
616 @param checked state of the Python 2 button (boolean)
617 """
618 # set the checkboxes
619 self.localeCheckBox.setEnabled(checked)
620 if checked:
621 self.unicodeCheckBox.setText(self.tr("Unicode"))
622 else:
623 self.unicodeCheckBox.setText(self.tr("ASCII"))
624 self.unicodeCheckBox.setChecked(not self.unicodeCheckBox.isChecked())
625
626 # clear the result table
627 self.resultTable.clear()
628 self.resultTable.setColumnCount(0)
629 self.resultTable.setRowCount(0)
630
631 # remove the highlight
632 tc = self.textTextEdit.textCursor()
633 tc.setPosition(0)
634 self.textTextEdit.setTextCursor(tc)
635
636 def getCode(self, indLevel, indString): 599 def getCode(self, indLevel, indString):
637 """ 600 """
638 Public method to get the source code. 601 Public method to get the source code.
639 602
640 @param indLevel indentation level (int) 603 @param indLevel indentation level (int)
660 flags.append('re.MULTILINE') 623 flags.append('re.MULTILINE')
661 if self.dotallCheckBox.isChecked(): 624 if self.dotallCheckBox.isChecked():
662 flags.append('re.DOTALL') 625 flags.append('re.DOTALL')
663 if self.verboseCheckBox.isChecked(): 626 if self.verboseCheckBox.isChecked():
664 flags.append('re.VERBOSE') 627 flags.append('re.VERBOSE')
665 if self.localeCheckBox.isChecked() and \
666 self.py2Button.isChecked():
667 flags.append('re.LOCALE')
668 if self.unicodeCheckBox.isChecked(): 628 if self.unicodeCheckBox.isChecked():
669 if self.py2Button.isChecked(): 629 flags.append('re.ASCII')
670 flags.append('re.UNICODE')
671 else:
672 flags.append('re.ASCII')
673 flags = " | ".join(flags) 630 flags = " | ".join(flags)
674 631
675 code = '' 632 code = ''
676 if self.importCheckBox.isChecked(): 633 if self.importCheckBox.isChecked():
677 code += 'import re{0}{1}'.format(os.linesep, istring) 634 code += 'import re{0}{1}'.format(os.linesep, istring)

eric ide

mercurial