eric6/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardCharactersDialog.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 from .Ui_PyRegExpWizardCharactersDialog import \ 17
18 from .Ui_PyRegExpWizardCharactersDialog import (
18 Ui_PyRegExpWizardCharactersDialog 19 Ui_PyRegExpWizardCharactersDialog
20 )
19 21
20 22
21 class PyRegExpWizardCharactersDialog( 23 class PyRegExpWizardCharactersDialog(
22 QDialog, Ui_PyRegExpWizardCharactersDialog): 24 QDialog, Ui_PyRegExpWizardCharactersDialog):
23 """ 25 """
304 char = entrieslist[1].text() 306 char = entrieslist[1].text()
305 regexp += self.__formatCharacter(index, char) 307 regexp += self.__formatCharacter(index, char)
306 308
307 # character ranges 309 # character ranges
308 for entrieslist in self.rangesEntries: 310 for entrieslist in self.rangesEntries:
309 if entrieslist[1].text() == "" or \ 311 if (
310 entrieslist[2].text() == "": 312 entrieslist[1].text() == "" or
313 entrieslist[2].text() == ""
314 ):
311 continue 315 continue
312 index = entrieslist[0].currentIndex() 316 index = entrieslist[0].currentIndex()
313 char1 = entrieslist[1].text() 317 char1 = entrieslist[1].text()
314 char2 = entrieslist[2].text() 318 char2 = entrieslist[2].text()
315 regexp += "{0}-{1}".format( 319 regexp += "{0}-{1}".format(
316 self.__formatCharacter(index, char1), 320 self.__formatCharacter(index, char1),
317 self.__formatCharacter(index, char2)) 321 self.__formatCharacter(index, char2))
318 322
319 if regexp: 323 if regexp:
320 if (len(regexp) == 2 and 324 if (
321 (regexp in self.predefinedClasses or 325 (len(regexp) == 2 and
322 regexp in self.specialChars)) or \ 326 (regexp in self.predefinedClasses or
323 len(regexp) == 1: 327 regexp in self.specialChars)) or
328 len(regexp) == 1
329 ):
324 return regexp 330 return regexp
325 else: 331 else:
326 return "[{0}]".format(regexp) 332 return "[{0}]".format(regexp)
327 else: 333 else:
328 return "" 334 return ""

eric ide

mercurial