Skip to content

Commit b39055b

Browse files
committedAug 22, 2015
indentation update (now including autopep8)
1 parent 93d45a0 commit b39055b

File tree

548 files changed

+18328
-17778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

548 files changed

+18328
-17778
lines changed
 

‎python/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ def mapping_feature(feature):
4141
properties = {}
4242
fields = [field.name() for field in feature.fields()]
4343
properties = dict(zip(fields, feature.attributes()))
44-
return {'type' : 'Feature',
45-
'properties' : properties,
46-
'geometry' : geom.__geo_interface__}
44+
return {'type': 'Feature',
45+
'properties': properties,
46+
'geometry': geom.__geo_interface__}
47+
4748

4849
def mapping_geometry(geometry):
4950
geo = geometry.exportToGeoJSON()

‎python/console/console.py

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,46 +38,51 @@
3838

3939
_console = None
4040

41+
4142
def show_console():
42-
""" called from QGIS to open the console """
43-
global _console
44-
if _console is None:
45-
parent = iface.mainWindow() if iface else None
46-
_console = PythonConsole( parent )
47-
_console.show() # force show even if it was restored as hidden
48-
# set focus to the console so the user can start typing
49-
# defer the set focus event so it works also whether the console not visible yet
50-
QTimer.singleShot(0, _console.activate)
51-
else:
52-
_console.setVisible(not _console.isVisible())
53-
# set focus to the console so the user can start typing
54-
if _console.isVisible():
55-
_console.activate()
56-
## Shows help on first launch of the console
57-
settings = QSettings()
58-
if settings.value('pythonConsole/contextHelpOnFirstLaunch', True, type=bool):
59-
QgsContextHelp.run( "PythonConsole" )
60-
settings.setValue('pythonConsole/contextHelpOnFirstLaunch', False)
43+
""" called from QGIS to open the console """
44+
global _console
45+
if _console is None:
46+
parent = iface.mainWindow() if iface else None
47+
_console = PythonConsole(parent)
48+
_console.show() # force show even if it was restored as hidden
49+
# set focus to the console so the user can start typing
50+
# defer the set focus event so it works also whether the console not visible yet
51+
QTimer.singleShot(0, _console.activate)
52+
else:
53+
_console.setVisible(not _console.isVisible())
54+
# set focus to the console so the user can start typing
55+
if _console.isVisible():
56+
_console.activate()
57+
## Shows help on first launch of the console
58+
settings = QSettings()
59+
if settings.value('pythonConsole/contextHelpOnFirstLaunch', True, type=bool):
60+
QgsContextHelp.run("PythonConsole")
61+
settings.setValue('pythonConsole/contextHelpOnFirstLaunch', False)
6162

6263
_old_stdout = sys.stdout
6364
_console_output = None
6465

6566
# hook for python console so all output will be redirected
6667
# and then shown in console
68+
69+
6770
def console_displayhook(obj):
6871
global _console_output
6972
_console_output = obj
7073

74+
7175
class PythonConsole(QDockWidget):
76+
7277
def __init__(self, parent=None):
7378
QDockWidget.__init__(self, parent)
7479
self.setObjectName("PythonConsole")
7580
self.setWindowTitle(QCoreApplication.translate("PythonConsole", "Python Console"))
7681
#self.setAllowedAreas(Qt.BottomDockWidgetArea)
7782

7883
self.console = PythonConsoleWidget(self)
79-
self.setWidget( self.console )
80-
self.setFocusProxy( self.console )
84+
self.setWidget(self.console)
85+
self.setFocusProxy(self.console)
8186

8287
# try to restore position from stored main window state
8388
if iface and not iface.mainWindow().restoreDockWidget(self):
@@ -92,7 +97,9 @@ def closeEvent(self, event):
9297
self.console.saveSettingsConsole()
9398
QWidget.closeEvent(self, event)
9499

100+
95101
class PythonConsoleWidget(QWidget):
102+
96103
def __init__(self, parent=None):
97104
QWidget.__init__(self, parent)
98105
self.setWindowTitle(QCoreApplication.translate("PythonConsole", "Python Console"))
@@ -113,7 +120,7 @@ def __init__(self, parent=None):
113120

