Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py

branch
5_3_x
changeset 2775
a1a4715a4eb0
parent 2773
a6d129e83b21
child 2825
323d417d256b
equal deleted inserted replaced
2773:a6d129e83b21 2775:a1a4715a4eb0
376 Private slot to validate the entered regexp. 376 Private slot to validate the entered regexp.
377 """ 377 """
378 regex = self.regexpTextEdit.toPlainText() 378 regex = self.regexpTextEdit.toPlainText()
379 if regex: 379 if regex:
380 try: 380 try:
381 flags = 0
382 if not self.caseSensitiveCheckBox.isChecked():
383 flags |= re.IGNORECASE
384 if self.multilineCheckBox.isChecked():
385 flags |= re.MULTILINE
386 if self.dotallCheckBox.isChecked():
387 flags |= re.DOTALL
388 if self.verboseCheckBox.isChecked():
389 flags |= re.VERBOSE
381 if self.py2Button.isChecked(): 390 if self.py2Button.isChecked():
382 re.compile(regex, 391 if self.localeCheckBox.isChecked():
383 (not self.caseSensitiveCheckBox.isChecked() and re.IGNORECASE or 0) | \ 392 flags |= re.LOCALE
384 self.multilineCheckBox.isChecked() and re.MULTILINE or 0 | \ 393 if self.unicodeCheckBox.isChecked():
385 self.dotallCheckBox.isChecked() and re.DOTALL or 0 | \ 394 flags |= re.UNICODE
386 self.verboseCheckBox.isChecked() and re.VERBOSE or 0 | \
387 self.localeCheckBox.isChecked() and re.LOCALE or 0 | \
388 self.unicodeCheckBox.isChecked() and re.UNICODE or 0)
389 else: 395 else:
390 re.compile(regex, 396 if self.unicodeCheckBox.isChecked():
391 (not self.caseSensitiveCheckBox.isChecked() and re.IGNORECASE or 0) | \ 397 flags |= re.ASCII
392 self.multilineCheckBox.isChecked() and re.MULTILINE or 0 | \ 398 re.compile(regex, flags)
393 self.dotallCheckBox.isChecked() and re.DOTALL or 0 | \
394 self.verboseCheckBox.isChecked() and re.VERBOSE or 0 | \
395 (not self.unicodeCheckBox.isChecked() and re.UNICODE or 0))
396 E5MessageBox.information(self, 399 E5MessageBox.information(self,
397 self.trUtf8("Validation"), 400 self.trUtf8("Validation"),
398 self.trUtf8("""The regular expression is valid.""")) 401 self.trUtf8("""The regular expression is valid."""))
399 except re.error as e: 402 except re.error as e:
400 E5MessageBox.critical(self, 403 E5MessageBox.critical(self,
439 if self.localeCheckBox.isChecked(): 442 if self.localeCheckBox.isChecked():
440 flags |= re.LOCALE 443 flags |= re.LOCALE
441 if self.unicodeCheckBox.isChecked(): 444 if self.unicodeCheckBox.isChecked():
442 flags |= re.UNICODE 445 flags |= re.UNICODE
443 else: 446 else:
444 if not self.unicodeCheckBox.isChecked(): 447 if self.unicodeCheckBox.isChecked():
445 flags |= re.UNICODE 448 flags |= re.ASCII
446 regobj = re.compile(regex, flags) 449 regobj = re.compile(regex, flags)
447 matchobj = regobj.search(text, startpos) 450 matchobj = regobj.search(text, startpos)
448 if matchobj is not None: 451 if matchobj is not None:
449 captures = len(matchobj.groups()) 452 captures = len(matchobj.groups())
450 if captures is None: 453 if captures is None:

eric ide

mercurial