From 7823025b8d35a5310617ade996e1fb7cd60a9f50 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Fri, 23 Feb 2018 10:39:08 +0200 Subject: [PATCH] [python console] remove 'u' prefixes from strings (fix #18171) --- python/console/console.py | 2 -- python/console/console_compile_apis.py | 4 ++-- python/console/console_editor.py | 8 ++++---- python/console/console_output.py | 2 -- python/console/console_sci.py | 6 ++---- python/console/console_settings.py | 6 +++--- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/python/console/console.py b/python/console/console.py index a1f3ce803e7..a4317db4f27 100644 --- a/python/console/console.py +++ b/python/console/console.py @@ -18,8 +18,6 @@ email : lrssvtml (at) gmail (dot) com ***************************************************************************/ Some portions of code were taken from https://code.google.com/p/pydee/ """ -from builtins import str -from builtins import range import os from qgis.PyQt.QtCore import Qt, QTimer, QCoreApplication, QSize, QByteArray, QFileInfo, QUrl, QDir diff --git a/python/console/console_compile_apis.py b/python/console/console_compile_apis.py index cbeedba7c07..a041166c0d1 100644 --- a/python/console/console_compile_apis.py +++ b/python/console/console_compile_apis.py @@ -64,7 +64,7 @@ class PrepareAPIDialog(QDialog): rslt = self.tr("Error") if prepd: rslt = QCoreApplication.translate("PythonConsole", "Saved") - self.ui.label.setText(u'{0} {1}'.format(self.ui.label.text(), rslt)) + self.ui.label.setText('{0} {1}'.format(self.ui.label.text(), rslt)) self._api = None self.ui.progressBar.setVisible(False) self.ui.buttonBox.button(QDialogButtonBox.Cancel).setText( @@ -73,7 +73,7 @@ class PrepareAPIDialog(QDialog): def prepareAPI(self): # self.ui.textEdit_Qsci.setLexer(0) - exec(u'self.qlexer = {0}(self.ui.textEdit_Qsci)'.format(self._api_lexer)) + exec('self.qlexer = {0}(self.ui.textEdit_Qsci)'.format(self._api_lexer)) # self.ui.textEdit_Qsci.setLexer(self.qlexer) self._api = QsciAPIs(self.qlexer) self._api.apiPreparationFinished.connect(self._preparationFinished) diff --git a/python/console/console_editor.py b/python/console/console_editor.py index 8736e4c751a..7dcc5867557 100644 --- a/python/console/console_editor.py +++ b/python/console/console_editor.py @@ -432,7 +432,7 @@ class Editor(QsciScintilla): getCmd = [] for strLine in listText: getCmd.append(strLine) - pasteText = u"\n".join(getCmd) + pasteText = "\n".join(getCmd) url = 'http://codepad.org' values = {'lang': 'Python', 'code': pasteText, @@ -591,7 +591,7 @@ class Editor(QsciScintilla): tmpFile = self.createTempFile() filename = tmpFile - self.parent.pc.shell.runCommand(u"exec(open(u'{0}'.encode('{1}')).read())" + self.parent.pc.shell.runCommand("exec(open('{0}'.encode('{1}')).read())" .format(filename.replace("\\", "/"), sys.getfilesystemencoding())) def runSelectedCode(self): # spellok @@ -626,9 +626,9 @@ class Editor(QsciScintilla): if not filename: filename = self.parent.tw.currentWidget().path # source = open(filename, 'r').read() + '\n' - if isinstance(source, type(u"")): + if isinstance(source, type("")): source = source.encode('utf-8') - if isinstance(filename, type(u"")): + if isinstance(filename, type("")): filename = filename.encode('utf-8') if filename: compile(source, filename, 'exec') diff --git a/python/console/console_output.py b/python/console/console_output.py index ba96ee538f9..c34afe0b1c8 100644 --- a/python/console/console_output.py +++ b/python/console/console_output.py @@ -18,8 +18,6 @@ email : lrssvtml (at) gmail (dot) com ***************************************************************************/ Some portions of code were taken from https://code.google.com/p/pydee/ """ -from builtins import range -from builtins import object from qgis.PyQt.QtCore import Qt, QCoreApplication from qgis.PyQt.QtGui import QColor, QFont, QKeySequence, QFontDatabase diff --git a/python/console/console_sci.py b/python/console/console_sci.py index 68ddbda5dbd..d0c4d87ac51 100644 --- a/python/console/console_sci.py +++ b/python/console/console_sci.py @@ -18,8 +18,6 @@ email : lrssvtml (at) gmail (dot) com ***************************************************************************/ Some portions of code were taken from https://code.google.com/p/pydee/ """ -from builtins import bytes -from builtins import range from qgis.PyQt.QtCore import Qt, QByteArray, QCoreApplication, QFile, QSize from qgis.PyQt.QtWidgets import QDialog, QMenu, QShortcut, QApplication @@ -600,7 +598,7 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): more = False else: self.buffer.append(cmd) - src = u"\n".join(self.buffer) + src = "\n".join(self.buffer) more = self.runsource(src) if not more: self.buffer = [] @@ -627,7 +625,7 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): hook = sys.excepthook try: def excepthook(etype, value, tb): - self.write(u"".join(traceback.format_exception(etype, value, tb))) + self.write("".join(traceback.format_exception(etype, value, tb))) sys.excepthook = excepthook diff --git a/python/console/console_settings.py b/python/console/console_settings.py index ee22e437722..fc65d1e63de 100644 --- a/python/console/console_settings.py +++ b/python/console/console_settings.py @@ -18,16 +18,16 @@ email : lrssvtml (at) gmail (dot) com ***************************************************************************/ Some portions of code were taken from https://code.google.com/p/pydee/ """ -from builtins import range from qgis.PyQt.QtCore import QCoreApplication, QSize, Qt from qgis.PyQt.QtWidgets import QDialog, QFileDialog, QMessageBox, QTableWidgetItem from qgis.PyQt.QtGui import QIcon, QFont, QColor, QFontDatabase -from .console_compile_apis import PrepareAPIDialog -from .ui_console_settings import Ui_SettingsDialogPythonConsole from qgis.core import QgsSettings +from .console_compile_apis import PrepareAPIDialog +from .ui_console_settings import Ui_SettingsDialogPythonConsole + class optionsDialog(QDialog, Ui_SettingsDialogPythonConsole):