--- a/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardCharactersDialog.py Thu Mar 09 19:28:59 2017 +0100 +++ b/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardCharactersDialog.py Fri Mar 10 17:32:19 2017 +0100 @@ -489,56 +489,57 @@ self.rangesEntries.append([cb1, le1, le2]) - def __populateW3cCharacterCombo(self, combo, format): + def __populateW3cCharacterCombo(self, combo, formatIdentifier): """ Private method to populate a W3C character selection combo. @param combo combo box to be populated (QComboBox) - @param format format identifier (one of "-ccp", "-ccn", "-cbp", "-cbn") + @param formatIdentifier format identifier (one of "-ccp", "-ccn", + "-cbp", "-cbn") """ combo.clear() - if format in ["-ccp", "-ccn"]: + if formatIdentifier in ["-ccp", "-ccn"]: comboLen = 0 for txt, code in self.__characterCategories: combo.addItem(txt, code) comboLen = max(comboLen, len(txt)) combo.setMinimumContentsLength(comboLen) - elif format in ["-cbp", "-cbn"]: + elif formatIdentifier in ["-cbp", "-cbn"]: comboLen = 0 for txt, code in self.__characterBlocks: combo.addItem(txt, code) comboLen = max(comboLen, len(txt)) combo.setMinimumContentsLength(comboLen) - def __performSelectedAction(self, format, lineedit, combo): + def __performSelectedAction(self, formatIdentifier, lineedit, combo): """ Private method performing some actions depending on the input. - @param format format of the selected entry (string) + @param formatIdentifier format of the selected entry (string) @param lineedit line edit widget to act on (QLineEdit) @param combo combo box widget to act on (QComboBox) """ - if format == "-i": + if formatIdentifier == "-i": return - if format in ["-c", "-h", "-o"]: + if formatIdentifier in ["-c", "-h", "-o"]: lineedit.show() lineedit.setEnabled(True) if combo is not None: combo.hide() - if format == "-c": + if formatIdentifier == "-c": lineedit.setValidator(self.charValidator) - elif format == "-h": + elif formatIdentifier == "-h": lineedit.setValidator(self.hexValidator) - elif format == "-o": + elif formatIdentifier == "-o": lineedit.setValidator(self.octValidator) - elif format in ["-ccp", "-ccn", "-cbp", "-cbn"]: + elif formatIdentifier in ["-ccp", "-ccn", "-cbp", "-cbn"]: lineedit.setEnabled(False) lineedit.hide() if combo is not None: combo.show() - self.__populateW3cCharacterCombo(combo, format) + self.__populateW3cCharacterCombo(combo, formatIdentifier) else: lineedit.setEnabled(False) lineedit.hide() @@ -556,9 +557,9 @@ combo = self.sender() for entriesList in self.singlesEntries: if combo == entriesList[0]: - format = combo.itemData(index) + formatIdentifier = combo.itemData(index) self.__performSelectedAction( - format, entriesList[1], entriesList[2]) + formatIdentifier, entriesList[1], entriesList[2]) break def __rangesCharTypeSelected(self, index): @@ -571,37 +572,39 @@ combo = self.sender() for entriesList in self.rangesEntries: if combo == entriesList[0]: - format = combo.itemData(index) - self.__performSelectedAction(format, entriesList[1], None) - self.__performSelectedAction(format, entriesList[2], None) + formatIdentifier = combo.itemData(index) + self.__performSelectedAction(formatIdentifier, entriesList[1], + None) + self.__performSelectedAction(formatIdentifier, entriesList[2], + None) break - def __formatCharacter(self, char, format): + def __formatCharacter(self, char, formatIdentifier): """ Private method to format the characters entered into the dialog. @param char character string entered into the dialog (string) - @param format string giving a special format (-c, -h, -i or -o) or - the already formatted character (string) + @param formatIdentifier string giving a special format (-c, -h, -i or + -o) or the already formatted character (string) @return formatted character string (string) """ - if format == "-c": + if formatIdentifier == "-c": return char - elif format == "-i": + elif formatIdentifier == "-i": return "" if self.__mode in [QRegExpWizardCharactersDialog.RegExpMode, QRegExpWizardCharactersDialog.W3CMode]: - if format == "-h": + if formatIdentifier == "-h": return "\\x{0}".format(char.lower()) - elif format == "-o": + elif formatIdentifier == "-o": return "\\0{0}".format(char) - elif format in ["-ccp", "-cbp"]: + elif formatIdentifier in ["-ccp", "-cbp"]: return "\\p{{{0}}}".format(char) - elif format in ["-ccn", "-cbn"]: + elif formatIdentifier in ["-ccn", "-cbn"]: return "\\P{{{0}}}".format(char) else: - return format + return formatIdentifier def getCharacters(self): """ @@ -639,24 +642,26 @@ # single characters for entrieslist in self.singlesEntries: - format = entrieslist[0].itemData(entrieslist[0].currentIndex()) - if format in ["-ccp", "-ccn", "-cbp", "-cbn"]: + formatIdentifier = entrieslist[0].itemData( + entrieslist[0].currentIndex()) + if formatIdentifier in ["-ccp", "-ccn", "-cbp", "-cbn"]: char = entrieslist[2].itemData(entrieslist[2].currentIndex()) else: char = entrieslist[1].text() - regexp += self.__formatCharacter(char, format) + regexp += self.__formatCharacter(char, formatIdentifier) # character ranges for entrieslist in self.rangesEntries: if not entrieslist[1].text() or \ not entrieslist[2].text(): continue - format = entrieslist[0].itemData(entrieslist[0].currentIndex()) + formatIdentifier = entrieslist[0].itemData( + entrieslist[0].currentIndex()) char1 = entrieslist[1].text() char2 = entrieslist[2].text() regexp += "{0}-{1}".format( - self.__formatCharacter(char1, format), - self.__formatCharacter(char2, format)) + self.__formatCharacter(char1, formatIdentifier), + self.__formatCharacter(char2, formatIdentifier)) if regexp: if (regexp.startswith("\\") and