Skip to content

Commit

Permalink
Use positional for str.format(). Fix #8277
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jul 12, 2013
1 parent 9a48e65 commit 272400e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions python/console/console.py
Expand Up @@ -641,7 +641,7 @@ def saveScriptFile(self):
except (IOError, OSError), error:
errTr = QCoreApplication.translate("PythonConsole", "Save Error")
msgText = QCoreApplication.translate('PythonConsole',
'The file <b>{}</b> could not be saved. Error: {}'.format(unicode(tabWidget.path),
'The file <b>{0}</b> could not be saved. Error: {1}'.format(unicode(tabWidget.path),
error.strerror))
self.callWidgetMessageBarEditor(msgText, 2, False)

Expand All @@ -668,7 +668,7 @@ def saveAsScriptFile(self, index=-1):
except (IOError, OSError), error:
errTr = QCoreApplication.translate("PythonConsole", "Save Error")
msgText = QCoreApplication.translate('PythonConsole',
'The file <b>{}</b> could not be saved. Error: {}'.format(unicode(tabWidget.path),
'The file <b>{0}</b> could not be saved. Error: {1}'.format(unicode(tabWidget.path),
error.strerror))
self.callWidgetMessageBarEditor(msgText, 2, False)
if fileNone:
Expand Down
24 changes: 12 additions & 12 deletions python/console/console_editor.py
Expand Up @@ -400,7 +400,7 @@ def findText(self, forward):
styleError = 'QLineEdit {background-color: #d65253; \
color: #ffffff;}'
msgText = QCoreApplication.translate('PythonConsole',
'<b>"{}"</b> was not found.'.format(text))
'<b>"{0}"</b> was not found.'.format(text))
self.parent.pc.callWidgetMessageBarEditor(msgText, 0, True)
else:
styleError = ''
Expand Down Expand Up @@ -522,17 +522,17 @@ def _runSubProcess(self, filename, tmp=False):
else:
raise e
if tmp:
tmpFileTr = QCoreApplication.translate('PythonConsole', ' [Temporary file saved in {}]'.format(dir))
tmpFileTr = QCoreApplication.translate('PythonConsole', ' [Temporary file saved in {0}]'.format(dir))
file = file + tmpFileTr
if _traceback:
msgTraceTr = QCoreApplication.translate('PythonConsole', '## Script error: {}'.format(file))
msgTraceTr = QCoreApplication.translate('PythonConsole', '## Script error: {0}'.format(file))
print "## %s" % datetime.datetime.now()
print unicode(msgTraceTr)
sys.stderr.write(_traceback)
p.stderr.close()
else:
msgSuccessTr = QCoreApplication.translate('PythonConsole',
'## Script executed successfully: {}'.format(file))
'## Script executed successfully: {0}'.format(file))
print "## %s" % datetime.datetime.now()
print unicode(msgSuccessTr)
sys.stdout.write(out)
Expand All @@ -542,7 +542,7 @@ def _runSubProcess(self, filename, tmp=False):
os.remove(filename)
except IOError, error:
IOErrorTr = QCoreApplication.translate('PythonConsole',
'Cannot execute file {}. Error: {}\n'.format(unicode(filename), error.strerror))
'Cannot execute file {0}. Error: {1}\n'.format(unicode(filename), error.strerror))
print '## Error: ' + IOErrorTr
except:
s = traceback.format_exc()
Expand Down Expand Up @@ -675,7 +675,7 @@ def focusInEvent(self, e):
if pathfile:
if not QFileInfo(pathfile).exists():
msgText = QCoreApplication.translate('PythonConsole',
'The file <b>"{}"</b> has been deleted or is not accessible'.format(unicode(pathfile)))
'The file <b>"{0}"</b> has been deleted or is not accessible'.format(unicode(pathfile)))
self.parent.pc.callWidgetMessageBarEditor(msgText, 2, False)
return
if pathfile and self.lastModified != QFileInfo(pathfile).lastModified():
Expand All @@ -696,14 +696,14 @@ def focusInEvent(self, e):
self.parent.tw.listObject(self.parent.tw.currentWidget())
self.lastModified = QFileInfo(pathfile).lastModified()
msgText = QCoreApplication.translate('PythonConsole',
'The file <b>"{}"</b> has been changed and reloaded'.format(unicode(pathfile)))
'The file <b>"{0}"</b> has been changed and reloaded'.format(unicode(pathfile)))
self.parent.pc.callWidgetMessageBarEditor(msgText, 1, False)
QsciScintilla.focusInEvent(self, e)

def fileReadOnly(self):
tabWidget = self.parent.tw.currentWidget()
msgText = QCoreApplication.translate('PythonConsole',
'The file <b>"{}"</b> is read only, please save to different file first.'.format(unicode(tabWidget.path)))
'The file <b>"{0}"</b> is read only, please save to different file first.'.format(unicode(tabWidget.path)))
self.parent.pc.callWidgetMessageBarEditor(msgText, 1, False)

class EditorTab(QWidget):
Expand Down Expand Up @@ -997,14 +997,14 @@ def newTabEditor(self, tabName=None, filename=None):
fn.close()
except IOError, error:
IOErrorTr = QCoreApplication.translate('PythonConsole',
'The file {} could not be opened. Error: {}\n'.format(unicode(filename), error.strerror))
'The file {0} could not be opened. Error: {1}\n'.format(unicode(filename), error.strerror))
print '## Error: '
sys.stderr.write(IOErrorTr)
return

nr = self.count()
if not tabName:
tabName = QCoreApplication.translate('PythonConsole', 'Untitled-{}'.format(nr))
tabName = QCoreApplication.translate('PythonConsole', 'Untitled-{0}'.format(nr))
self.tab = EditorTab(self, self.parent, filename, readOnly)
self.iconTab = QgsApplication.getThemeIcon('console/iconTabEditorConsole.png')
self.addTab(self.tab, self.iconTab, tabName + ' (ro)' if readOnly else tabName)
Expand Down Expand Up @@ -1039,7 +1039,7 @@ def _removeTab(self, tab, tab2index=False):
txtSaveOnRemove = QCoreApplication.translate("PythonConsole",
"Python Console: Save File")
txtMsgSaveOnRemove = QCoreApplication.translate("PythonConsole",
"The file <b>'{}'</b> has been modified, save changes?".format(self.tabText(tab)))
"The file <b>'{0}'</b> has been modified, save changes?".format(self.tabText(tab)))
res = QMessageBox.question( self, txtSaveOnRemove,
txtMsgSaveOnRemove,
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel )
Expand Down Expand Up @@ -1083,7 +1083,7 @@ def restoreTabs(self):
self.newTabEditor(tabName, pathFile)
else:
errOnRestore = QCoreApplication.translate("PythonConsole",
"Unable to restore the file: \n{}\n".format(unicode(pathFile)))
"Unable to restore the file: \n{0}\n".format(unicode(pathFile)))
print '## Error: '
s = errOnRestore
sys.stderr.write(s)
Expand Down

0 comments on commit 272400e

Please sign in to comment.