eric6/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardCharactersDialog.py

changeset 7258
aff39db4dacc
parent 7229
53054eb5b15a
child 7360
9190402e4505
equal deleted inserted replaced
7257:c4d0cac9b5c9 7258:aff39db4dacc
8 """ 8 """
9 9
10 10
11 from PyQt5.QtCore import QRegExp 11 from PyQt5.QtCore import QRegExp
12 from PyQt5.QtGui import QRegExpValidator 12 from PyQt5.QtGui import QRegExpValidator
13 from PyQt5.QtWidgets import QSizePolicy, QSpacerItem, QWidget, QHBoxLayout, \ 13 from PyQt5.QtWidgets import (
14 QLineEdit, QPushButton, QDialog, QScrollArea, QComboBox, QVBoxLayout, \ 14 QSizePolicy, QSpacerItem, QWidget, QHBoxLayout, QLineEdit, QPushButton,
15 QLabel 15 QDialog, QScrollArea, QComboBox, QVBoxLayout, QLabel
16 )
16 17
17 from .Ui_QRegExpWizardCharactersDialog import Ui_QRegExpWizardCharactersDialog 18 from .Ui_QRegExpWizardCharactersDialog import Ui_QRegExpWizardCharactersDialog
18 19
19 20
20 class QRegExpWizardCharactersDialog(QDialog, Ui_QRegExpWizardCharactersDialog): 21 class QRegExpWizardCharactersDialog(QDialog, Ui_QRegExpWizardCharactersDialog):
659 char = entrieslist[1].text() 660 char = entrieslist[1].text()
660 regexp += self.__formatCharacter(char, formatIdentifier) 661 regexp += self.__formatCharacter(char, formatIdentifier)
661 662
662 # character ranges 663 # character ranges
663 for entrieslist in self.rangesEntries: 664 for entrieslist in self.rangesEntries:
664 if not entrieslist[1].text() or \ 665 if (
665 not entrieslist[2].text(): 666 not entrieslist[1].text() or
667 not entrieslist[2].text()
668 ):
666 continue 669 continue
667 formatIdentifier = entrieslist[0].itemData( 670 formatIdentifier = entrieslist[0].itemData(
668 entrieslist[0].currentIndex()) 671 entrieslist[0].currentIndex())
669 char1 = entrieslist[1].text() 672 char1 = entrieslist[1].text()
670 char2 = entrieslist[2].text() 673 char2 = entrieslist[2].text()
671 regexp += "{0}-{1}".format( 674 regexp += "{0}-{1}".format(
672 self.__formatCharacter(char1, formatIdentifier), 675 self.__formatCharacter(char1, formatIdentifier),
673 self.__formatCharacter(char2, formatIdentifier)) 676 self.__formatCharacter(char2, formatIdentifier))
674 677
675 if regexp: 678 if regexp:
676 if (regexp.startswith("\\") and 679 if (
677 regexp.count("\\") == 1 and 680 (regexp.startswith("\\") and
678 "-" not in regexp) or \ 681 regexp.count("\\") == 1 and
679 len(regexp) == 1: 682 "-" not in regexp) or
683 len(regexp) == 1
684 ):
680 return regexp 685 return regexp
681 else: 686 else:
682 return "[{0}]".format(regexp) 687 return "[{0}]".format(regexp)
683 else: 688 else:
684 return "" 689 return ""

eric ide

mercurial