@@ -183,9 +183,9 @@ def __init__(self, parent=None):
183
183
def settingsEditor (self ):
184
184
# Set Python lexer
185
185
self .setLexers ()
186
- threshold = self .settings .value ("pythonConsole/autoCompThresholdEditor" , 2 ). toInt ()[ 0 ]
187
- radioButtonSource = self .settings .value ("pythonConsole/autoCompleteSourceEditor" , 'fromAPI' ). toString ()
188
- autoCompEnabled = self .settings .value ("pythonConsole/autoCompleteEnabledEditor" , True ). toBool ()
186
+ threshold = self .settings .value ("pythonConsole/autoCompThresholdEditor" , 2 )
187
+ radioButtonSource = self .settings .value ("pythonConsole/autoCompleteSourceEditor" , 'fromAPI' )
188
+ autoCompEnabled = self .settings .value ("pythonConsole/autoCompleteEnabledEditor" , True )
189
189
self .setAutoCompletionThreshold (threshold )
190
190
if autoCompEnabled :
191
191
if radioButtonSource == 'fromDoc' :
@@ -198,8 +198,8 @@ def settingsEditor(self):
198
198
self .setAutoCompletionSource (self .AcsNone )
199
199
200
200
def autoCompleteKeyBinding (self ):
201
- radioButtonSource = self .settings .value ("pythonConsole/autoCompleteSourceEditor" ). toString ()
202
- autoCompEnabled = self .settings .value ("pythonConsole/autoCompleteEnabledEditor" ). toBool ()
201
+ radioButtonSource = self .settings .value ("pythonConsole/autoCompleteSourceEditor" )
202
+ autoCompEnabled = self .settings .value ("pythonConsole/autoCompleteEnabledEditor" )
203
203
if autoCompEnabled :
204
204
if radioButtonSource == 'fromDoc' :
205
205
self .autoCompleteFromDocument ()
@@ -216,8 +216,8 @@ def setLexers(self):
216
216
self .lexer .setFoldComments (True )
217
217
self .lexer .setFoldQuotes (True )
218
218
219
- loadFont = self .settings .value ("pythonConsole/fontfamilytextEditor" , "Monospace" ). toString ()
220
- fontSize = self .settings .value ("pythonConsole/fontsizeEditor" , 10 ). toInt ()[ 0 ]
219
+ loadFont = self .settings .value ("pythonConsole/fontfamilytextEditor" , "Monospace" )
220
+ fontSize = self .settings .value ("pythonConsole/fontsizeEditor" , 10 )
221
221
222
222
font = QFont (loadFont )
223
223
font .setFixedPitch (True )
@@ -236,11 +236,11 @@ def setLexers(self):
236
236
self .lexer .setFont (font , 4 )
237
237
238
238
self .api = QsciAPIs (self .lexer )
239
- chekBoxAPI = self .settings .value ("pythonConsole/preloadAPI" , True ). toBool ()
239
+ chekBoxAPI = self .settings .value ("pythonConsole/preloadAPI" , True )
240
240
if chekBoxAPI :
241
241
self .api .loadPrepared ( QgsApplication .pkgDataPath () + "/python/qsci_apis/pyqgis_master.pap" )
242
242
else :
243
- apiPath = self .settings .value ("pythonConsole/userAPI" ). toStringList ()
243
+ apiPath = self .settings .value ("pythonConsole/userAPI" )
244
244
for i in range (0 , len (apiPath )):
245
245
self .api .load (QString (unicode (apiPath [i ])))
246
246
self .api .prepare ()
@@ -258,7 +258,7 @@ def move_cursor_to_end(self):
258
258
def get_end_pos (self ):
259
259
"""Return (line, index) position of the last character"""
260
260
line = self .lines () - 1
261
- return (line , self .text (line ). length ( ))
261
+ return (line , len ( self .text (line )))
262
262
263
263
def contextMenuEvent (self , e ):
264
264
menu = QMenu (self )
@@ -372,7 +372,7 @@ def contextMenuEvent(self, e):
372
372
if QApplication .clipboard ().text ():
373
373
pasteAction .setEnabled (True )
374
374
if self .settings .value ("pythonConsole/enableObjectInsp" ,
375
- False ). toBool () :
375
+ False ):
376
376
showCodeInspection .setEnabled (True )
377
377
action = menu .exec_ (self .mapToGlobal (e .pos ()))
378
378
@@ -385,7 +385,7 @@ def findText(self, forward):
385
385
cs = self .parent .pc .caseSensitive .isChecked ()
386
386
wo = self .parent .pc .wholeWord .isChecked ()
387
387
notFound = False
388
- if not text . isEmpty () :
388
+ if not text :
389
389
if not forward :
390
390
line = lineFrom
391
391
index = indexFrom
@@ -397,7 +397,7 @@ def findText(self, forward):
397
397
styleError = 'QLineEdit {background-color: #d65253; \
398
398
color: #ffffff;}'
399
399
msgText = QCoreApplication .translate ('PythonConsole' ,
400
- '<b>"%1 "</b> was not found.' ). arg (text )
400
+ '<b>"{} "</b> was not found.' . format (text ) )
401
401
self .parent .pc .callWidgetMessageBarEditor (msgText , 0 , True )
402
402
else :
403
403
styleError = ''
@@ -519,17 +519,17 @@ def _runSubProcess(self, filename, tmp=False):
519
519
else :
520
520
raise e
521
521
if tmp :
522
- tmpFileTr = QCoreApplication .translate ('PythonConsole' , ' [Temporary file saved in %1]' ). arg (dir )
522
+ tmpFileTr = QCoreApplication .translate ('PythonConsole' , ' [Temporary file saved in {}]' . format (dir ) )
523
523
file = file + tmpFileTr
524
524
if _traceback :
525
- msgTraceTr = QCoreApplication .translate ('PythonConsole' , '## Script error: %1' ). arg (file )
525
+ msgTraceTr = QCoreApplication .translate ('PythonConsole' , '## Script error: {}' . format (file ) )
526
526
print "## %s" % datetime .datetime .now ()
527
527
print unicode (msgTraceTr )
528
528
sys .stderr .write (_traceback )
529
529
p .stderr .close ()
530
530
else :
531
531
msgSuccessTr = QCoreApplication .translate ('PythonConsole' ,
532
- '## Script executed successfully: %1' ). arg (file )
532
+ '## Script executed successfully: {}' . format (file ) )
533
533
print "## %s" % datetime .datetime .now ()
534
534
print unicode (msgSuccessTr )
535
535
sys .stdout .write (out )
@@ -539,16 +539,15 @@ def _runSubProcess(self, filename, tmp=False):
539
539
os .remove (filename )
540
540
except IOError , error :
541
541
IOErrorTr = QCoreApplication .translate ('PythonConsole' ,
542
- 'Cannot execute file %1. Error: %2\n ' ) \
543
- .arg (unicode (filename )).arg (error .strerror )
542
+ 'Cannot execute file {}. Error: {}\n ' .format (unicode (filename ), error .strerror ))
544
543
print '## Error: ' + IOErrorTr
545
544
except :
546
545
s = traceback .format_exc ()
547
546
print '## Error: '
548
547
sys .stderr .write (s )
549
548
550
549
def runScriptCode (self ):
551
- autoSave = self .settings .value ("pythonConsole/autoSaveScript" ). toBool ()
550
+ autoSave = self .settings .value ("pythonConsole/autoSaveScript" )
552
551
553
552
tabWidget = self .parent .tw .currentWidget ()
554
553
@@ -630,7 +629,7 @@ def syntaxCheck(self, filename=None, fromContextMenu=True):
630
629
self .bufferMarkerLine .append (eline )
631
630
self .markerAdd (eline , self .MARKER_NUM )
632
631
loadFont = self .settings .value ("pythonConsole/fontfamilytextEditor" ,
633
- "Monospace" ). toString ()
632
+ "Monospace" )
634
633
styleAnn = QsciStyle (- 1 ,"Annotation" ,
635
634
QColor (255 ,0 ,0 ),
636
635
QColor (255 ,200 ,0 ),
@@ -651,7 +650,7 @@ def syntaxCheck(self, filename=None, fromContextMenu=True):
651
650
return True
652
651
653
652
def keyPressEvent (self , e ):
654
- if self .settings .value ("pythonConsole/autoCloseBracketEditor" , True ). toBool () :
653
+ if self .settings .value ("pythonConsole/autoCloseBracketEditor" , True ):
655
654
t = unicode (e .text ())
656
655
## Close bracket automatically
657
656
if t in self .opening :
@@ -664,8 +663,7 @@ def focusInEvent(self, e):
664
663
if pathfile :
665
664
if not QFileInfo (pathfile ).exists ():
666
665
msgText = QCoreApplication .translate ('PythonConsole' ,
667
- 'The file <b>"%1"</b> has been deleted or is not accessible' ) \
668
- .arg (unicode (pathfile ))
666
+ 'The file <b>"{}"</b> has been deleted or is not accessible' .format (unicode (pathfile )))
669
667
self .parent .pc .callWidgetMessageBarEditor (msgText , 2 , False )
670
668
return
671
669
if pathfile and self .lastModified != QFileInfo (pathfile ).lastModified ():
@@ -686,16 +684,14 @@ def focusInEvent(self, e):
686
684
self .parent .tw .listObject (self .parent .tw .currentWidget ())
687
685
self .lastModified = QFileInfo (pathfile ).lastModified ()
688
686
msgText = QCoreApplication .translate ('PythonConsole' ,
689
- 'The file <b>"%1"</b> has been changed and reloaded' ) \
690
- .arg (unicode (pathfile ))
687
+ 'The file <b>"{}"</b> has been changed and reloaded' .format (unicode (pathfile )))
691
688
self .parent .pc .callWidgetMessageBarEditor (msgText , 1 , False )
692
689
QsciScintilla .focusInEvent (self , e )
693
690
694
691
def fileReadOnly (self ):
695
692
tabWidget = self .parent .tw .currentWidget ()
696
693
msgText = QCoreApplication .translate ('PythonConsole' ,
697
- 'The file <b>"%1"</b> is read only, please save to different file first.' ) \
698
- .arg (unicode (tabWidget .path ))
694
+ 'The file <b>"{}"</b> is read only, please save to different file first.' .format (unicode (tabWidget .path )))
699
695
self .parent .pc .callWidgetMessageBarEditor (msgText , 1 , False )
700
696
701
697
class EditorTab (QWidget ):
@@ -865,7 +861,7 @@ def __init__(self, parent):
865
861
# Restore script of the previuos session
866
862
self .settings = QSettings ()
867
863
tabScripts = self .settings .value ("pythonConsole/tabScripts" )
868
- self .restoreTabList = tabScripts . toList ()
864
+ self .restoreTabList = tabScripts
869
865
870
866
if self .restoreTabList :
871
867
self .topFrame .show ()
@@ -912,7 +908,7 @@ def __init__(self, parent):
912
908
913
909
def _currentWidgetChanged (self , tab ):
914
910
if self .settings .value ("pythonConsole/enableObjectInsp" ,
915
- False ). toBool () :
911
+ False ):
916
912
self .listObject (tab )
917
913
self .changeLastDirPath (tab )
918
914
self .enableSaveIfModified (tab )
@@ -988,15 +984,14 @@ def newTabEditor(self, tabName=None, filename=None):
988
984
fn .close ()
989
985
except IOError , error :
990
986
IOErrorTr = QCoreApplication .translate ('PythonConsole' ,
991
- 'The file %1 could not be opened. Error: %2\n ' ) \
992
- .arg (unicode (filename )).arg (error .strerror )
987
+ 'The file {} could not be opened. Error: {}\n ' .format (unicode (filename ), error .strerror ))
993
988
print '## Error: '
994
989
sys .stderr .write (IOErrorTr )
995
990
return
996
991
997
992
nr = self .count ()
998
993
if not tabName :
999
- tabName = QCoreApplication .translate ('PythonConsole' , 'Untitled-%1' ). arg (nr )
994
+ tabName = QCoreApplication .translate ('PythonConsole' , 'Untitled-{}' . format (nr ) )
1000
995
self .tab = EditorTab (self , self .parent , filename , readOnly )
1001
996
self .iconTab = QgsApplication .getThemeIcon ('console/iconTabEditorConsole.png' )
1002
997
self .addTab (self .tab , self .iconTab , tabName + ' (ro)' if readOnly else tabName )
@@ -1031,8 +1026,7 @@ def _removeTab(self, tab, tab2index=False):
1031
1026
txtSaveOnRemove = QCoreApplication .translate ("PythonConsole" ,
1032
1027
"Python Console: Save File" )
1033
1028
txtMsgSaveOnRemove = QCoreApplication .translate ("PythonConsole" ,
1034
- "The file <b>'%1'</b> has been modified, save changes?" ) \
1035
- .arg (self .tabText (tab ))
1029
+ "The file <b>'{}'</b> has been modified, save changes?" .format (self .tabText (tab )))
1036
1030
res = QMessageBox .question ( self , txtSaveOnRemove ,
1037
1031
txtMsgSaveOnRemove ,
1038
1032
QMessageBox .Save | QMessageBox .Discard | QMessageBox .Cancel )
@@ -1070,14 +1064,13 @@ def closeCurrentWidget(self):
1070
1064
1071
1065
def restoreTabs (self ):
1072
1066
for script in self .restoreTabList :
1073
- pathFile = unicode (script . toString () )
1067
+ pathFile = unicode (script )
1074
1068
if QFileInfo (pathFile ).exists ():
1075
1069
tabName = pathFile .split ('/' )[- 1 ]
1076
1070
self .newTabEditor (tabName , pathFile )
1077
1071
else :
1078
1072
errOnRestore = QCoreApplication .translate ("PythonConsole" ,
1079
- "Unable to restore the file: \n %1\n " ) \
1080
- .arg (unicode (pathFile ))
1073
+ "Unable to restore the file: \n {}\n " .format (unicode (pathFile )))
1081
1074
print '## Error: '
1082
1075
s = errOnRestore
1083
1076
sys .stderr .write (s )
@@ -1193,7 +1186,7 @@ def refreshSettingsEditor(self):
1193
1186
self .widget (i ).newEditor .settingsEditor ()
1194
1187
1195
1188
objInspectorEnabled = self .settings .value ("pythonConsole/enableObjectInsp" ,
1196
- False ). toBool ()
1189
+ False )
1197
1190
listObj = self .parent .objectListButton
1198
1191
if self .parent .listClassMethod .isVisible ():
1199
1192
listObj .setChecked (objInspectorEnabled )
0 commit comments