Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
indentation update
  • Loading branch information
jef-n committed May 1, 2013
1 parent 334f43e commit d0aa1e4
Show file tree
Hide file tree
Showing 60 changed files with 450 additions and 450 deletions.
14 changes: 7 additions & 7 deletions python/console/console.py
Expand Up @@ -109,22 +109,22 @@ def __init__(self, parent=None):
self.splitter.addWidget(self.shellOut)
self.splitter.addWidget(self.shell)
#self.splitterEditor.addWidget(self.tabEditorWidget)

self.splitterObj = QSplitter(self.splitterEditor)
self.splitterObj.setHandleWidth(3)
self.splitterObj.setOrientation(Qt.Horizontal)
#self.splitterObj.setSizes([0, 0])
#self.splitterObj.setStretchFactor(0, 1)

self.widgetEditor = QWidget(self.splitterObj)

self.listClassMethod = QTreeWidget(self.splitterObj)
self.listClassMethod.setColumnCount(2)
self.listClassMethod.setHeaderLabels(['Object', 'Line'])
self.listClassMethod.setColumnHidden(1, True)
self.listClassMethod.setAlternatingRowColors(True)


#self.splitterEditor.addWidget(self.widgetEditor)
#self.splitterObj.addWidget(self.listClassMethod)
#self.splitterObj.addWidget(self.widgetEditor)
Expand Down Expand Up @@ -528,7 +528,7 @@ def uncommentCode(self):
# if line != "\n":
# listScriptFile.append(line)
# self.shell.insertTextFromFile(listScriptFile)
#
#
# lastDirPath = QFileInfo(scriptFile).path()
# settings.setValue("pythonConsole/lastDirPath", QVariant(scriptFile))
#
Expand All @@ -538,7 +538,7 @@ def uncommentCode(self):
# scriptFile.setDefaultSuffix(".py")
# fName = scriptFile.getSaveFileName(
# self, "Save file", QString(), "Script file (*.py)")
#
#
# if fName.isEmpty() == False:
# filename = str(fName)
# if not filename.endswith(".py"):
Expand Down Expand Up @@ -616,7 +616,7 @@ def callWidgetMessageBar(self, text):
def callWidgetMessageBarEditor(self, text, level, timed):
self.tabEditorWidget.widgetMessageBar(iface, text, level, timed)

def updateTabListScript(self, script, action=None):
def updateTabListScript(self, script, action=None):
if script != '':
settings = QSettings()
if script == 'empty':
Expand Down
51 changes: 26 additions & 25 deletions python/console/console_editor.py
Expand Up @@ -64,12 +64,12 @@ def get_handler(self, key, modifier):
if modifiers == modifier:
return handler
return None

def eventFilter(self, obj, event):
if event.type() == QEvent.KeyPress and event.key() < 256:
handler = self.get_handler(event.key(), event.modifiers())
if handler:
handler(self.window, self.tab)
handler(self.window, self.tab)
return QObject.eventFilter(self, obj, event)

class Editor(QsciScintilla):
Expand Down Expand Up @@ -127,12 +127,12 @@ def __init__(self, parent=None):
#self.setWrapMode(QsciScintilla.WrapCharacter)
self.setWhitespaceVisibility(QsciScintilla.WsVisibleAfterIndent)
#self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

self.settingsEditor()

# Annotations
#self.setAnnotationDisplay(QsciScintilla.ANNOTATION_BOXED)

# Indentation
self.setAutoIndent(True)
self.setIndentationsUseTabs(False)
Expand Down Expand Up @@ -161,7 +161,7 @@ def __init__(self, parent=None):
self.runScriptScut = QShortcut(QKeySequence(Qt.SHIFT + Qt.CTRL + Qt.Key_E), self)
self.runScriptScut.setContext(Qt.WidgetShortcut)
self.runScriptScut.activated.connect(self.runScriptCode)