114121
self.shellOutWidget = QWidget(self)
115122
self.shellOutWidget.setLayout(QVBoxLayout())
116-
self.shellOutWidget.layout().setContentsMargins(0,0,0,0)
123+
self.shellOutWidget.layout().setContentsMargins(0, 0, 0, 0)
117124
self.shellOutWidget.layout().addWidget(self.shellOut)
118125

119126
self.splitter = QSplitter(self.splitterEditor)
@@ -141,7 +148,6 @@ def __init__(self, parent=None):
141148
self.listClassMethod.setColumnHidden(1, True)
142149
self.listClassMethod.setAlternatingRowColors(True)
143150

144-
145151
#self.splitterEditor.addWidget(self.widgetEditor)
146152
#self.splitterObj.addWidget(self.listClassMethod)
147153
#self.splitterObj.addWidget(self.widgetEditor)
@@ -477,9 +483,9 @@ def __init__(self, parent=None):
477483
placeHolderTxt = QCoreApplication.translate("PythonConsole", "Enter text to find...")
478484

479485
if pyqtconfig.Configuration().qt_version >= 0x40700:
480-
self.lineEditFind.setPlaceholderText(placeHolderTxt)
486+
self.lineEditFind.setPlaceholderText(placeHolderTxt)
481487
else:
482-
self.lineEditFind.setToolTip(placeHolderTxt)
488+
self.lineEditFind.setToolTip(placeHolderTxt)
483489
self.findNextButton = QToolButton()
484490
self.findNextButton.setEnabled(False)
485491
toolTipfindNext = QCoreApplication.translate("PythonConsole", "Find Next")
@@ -579,13 +585,13 @@ def onClickGoToLine(self, item, column):
579585
tabEditor.goToLine(objName, linenr)
580586

581587
def processing(self):
582-
self.shell.commandConsole('processing')
588+
self.shell.commandConsole('processing')
583589

584590
def qtCore(self):
585-
self.shell.commandConsole('qtCore')
591+
self.shell.commandConsole('qtCore')
586592

587593
def qtGui(self):
588-
self.shell.commandConsole('qtGui')
594+
self.shell.commandConsole('qtGui')
589595

590596
def toggleEditor(self, checked):
591597
self.splitterObj.show() if checked else self.splitterObj.hide()
@@ -650,7 +656,7 @@ def saveScriptFile(self):
650656
tabWidget = self.tabEditorWidget.currentWidget()
651657
try:
652658
tabWidget.save()
653-
except (IOError, OSError), error:
659+
except (IOError, OSError) as error:
654660
msgText = QCoreApplication.translate('PythonConsole',
655661
'The file <b>{0}</b> could not be saved. Error: {1}').format(tabWidget.path,
656662
error.strerror)
@@ -663,19 +669,19 @@ def saveAsScriptFile(self, index=None):
663669
if not tabWidget.path:
664670
fileName = self.tabEditorWidget.tabText(index) + '.py'
665671
folder = self.settings.value("pythonConsole/lastDirPath", QDir.home())
666-
pathFileName = os.path.join(folder,fileName)
672+
pathFileName = os.path.join(folder, fileName)
667673
fileNone = True
668674
else:
669675
pathFileName = tabWidget.path
670676
fileNone = False
671677
saveAsFileTr = QCoreApplication.translate("PythonConsole", "Save File As")
672678
filename = QFileDialog.getSaveFileName(self,
673-
saveAsFileTr,
674-
pathFileName, "Script file (*.py)")
679+
saveAsFileTr,
680+
pathFileName, "Script file (*.py)")
675681
if filename:
676682
try:
677683
tabWidget.save(filename)
678-
except (IOError, OSError), error:
684+
except (IOError, OSError) as error:
679685
msgText = QCoreApplication.translate('PythonConsole',
680686
'The file <b>{0}</b> could not be saved. Error: {1}').format(tabWidget.path,
681687
error.strerror)
@@ -690,7 +696,7 @@ def saveAsScriptFile(self, index=None):
690696
self.updateTabListScript(pathFileName, action='remove')
691697

692698
def openHelp(self):
693-
QgsContextHelp.run( "PythonConsole" )
699+
QgsContextHelp.run("PythonConsole")
694700

695701
def openSettings(self):
696702
if optionsDialog(self).exec_():

0 commit comments

Comments
 (0)
Please sign in to comment.