--- a/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardCharactersDialog.py Thu Mar 09 19:28:59 2017 +0100 +++ b/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardCharactersDialog.py Fri Mar 10 17:32:19 2017 +0100 @@ -403,23 +403,23 @@ self.rangesEntries.append([cb1, le1, le2]) - def __populateCharacterCombo(self, combo, format): + def __populateCharacterCombo(self, combo, formatIdentifier): """ Private method to populate a character selection combo. @param combo combo box to be populated (QComboBox) - @param format format identifier (one of "-ccp", "-ccn", + @param formatIdentifier format identifier (one of "-ccp", "-ccn", "-cbp", "-cbn", "-csp", "-csn", "-psp", "-psn") """ combo.clear() - if format in ["-ccp", "-ccn"]: + if formatIdentifier in ["-ccp", "-ccn"]: items = self.__characterCategories - elif format in ["-csp", "-csn"]: + elif formatIdentifier in ["-csp", "-csn"]: items = self.__specialCharacterCategories - elif format in ["-cbp", "-cbn"]: + elif formatIdentifier in ["-cbp", "-cbn"]: items = self.__characterBlocks - elif format in ["-psp", "-psn"]: + elif formatIdentifier in ["-psp", "-psn"]: items = self.__posixNamedSets comboLen = 0 @@ -428,35 +428,35 @@ 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", "-csp", "-csn", - "-psp", "-psn"]: + elif formatIdentifier in ["-ccp", "-ccn", "-cbp", "-cbn", "-csp", + "-csn", "-psp", "-psn"]: lineedit.setEnabled(False) lineedit.hide() if combo is not None: combo.show() - self.__populateCharacterCombo(combo, format) + self.__populateCharacterCombo(combo, formatIdentifier) else: lineedit.setEnabled(False) lineedit.hide() @@ -474,9 +474,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): @@ -489,48 +489,50 @@ 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 format == "-h": + if formatIdentifier == "-h": while len(char) < 2: char = "0" + char if len(char) > 2: return "\\x{{{0}}}".format(char.lower()) else: return "\\x{0}".format(char.lower()) - elif format == "-o": + elif formatIdentifier == "-o": while len(char) < 3: char = "0" + char if len(char) > 3: char = char[:3] return "\\{0}".format(char) - elif format in ["-ccp", "-cbp", "-csp"]: + elif formatIdentifier in ["-ccp", "-cbp", "-csp"]: return "\\p{{{0}}}".format(char) - elif format in ["-ccn", "-cbn", "-csn"]: + elif formatIdentifier in ["-ccn", "-cbn", "-csn"]: return "\\P{{{0}}}".format(char) - elif format == "-psp": + elif formatIdentifier == "-psp": return "[:{0}:]".format(char) - elif format == "-psn": + elif formatIdentifier == "-psn": return "[:^{0}:]".format(char) else: - return format + return formatIdentifier def getCharacters(self): """ @@ -572,25 +574,27 @@ # single characters for entrieslist in self.singlesEntries: - format = entrieslist[0].itemData(entrieslist[0].currentIndex()) - if format in ["-ccp", "-ccn", "-cbp", "-cbn", "-csp", "-csn", - "-psp", "-psn"]: + formatIdentifier = entrieslist[0].itemData( + entrieslist[0].currentIndex()) + if formatIdentifier in ["-ccp", "-ccn", "-cbp", "-cbn", "-csp", + "-csn", "-psp", "-psn"]: 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