From 50a785bdd63d4e8ab3238a91e109e51c31d32eda Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Fri, 25 Nov 2016 09:27:50 +0200 Subject: [PATCH] [processing] indentation update --- .../processing/algs/qgis/FieldsMapper.py | 1 - .../processing/algs/qgis/RasterCalculator.py | 29 ++++++++++--------- .../algs/qgis/ui/RasterCalculatorWidgets.py | 23 +++++++-------- .../plugins/processing/core/GeoAlgorithm.py | 12 ++++---- .../plugins/processing/gui/ParametersPanel.py | 4 +-- .../modeler/ModelerParametersDialog.py | 2 +- 6 files changed, 35 insertions(+), 36 deletions(-) diff --git a/python/plugins/processing/algs/qgis/FieldsMapper.py b/python/plugins/processing/algs/qgis/FieldsMapper.py index ce7aff03b925..cc24f08d126a 100644 --- a/python/plugins/processing/algs/qgis/FieldsMapper.py +++ b/python/plugins/processing/algs/qgis/FieldsMapper.py @@ -86,7 +86,6 @@ def setValue(self, value): return False return False - self.addParameter(ParameterFieldsMapping(self.FIELDS_MAPPING, self.tr('Fields mapping'), self.INPUT_LAYER)) diff --git a/python/plugins/processing/algs/qgis/RasterCalculator.py b/python/plugins/processing/algs/qgis/RasterCalculator.py index f8993582d01f..25274d988624 100644 --- a/python/plugins/processing/algs/qgis/RasterCalculator.py +++ b/python/plugins/processing/algs/qgis/RasterCalculator.py @@ -39,6 +39,7 @@ from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException from processing.algs.qgis.ui.RasterCalculatorWidgets import LayersListWidgetWrapper, ExpressionWidgetWrapper + class RasterCalculator(GeoAlgorithm): LAYERS = 'LAYERS' @@ -52,11 +53,13 @@ def defineCharacteristics(self): self.group, self.i18n_group = self.trAlgorithm('Raster') self.addParameter(ParameterMultipleInput(self.LAYERS, - self.tr('Input layers'), - datatype=dataobjects.TYPE_RASTER, - optional=True, - metadata={'widget_wrapper': LayersListWidgetWrapper})) + self.tr('Input layers'), + datatype=dataobjects.TYPE_RASTER, + optional=True, + metadata={'widget_wrapper': LayersListWidgetWrapper})) + class ParameterRasterCalculatorExpression(ParameterString): + def evaluateForModeler(self, value, model): # print value for i in list(model.inputs.values()): @@ -76,8 +79,8 @@ def evaluateForModeler(self, value, model): return value self.addParameter(ParameterRasterCalculatorExpression(self.EXPRESSION, self.tr('Expression'), - multiline=True, - metadata={'widget_wrapper': ExpressionWidgetWrapper})) + multiline=True, + metadata={'widget_wrapper': ExpressionWidgetWrapper})) self.addParameter(ParameterNumber(self.CELLSIZE, self.tr('Cellsize (use 0 or empty to set it automatically)'), minValue=0.0, default=0.0, optional=True)) @@ -86,7 +89,6 @@ def evaluateForModeler(self, value, model): optional=True)) self.addOutput(OutputRaster(self.OUTPUT, self.tr('Output'))) - def processAlgorithm(self, progress): expression = self.getParameterValue(self.EXPRESSION) layersValue = self.getParameterValue(self.LAYERS) @@ -123,6 +125,7 @@ def processAlgorithm(self, progress): bbox.combineExtentWith(lyr.extent()) else: raise GeoAlgorithmExecutionException(self.tr("No layers selected")) + def _cellsize(layer): return (layer.extent().xMaximum() - layer.extent().xMinimum()) / layer.width() cellsize = self.getParameterValue(self.CELLSIZE) or min([_cellsize(lyr) for lyr in layersDict.values()]) @@ -130,12 +133,12 @@ def _cellsize(layer): height = math.floor((bbox.yMaximum() - bbox.yMinimum()) / cellsize) driverName = GdalUtils.getFormatShortNameFromFilename(output) calc = QgsRasterCalculator(expression, - output, - driverName, - bbox, - width, - height, - entries) + output, + driverName, + bbox, + width, + height, + entries) res = calc.processCalculation() if res == QgsRasterCalculator.ParserError: diff --git a/python/plugins/processing/algs/qgis/ui/RasterCalculatorWidgets.py b/python/plugins/processing/algs/qgis/ui/RasterCalculatorWidgets.py index 1d4c8fe49030..32c00aad26b0 100644 --- a/python/plugins/processing/algs/qgis/ui/RasterCalculatorWidgets.py +++ b/python/plugins/processing/algs/qgis/ui/RasterCalculatorWidgets.py @@ -20,37 +20,38 @@ class ExpressionWidget(BASE, WIDGET): def __init__(self, options): super(ExpressionWidget, self).__init__(None) self.setupUi(self) - + self.setList(options) - + def doubleClicked(item): self.text.insertPlainText(self.options[item.text()]) + def addButtonText(text): if any(c for c in text if c.islower()): self.text.insertPlainText(" %s()" % text) self.text.moveCursor(QTextCursor.PreviousCharacter, QTextCursor.MoveAnchor) else: - self.text.insertPlainText(" %s " % text) + self.text.insertPlainText(" %s " % text) buttons = [b for b in self.buttonsGroupBox.children()if isinstance(b, QPushButton)] for button in buttons: button.clicked.connect(partial(addButtonText, button.text())) self.listWidget.itemDoubleClicked.connect(doubleClicked) - + def setList(self, options): self.options = options self.listWidget.clear() for opt in options.keys(): self.listWidget.addItem(opt) - + def setValue(self, value): self.text.setPlainText(value) - + def value(self): return self.text.toPlainText() - + class ExpressionWidgetWrapper(WidgetWrapper): - + def _panel(self, options): return ExpressionWidget(options) @@ -61,7 +62,7 @@ def createWidget(self): for lyr in layers: for n in xrange(lyr.bandCount()): name = '%s@%i' % (lyr.name(), n + 1) - options[name] = name + options[name] = name return self._panel(options) elif self.dialogType == DIALOG_BATCH: return QLineEdit() @@ -109,7 +110,6 @@ def setValue(self, value): if self.dialogType == DIALOG_BATCH: return self.widget.setText(value) - def value(self): if self.dialogType == DIALOG_STANDARD: if self.param.datatype == dataobjects.TYPE_FILE: @@ -130,6 +130,3 @@ def value(self): if len(values) == 0 and not self.param.optional: raise InvalidParameterValue() return values - - - \ No newline at end of file diff --git a/python/plugins/processing/core/GeoAlgorithm.py b/python/plugins/processing/core/GeoAlgorithm.py index 8350d11e9645..96897e5c3a8b 100644 --- a/python/plugins/processing/core/GeoAlgorithm.py +++ b/python/plugins/processing/core/GeoAlgorithm.py @@ -48,6 +48,7 @@ from processing.tools import dataobjects, vector from processing.algs.help import shortHelp + class GeoAlgorithm(object): def __init__(self): @@ -132,10 +133,9 @@ def defineCharacteristics(self): """ pass - def getParametersPanel(self, parent): - return ParametersPanel(parent, self) - + return ParametersPanel(parent, self) + def getCustomParametersDialog(self): """If the algorithm has a custom parameters dialog, it should be returned here, ready to be executed. @@ -185,12 +185,12 @@ def checkParameterValuesBeforeExecuting(self): calling from the console. """ return None - + def processBeforeAddingToModeler(self, alg, model): """Add here any task that has to be performed before adding an algorithm to a model, such as changing the value of a parameter depending on value - of another one""" - pass + of another one""" + pass # ========================================================= diff --git a/python/plugins/processing/gui/ParametersPanel.py b/python/plugins/processing/gui/ParametersPanel.py index 8bd9b6c0190d..312476fc23e3 100644 --- a/python/plugins/processing/gui/ParametersPanel.py +++ b/python/plugins/processing/gui/ParametersPanel.py @@ -119,10 +119,10 @@ def initWidgets(self): button.toggled.connect(self.buttonToggled) widget = QWidget() widget.setLayout(layout) - + tooltips = self.alg.getParameterDescriptions() widget.setToolTip(tooltips.get(param.name, param.description)) - + label = QLabel(desc) # label.setToolTip(tooltip) self.labels[param.name] = label diff --git a/python/plugins/processing/modeler/ModelerParametersDialog.py b/python/plugins/processing/modeler/ModelerParametersDialog.py index d5dc14f2c271..71f7dd034ede 100644 --- a/python/plugins/processing/modeler/ModelerParametersDialog.py +++ b/python/plugins/processing/modeler/ModelerParametersDialog.py @@ -158,7 +158,7 @@ def setupUi(self): label.setVisible(self.showAdvanced) widget.setVisible(self.showAdvanced) self.widgets[param.name] = widget - + self.verticalLayout.addWidget(label) self.verticalLayout.addWidget(widget)