--- a/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Fri Jan 01 16:11:36 2010 +0000 +++ b/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Sat Jan 02 15:11:35 2010 +0000 @@ -13,8 +13,8 @@ from PyQt4.QtGui import QPalette, QFileDialog, QColorDialog, QFontDialog, \ QInputDialog, QMessageBox -from ConfigurationPageBase import ConfigurationPageBase -from Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage +from .ConfigurationPageBase import ConfigurationPageBase +from .Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage from E4XML.XMLUtilities import make_parser from E4XML.XMLErrorHandler import XMLErrorHandler, XMLFatalParseError @@ -43,8 +43,7 @@ self.lexers = lexers # set initial values - languages = [''] + self.lexers.keys() - languages.sort() + languages = sorted([''] + list(self.lexers.keys())) self.lexerLanguageComboBox.addItems(languages) self.on_lexerLanguageComboBox_activated("") @@ -52,7 +51,7 @@ """ Public slot to save the Editor Highlighting Styles configuration. """ - for lexer in self.lexers.values(): + for lexer in list(self.lexers.values()): lexer.writeSettings(Preferences.Prefs.settings, "Scintilla") @pyqtSlot(str) @@ -155,7 +154,7 @@ pl.setColor(QPalette.Base, colour) self.sampleText.setPalette(pl) self.sampleText.repaint() - for style in self.lexer.ind2style.values(): + for style in list(self.lexer.ind2style.values()): self.lexer.setPaper(colour, style) @pyqtSlot() @@ -181,7 +180,7 @@ font, ok = QFontDialog.getFont(self.lexer.font(self.style)) if ok: self.sampleText.setFont(font) - for style in self.lexer.ind2style.values(): + for style in list(self.lexer.ind2style.values()): self.lexer.setFont(font, style) def on_eolfillCheckBox_toggled(self, b): @@ -208,7 +207,7 @@ if ok: enabled = selection == on self.eolfillCheckBox.setChecked(enabled) - for style in self.lexer.ind2style.values(): + for style in list(self.lexer.ind2style.values()): self.lexer.setEolFill(enabled, style) @pyqtSlot() @@ -229,7 +228,7 @@ """ Private method to set all styles to their default values. """ - for style in self.lexer.ind2style.values(): + for style in list(self.lexer.ind2style.values()): self.__setToDefault(style) self.on_styleElementList_currentRowChanged(self.styleElementList.currentRow()) @@ -270,7 +269,7 @@ """ Private slot to export the styles of all lexers. """ - self.__exportStyles(self.lexers.values()) + self.__exportStyles(list(self.lexers.values())) def __exportStyles(self, lexers): """ @@ -296,15 +295,15 @@ fn += ex try: - f = open(fn, "wb") + f = open(fn, "w") HighlightingStylesWriter(f, lexers).writeXML() f.close() - except IOError, err: + except IOError as err: QMessageBox.critical(self, self.trUtf8("Export Highlighting Styles"), self.trUtf8("""<p>The highlighting styles could not be exported""" """ to file <b>{0}</b>.</p><p>Reason: {1}</p>""")\ - .format(fn, unicode(err)) + .format(fn, str(err)) ) def __importStyles(self, lexers): @@ -323,18 +322,18 @@ return try: - f = open(fn, "rb") + f = open(fn, "r") try: line = f.readline() dtdLine = f.readline() finally: f.close() - except IOError, err: + except IOError as err: QMessageBox.critical(self, self.trUtf8("Import Highlighting Styles"), self.trUtf8("""<p>The highlighting styles could not be read""" """ from file <b>{0}</b>.</p><p>Reason: {1}</p>""")\ - .format(fn, unicode(err)) + .format(fn, str(err)) ) return @@ -349,7 +348,7 @@ parser.setErrorHandler(eh) try: - f = open(fn, "rb") + f = open(fn, "r") try: try: parser.parse(f) @@ -359,12 +358,12 @@ parser.parse(buf) finally: f.close() - except IOError, err: + except IOError as err: QMessageBox.critical(self, self.trUtf8("Import Highlighting Styles"), self.trUtf8("""<p>The highlighting styles could not be read""" """ from file <b>{0}</b>.</p><p>Reason: {1}</p>""")\ - .format(fn, unicode(err)) + .format(fn, str(err)) ) return except XMLFatalParseError: