Skip to content
Permalink
Browse files

[python console] remove 'u' prefixes from strings (fix #18171)

  • Loading branch information
alexbruy committed Feb 23, 2018
1 parent a554409 commit 7823025b8d35a5310617ade996e1fb7cd60a9f50
@@ -18,8 +18,6 @@
***************************************************************************/
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
@@ -64,7 +64,7 @@ def _preparationFinished(self):
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 @@ def _preparationFinished(self):

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)
@@ -432,7 +432,7 @@ def codepad(self):
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 @@ def runScriptCode(self):
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 @@ def syntaxCheck(self, filename=None, fromContextMenu=True):
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')
@@ -18,8 +18,6 @@
***************************************************************************/
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
@@ -18,8 +18,6 @@
***************************************************************************/
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 @@ def runCommand(self, cmd):
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 @@ def runsource(self, source, filename='<input>', symbol='single'):
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

@@ -18,16 +18,16 @@
***************************************************************************/
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):

0 comments on commit 7823025

Please sign in to comment.
You can’t perform that action at this time.