self.commentScut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_3), self)
self.commentScut.setContext(Qt.WidgetShortcut)
self.commentScut.activated.connect(self.parent.pc.commentCode)
Expand Down Expand Up @@ -295,8 +295,8 @@ def contextMenuEvent(self, e):
menu.addSeparator()
commentCodeAction = menu.addAction(iconCommentEditor, "Comment",
self.parent.pc.commentCode, 'Ctrl+3')
uncommentCodeAction = menu.addAction(iconUncommentEditor, "Uncomment",
self.parent.pc.uncommentCode,
uncommentCodeAction = menu.addAction(iconUncommentEditor, "Uncomment",
self.parent.pc.uncommentCode,
'Shift+Ctrl+3')
menu.addSeparator()
codePadAction = menu.addAction(iconCodePad,
Expand Down Expand Up @@ -391,7 +391,7 @@ def commentEditorCode(self, commentCheck):
else:
if not self.text(line).trimmed().startsWith('#'):
continue
self.setSelection(line, self.indentation(line),
self.setSelection(line, self.indentation(line),
line, self.indentation(line) + 1)
self.removeSelectedText()
else:
Expand All @@ -401,11 +401,11 @@ def commentEditorCode(self, commentCheck):
else:
if not self.text(line).trimmed().startsWith('#'):
return
self.setSelection(line, self.indentation(line),
self.setSelection(line, self.indentation(line),
line, self.indentation(line) + 1)
self.removeSelectedText()
self.endUndoAction()

def createTempFile(self):
import tempfile
fd, path = tempfile.mkstemp()
Expand All @@ -423,10 +423,10 @@ def _runSubProcess(self, filename, tmp=False):
try:
## set creationflags for runnning command without shell window
if sys.platform.startswith('win'):
p = subprocess.Popen(['python', str(filename)], shell=False, stdin=subprocess.PIPE,
p = subprocess.Popen(['python', str(filename)], shell=False, stdin=subprocess.PIPE,
stderr=subprocess.PIPE, stdout=subprocess.PIPE, creationflags=0x08000000)
else:
p = subprocess.Popen(['python', str(filename)], shell=False, stdin=subprocess.PIPE,
p = subprocess.Popen(['python', str(filename)], shell=False, stdin=subprocess.PIPE,
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
out, _traceback = p.communicate()

Expand Down Expand Up @@ -465,13 +465,14 @@ def _runSubProcess(self, filename, tmp=False):

def runScriptCode(self):
autoSave = self.settings.value("pythonConsole/autoSaveScript").toBool()

tabWidget = self.parent.tw.currentWidget()

filename = tabWidget.path
msgEditorBlank = QCoreApplication.translate('PythonConsole',

msgEditorBlank = QCoreApplication.translate('PythonConsole',
'Hey, type something for running !')
msgEditorUnsaved = QCoreApplication.translate('PythonConsole',
msgEditorUnsaved = QCoreApplication.translate('PythonConsole',
'You have to save the file before running.')
if not autoSave:
if filename is None:
Expand Down Expand Up @@ -500,7 +501,7 @@ def getTextFromEditor(self):
text = self.text()
textList = text.split("\n")
return textList

def goToLine(self, objName, linenr):
self.SendScintilla(QsciScintilla.SCI_GOTOLINE, linenr-1)
self.SendScintilla(QsciScintilla.SCI_SETTARGETSTART, self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS))
Expand Down Expand Up @@ -552,7 +553,7 @@ def __init__(self, parent, parentConsole, filename, *args):
self.newEditor = Editor(self)
if filename:
self.path = filename
if os.path.exists(filename):
if os.path.exists(filename)
self.loadFile(filename, False)

# Creates layout for message bar
Expand Down Expand Up @@ -589,15 +590,15 @@ def loadFile(self, filename, modified):

def save(self):
if self.path is None:
self.path = str(QFileDialog().getSaveFileName(self,
self.path = str(QFileDialog().getSaveFileName(self,
"Python Console: Save file",
"*.py",
"Script file (*.py)"))
# If the user didn't select a file, abort the save operation
if len(self.path) == 0:
self.path = None
return
msgText = QCoreApplication.translate('PythonConsole',
msgText = QCoreApplication.translate('PythonConsole',
'Script was correctly saved.')
self.pc.callWidgetMessageBarEditor(msgText, 0, True)
# Rename the original file, if it exists
Expand Down Expand Up @@ -706,9 +707,9 @@ def __init__(self, parent):

# Menu button list tabs
self.fileTabMenu = QMenu(self)
self.connect(self.fileTabMenu, SIGNAL("aboutToShow()"),
self.connect(self.fileTabMenu, SIGNAL("aboutToShow()"),
self.showFileTabMenu)
self.connect(self.fileTabMenu, SIGNAL("triggered(QAction*)"),
self.connect(self.fileTabMenu, SIGNAL("triggered(QAction*)"),
self.showFileTabMenuTriggered)
self.fileTabButton = QToolButton(self)
self.fileTabButton.setToolTip('List all tabs')
Expand Down Expand Up @@ -782,7 +783,7 @@ def _removeTab(self, tab, tab2index=False):
tab = self.indexOf(tab)
if self.widget(tab).newEditor.isModified():
res = QMessageBox.question( self, 'Python Console: Save File',
'The file <b>"%s"</b> has been modified, save changes ?'
'The file <b>"%s"</b> has been modified, save changes ?'
% self.tabText(tab),
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel )
if res == QMessageBox.Save:
Expand Down Expand Up @@ -920,7 +921,7 @@ def listObject(self, tab):
s = traceback.format_exc()
print '## Error: '
sys.stderr.write(s)

def refreshSettingsEditor(self):
countTab = self.count()
for i in range(countTab):
Expand Down
4 changes: 2 additions & 2 deletions python/console/console_output.py
Expand Up @@ -128,7 +128,7 @@ def __init__(self, parent=None):
self.selectAllShortcut.activated.connect(self.selectAll)

def insertInitText(self):
txtInit = QCoreApplication.translate("PythonConsole",
txtInit = QCoreApplication.translate("PythonConsole",
"Python %1 on %2\n"
"## Type help(iface) for more info and list of methods.\n").arg(sys.version, socket.gethostname())
initText = self.setText(txtInit)
Expand Down Expand Up @@ -215,7 +215,7 @@ def hideToolBar(self):

def showEditor(self):
Ed = self.parent.splitterObj
if not Ed.isVisible():
if not Ed.isVisible():
Ed.show()
self.parent.showEditorButton.setChecked(True)
self.shell.setFocus()
Expand Down
4 changes: 2 additions & 2 deletions python/console/console_sci.py
Expand Up @@ -160,7 +160,7 @@ def commandConsole(self, command):

def setLexers(self):
self.lexer = QsciLexerPython()

loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace").toString()
fontSize = self.settings.value("pythonConsole/fontsize", 10).toInt()[0]

Expand Down Expand Up @@ -514,7 +514,7 @@ def runCommand(self, cmd):
more = self.runsource(src, "<input>")
if not more:
self.buffer = []
## prevents to commands with more lines to break the console
## prevents to commands with more lines to break the console
## in the case they have a eol different from '\n'
self.setText('')
self.move_cursor_to_end()
Expand Down
22 changes: 11 additions & 11 deletions python/console/console_settings.py
Expand Up @@ -64,7 +64,7 @@ def enableDisable(self, value):
self.tableWidget.setEnabled(value)
self.addAPIpath.setEnabled(value)
self.removeAPIpath.setEnabled(value)

def autoCompletionOptions(self):
if self.autoCompleteEnabled.isChecked():
self.enableDisableAutoCompleteOptions(True)
Expand Down Expand Up @@ -144,32 +144,32 @@ def saveSettings(self):
settings.setValue("pythonConsole/fontfamilyindex", QVariant(fontFamilyIndex))
fontFamilyText = self.fontComboBox.currentText()
settings.setValue("pythonConsole/fontfamilytext", QVariant(fontFamilyText))

fontFamilyIndexEditor = self.fontComboBoxEditor.currentIndex()
settings.setValue("pythonConsole/fontfamilyindexEditor", QVariant(fontFamilyIndexEditor))
fontFamilyTextEditor = self.fontComboBoxEditor.currentText()
settings.setValue("pythonConsole/fontfamilytextEditor", QVariant(fontFamilyTextEditor))

fontSize = self.spinBox.value()
fontSizeEditor = self.spinBoxEditor.value()

for i in range(0, self.tableWidget.rowCount()):
text = self.tableWidget.item(i, 1).text()
self.listPath.append(text)
settings.setValue("pythonConsole/fontsize", QVariant(fontSize))
settings.setValue("pythonConsole/fontsizeEditor", QVariant(fontSizeEditor))
settings.setValue("pythonConsole/userAPI", QVariant(self.listPath))

settings.setValue("pythonConsole/autoCompThreshold", QVariant(self.autoCompThreshold.value()))
settings.setValue("pythonConsole/autoCompThresholdEditor", QVariant(self.autoCompThresholdEditor.value()))

if self.autoCompFromAPIEditor.isChecked():
settings.setValue("pythonConsole/autoCompleteSourceEditor", QVariant('fromAPI'))
elif self.autoCompFromDocEditor.isChecked():
settings.setValue("pythonConsole/autoCompleteSourceEditor", QVariant('fromDoc'))
elif self.autoCompFromDocAPIEditor.isChecked():
settings.setValue("pythonConsole/autoCompleteSourceEditor", QVariant('fromDocAPI'))

if self.autoCompFromAPI.isChecked():
settings.setValue("pythonConsole/autoCompleteSource", QVariant('fromAPI'))
elif self.autoCompFromDoc.isChecked():
Expand Down Expand Up @@ -198,20 +198,20 @@ def restoreSettings(self):
self.tableWidget.horizontalHeader().show()
self.tableWidget.horizontalHeader().setResizeMode(1, QHeaderView.Stretch)
self.autoSaveScript.setChecked(settings.value("pythonConsole/autoSaveScript", False).toBool())

self.autoCompThreshold.setValue(settings.value("pythonConsole/autoCompThreshold", 2).toInt()[0])
self.autoCompThresholdEditor.setValue(settings.value("pythonConsole/autoCompThresholdEditor", 2).toInt()[0])

self.autoCompleteEnabledEditor.setChecked(settings.value("pythonConsole/autoCompleteEnabledEditor", True).toBool())
self.autoCompleteEnabled.setChecked(settings.value("pythonConsole/autoCompleteEnabled", True).toBool())

if settings.value("pythonConsole/autoCompleteSource") == 'fromDoc':
self.autoCompFromDoc.setChecked(True)
elif settings.value("pythonConsole/autoCompleteSource") == 'fromAPI':
self.autoCompFromAPI.setChecked(True)
elif settings.value("pythonConsole/autoCompleteSource") == 'fromDocAPI':
self.autoCompFromDocAPI.setChecked(True)

if settings.value("pythonConsole/autoCompleteSourceEditor") == 'fromDoc':
self.autoCompFromDocEditor.setChecked(True)
elif settings.value("pythonConsole/autoCompleteSourceEditor") == 'fromAPI':
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/GdalTools/tools/doRasterize.py
Expand Up @@ -106,7 +106,7 @@ def fillOutputFileEdit(self):

self.outSelector.setFilename(outputFile)

# required either -ts or -tr to create the output file
# required either -ts or -tr to create the output file
if gdalVersion >= "1.8.0":
if not QFileInfo(outputFile).exists():
QMessageBox.information( self, self.tr( "Output size or resolution required" ), self.tr( "The output file doesn't exist. You must set up the output size or resolution to create it." ) )
Expand All @@ -127,7 +127,7 @@ def getArguments(self):
arguments << str( self.vertresSpin.value() )
inputFn = self.getInputFileName()
if not inputFn.isEmpty():
arguments << "-l"
arguments << "-l"
arguments << QFileInfo( inputFn ).baseName()
arguments << inputFn
arguments << self.getOutputFileName()
Expand Down

2 comments on commit d0aa1e4

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an automated command you used to clean all these files? I know about the prepare-commit script, but wasn't aware if there was a similar command for qgis python scripts.

@jef-n
Copy link
Member Author

@jef-n jef-n commented on d0aa1e4 May 1, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prepare-commit also works for python files.

Please sign in to comment.