Skip to content

Commit

Permalink
Merge branch 'processing_parameters_refactoring'
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Oct 10, 2016
2 parents 6d2ab9e + 2c9fdae commit 66035b6
Show file tree
Hide file tree
Showing 98 changed files with 2,259 additions and 3,046 deletions.
6 changes: 1 addition & 5 deletions python/plugins/processing/algs/gdal/GdalAlgorithmDialog.py
Expand Up @@ -41,8 +41,7 @@ def __init__(self, alg):

self.alg = alg

self.mainWidget = GdalParametersPanel(self, alg)
self.setMainWidget()
self.setMainWidget(GdalParametersPanel(self, alg))

cornerWidget = QWidget()
layout = QVBoxLayout()
Expand All @@ -56,9 +55,6 @@ def __init__(self, alg):

self.mainWidget.parametersHaveChanged()

QgsMapLayerRegistry.instance().layerWasAdded.connect(self.mainWidget.layerAdded)
QgsMapLayerRegistry.instance().layersWillBeRemoved.connect(self.mainWidget.layersWillBeRemoved)


class GdalParametersPanel(ParametersPanel):

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GdalUtils.py
Expand Up @@ -155,7 +155,7 @@ def getVectorDriverFromFileName(filename):
return 'ESRI Shapefile'

formats = QgsVectorFileWriter.supportedFiltersAndFormats()
for k, v in formats.items():
for k, v in list(formats.items()):
if ext in k:
return v
return 'ESRI Shapefile'
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/gdal2tiles.py
Expand Up @@ -168,7 +168,7 @@ def getConsoleCommands(self):

parameters = {self.TITLE: '-t', self.COPYRIGHT: '-c',
self.GOOGLEKEY: '-g', self.BINGKEY: '-b'}
for arg, parameter in parameters.items():
for arg, parameter in list(parameters.items()):
if self.getParameterValue(arg):
arguments.append(parameter)
arguments.append(self.getParameterValue(arg))
Expand Down
13 changes: 6 additions & 7 deletions python/plugins/processing/algs/grass/GrassAlgorithm.py
Expand Up @@ -34,6 +34,7 @@
import uuid
import importlib
import re
import traceback

from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtGui import QIcon
Expand Down Expand Up @@ -145,18 +146,14 @@ def defineCharacteristicsFromFile(self):
line = line.strip('\n').strip()
if line.startswith('Hardcoded'):
self.hardcodedStrings.append(line[len('Hardcoded|'):])
elif line.startswith('Parameter'):
parameter = getParameterFromString(line)
parameter = getParameterFromString(line)
if parameter is not None:
self.addParameter(parameter)
if isinstance(parameter, ParameterVector):
hasVectorInput = True
if isinstance(parameter, ParameterMultipleInput) \
and parameter.datatype < 3:
hasVectorInput = True
elif line.startswith('*Parameter'):
param = getParameterFromString(line[1:])
param.isAdvanced = True
self.addParameter(param)
else:
output = getOutputFromString(line)
self.addOutput(output)
Expand All @@ -169,9 +166,11 @@ def defineCharacteristicsFromFile(self):
" (raw output)", "txt"))
line = lines.readline().strip('\n').strip()
except Exception as e:

ProcessingLog.addToLog(
ProcessingLog.LOG_ERROR,
self.tr('Could not open GRASS algorithm: %s.\n%s' % (self.descriptionFile, line)))
traceback.format_exc())
#self.tr('Could not open GRASS algorithm: %s.\n%s' % (self.descriptionFile, line)))
raise e
lines.close()

Expand Down
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -177,18 +177,14 @@ def defineCharacteristicsFromFile(self):
line = line.strip('\n').strip()
if line.startswith('Hardcoded'):
self.hardcodedStrings.append(line[len('Hardcoded|'):])
elif line.startswith('Parameter'):
parameter = getParameterFromString(line)
parameter = getParameterFromString(line)
if parameter is not None:
self.addParameter(parameter)
if isinstance(parameter, ParameterVector):
hasVectorInput = True
if isinstance(parameter, ParameterMultipleInput) \
and parameter.datatype < 3:
hasVectorInput = True
elif line.startswith('*Parameter'):
param = getParameterFromString(line[1:])
param.isAdvanced = True
self.addParameter(param)
else:
output = getOutputFromString(line)
self.addOutput(output)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/ext/i.py
Expand Up @@ -174,7 +174,7 @@ def exportInputRasters(alg, rasterDic):
{ 'inputName1': 'outputName1', 'inputName2': 'outputName2'}
"""
# Get inputs and outputs
for inputName, outputName in rasterDic.items():
for inputName, outputName in list(rasterDic.items()):
inputRaster = alg.getParameterValue(inputName)
outputRaster = alg.getOutputFromName(outputName)
command = 'r.out.gdal -c -t -f --overwrite createopt="TFW=YES,COMPRESS=LZW" input={} output=\"{}\"'.format(
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/ext/v_net.py
Expand Up @@ -87,7 +87,7 @@ def variableOutput(alg, params, nocats=True):
"""

# Build the v.out.ogr commands
for outputName, typeList in params.items():
for outputName, typeList in list(params.items()):
if not isinstance(typeList, list):
continue

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/help/__init__.py
Expand Up @@ -50,7 +50,7 @@ def replace(s):
return s.replace("{qgisdocs}", "https://docs.qgis.org/%s/%s/docs" % (version, locale))
else:
return None
h = {k: replace(v) for k, v in h.items()}
h = {k: replace(v) for k, v in list(h.items())}
return h


Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/lidar/fusion/ClipData.py
Expand Up @@ -52,7 +52,7 @@ def defineCharacteristics(self):
self.group, self.i18n_group = self.trAlgorithm('Points')
self.addParameter(ParameterFile(
self.INPUT, self.tr('Input LAS layer')))
self.addParameter(ParameterExtent(self.EXTENT, self.tr('Extent')))
self.addParameter(ParameterExtent(self.EXTENT, self.tr('Extent'), optional=False))
self.addParameter(ParameterSelection(
self.SHAPE, self.tr('Shape'), ['Rectangle', 'Circle']))
self.addOutput(OutputFile(
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/lidar/lastools/lasquery.py
Expand Up @@ -45,7 +45,7 @@ def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('lasquery')
self.group, self.i18n_group = self.trAlgorithm('LAStools')
self.addParametersVerboseGUI()
self.addParameter(ParameterExtent(self.AOI, self.tr('area of interest')))
self.addParameter(ParameterExtent(self.AOI, self.tr('area of interest'), optional=False))
self.addParametersAdditionalGUI()

def processAlgorithm(self, progress):
Expand All @@ -61,7 +61,7 @@ def processAlgorithm(self, progress):
layers = QgsMapLayerRegistry.instance().mapLayers()

# loop over layers
for name, layer in layers.items():
for name, layer in list(layers.items()):
layerType = layer.type()
if layerType == QgsMapLayer.VectorLayer:
shp_file_name = layer.source()
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/otb/OTBAlgorithm.py
Expand Up @@ -22,6 +22,7 @@
* *
***************************************************************************
"""
from builtins import next
from future import standard_library
standard_library.install_aliases()
from builtins import map
Expand Down Expand Up @@ -307,7 +308,7 @@ def processAlgorithm(self, progress):
OTBUtils.executeOtb(helperCommands, progress)

if self.roiRasters:
supportRaster = next(iter(self.roiRasters.values()))
supportRaster = next(iter(list(self.roiRasters.values())))
for roiInput, roiFile in list(self.roiVectors.items()):
helperCommands = [
"otbcli_VectorDataExtractROIApplication",
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/otb/maintenance/parsing.py
Expand Up @@ -17,6 +17,7 @@
* *
***************************************************************************
"""
from builtins import next
from builtins import str
from builtins import range
__author__ = 'Julien Malik, Oscar Picas'
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/ConcaveHull.py
Expand Up @@ -89,7 +89,7 @@ def processAlgorithm(self, progress):
counter = 50. / len(edges)
i = 0
ids = []
for id, max_len in edges.items():
for id, max_len in list(edges.items()):
if max_len > alpha * max_length:
ids.append(id)
progress.setPercentage(50 + i * counter)
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/qgis/Delaunay.py
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down
22 changes: 13 additions & 9 deletions python/plugins/processing/algs/qgis/DeleteColumn.py
Expand Up @@ -36,7 +36,7 @@
class DeleteColumn(GeoAlgorithm):

INPUT = 'INPUT'
COLUMN = 'COLUMN'
COLUMNS = 'COLUMN'
OUTPUT = 'OUTPUT'

def defineCharacteristics(self):
Expand All @@ -45,17 +45,20 @@ def defineCharacteristics(self):

self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer')))
self.addParameter(ParameterTableField(self.COLUMN,
self.tr('Field to delete'), self.INPUT))
self.addOutput(OutputVector(self.OUTPUT, self.tr('Deleted column')))
self.addParameter(ParameterTableField(self.COLUMNS,
self.tr('Fields to delete'), self.INPUT, multiple=True))
self.addOutput(OutputVector(self.OUTPUT, self.tr('Output layer')))

def processAlgorithm(self, progress):
layer = dataobjects.getObjectFromUri(
self.getParameterValue(self.INPUT))
idx = layer.fields().lookupField(self.getParameterValue(self.COLUMN))
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))

toDelete = self.getParameterValue(self.COLUMNS)
fields = layer.fields()
fields.remove(idx)
idxs = []
for f in toDelete:
idx = layer.fieldNameIndex()
fields.remove(idx)
idxs.append[idx]

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
layer.wkbType(), layer.crs())
Expand All @@ -67,7 +70,8 @@ def processAlgorithm(self, progress):
for current, f in enumerate(features):
feat.setGeometry(f.geometry())
attributes = f.attributes()
del attributes[idx]
for idx in idxs:
del attributes[idx]
feat.setAttributes(attributes)
writer.addFeature(feat)

Expand Down
Expand Up @@ -64,7 +64,7 @@ def processAlgorithm(self, progress):

cleaned = dict(geoms)

for i, g in geoms.items():
for i, g in list(geoms.items()):
for j in list(cleaned.keys()):
if i == j or i not in cleaned:
continue
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/qgis/Difference.py
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/qgis/Dissolve.py
Expand Up @@ -37,7 +37,7 @@
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.parameters import ParameterVector
from processing.core.parameters import ParameterBoolean
from processing.core.parameters import ParameterTableMultipleField
from processing.core.parameters import ParameterTableField
from processing.core.outputs import OutputVector
from processing.tools import vector, dataobjects

Expand All @@ -62,8 +62,8 @@ def defineCharacteristics(self):
[dataobjects.TYPE_VECTOR_POLYGON, dataobjects.TYPE_VECTOR_LINE]))
self.addParameter(ParameterBoolean(Dissolve.DISSOLVE_ALL,
self.tr('Dissolve all (do not use fields)'), True))
self.addParameter(ParameterTableMultipleField(Dissolve.FIELD,
self.tr('Unique ID fields'), Dissolve.INPUT, optional=True))
self.addParameter(ParameterTableField(Dissolve.FIELD,
self.tr('Unique ID fields'), Dissolve.INPUT, optional=True, multiple=True))
self.addOutput(OutputVector(Dissolve.OUTPUT, self.tr('Dissolved')))

def processAlgorithm(self, progress):
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/qgis/ExtractByLocation.py
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/qgis/FieldsCalculator.py
Expand Up @@ -89,11 +89,6 @@ def processAlgorithm(self, progress):

output = self.getOutputFromName(self.OUTPUT_LAYER)

if output.value == '':
ext = output.getDefaultFileExtension(self)
output.value = system.getTempFilenameInTempFolder(
output.name + '.' + ext)

fields = layer.fields()
if newField:
fields.append(QgsField(fieldName, fieldType, '', width, precision))
Expand Down
8 changes: 0 additions & 8 deletions python/plugins/processing/algs/qgis/FieldsMapper.py
Expand Up @@ -37,8 +37,6 @@
from processing.tools import dataobjects, vector

from .fieldsmapping import ParameterFieldsMapping
from .ui.FieldsMapperDialogs import (FieldsMapperParametersDialog,
FieldsMapperModelerParametersDialog)


class FieldsMapper(GeoAlgorithm):
Expand Down Expand Up @@ -151,9 +149,3 @@ def processAlgorithm(self, progress):
raise GeoAlgorithmExecutionException(
self.tr('An error occurred while evaluating the calculation'
' string:\n') + error)

def getCustomParametersDialog(self):
return FieldsMapperParametersDialog(self)

def getCustomModelerParametersDialog(self, modelAlg, algName=None):
return FieldsMapperModelerParametersDialog(self, modelAlg, algName)
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/GridLine.py
Expand Up @@ -57,7 +57,7 @@ def defineCharacteristics(self):
self.group, self.i18n_group = self.trAlgorithm('Vector creation tools')

self.addParameter(ParameterExtent(self.EXTENT,
self.tr('Grid extent')))
self.tr('Grid extent'), optional=False))
self.addParameter(ParameterNumber(self.HSPACING,
self.tr('Horizontal spacing'), default=10.0))
self.addParameter(ParameterNumber(self.VSPACING,
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/GridPolygon.py
Expand Up @@ -65,7 +65,7 @@ def defineCharacteristics(self):
self.addParameter(ParameterSelection(self.TYPE,
self.tr('Grid type'), self.types))
self.addParameter(ParameterExtent(self.EXTENT,
self.tr('Grid extent')))
self.tr('Grid extent'), optional=False))
self.addParameter(ParameterNumber(self.HSPACING,
self.tr('Horizontal spacing'), default=10.0))
self.addParameter(ParameterNumber(self.VSPACING,
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/qgis/HubDistanceLines.py
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Michael Minn'
__date__ = 'May 2010'
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/qgis/HubDistancePoints.py
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Michael Minn'
__date__ = 'May 2010'
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/HypsometricCurves.py
Expand Up @@ -197,7 +197,7 @@ def calculateHypsometry(self, fid, fName, progress, data, pX, pY,
else:
multiplier = pX * pY

for k, v in out.items():
for k, v in list(out.items()):
out[k] = v * multiplier

prev = None
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/qgis/Intersection.py
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/qgis/LinesIntersection.py
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/MeanCoords.py
Expand Up @@ -124,7 +124,7 @@ def processAlgorithm(self, progress):

current = 0
total = 100.0 / len(means)
for (clazz, values) in means.items():
for (clazz, values) in list(means.items()):
outFeat = QgsFeature()
cx = values[0] / values[2]
cy = values[1] / values[2]
Expand Down
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next
from builtins import str

__author__ = 'Victor Olaya'
Expand Down

3 comments on commit 66035b6

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 66035b6 Oct 11, 2016

Choose a reason for hiding this comment

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

This probably led to the following build error:
make[2]: *** No rule to make target '../python/plugins/processing/ui/widgetNumberSelector.ui', needed by 'python/plugins/processing/ui/CMakeFiles/zzz-processing-65-depend'. Stop.

As well as:
make[2]: *** No rule to make target '../python/plugins/processing/algs/qgis/ui/FieldsMapperDialogs.py', needed by 'python/plugins/processing/algs/qgis/ui/CMakeFiles/zzz-processing-45-depend'. Stop.

make[2]: *** No rule to make target '../python/plugins/processing/modeler/CalculatorModelerAlgorithm.py', needed by 'python/plugins/processing/modeler/CMakeFiles/zzz-processing-58-depend'. Stop.

make[2]: *** No rule to make target '../python/plugins/processing/modeler/ModelerOnlyAlgorithmProvider.py', needed by 'python/plugins/processing/modeler/CMakeFiles/zzz-processing-58-depend'. Stop.

make[2]: *** No rule to make target '../python/plugins/processing/gui/NumberInputDialog.py', needed by 'python/plugins/processing/gui/CMakeFiles/zzz-processing-54-depend'. Stop.

make[2]: *** No rule to make target '../python/plugins/processing/modeler/RasterLayerBoundsAlgorithm.py', needed by 'python/plugins/processing/modeler/CMakeFiles/zzz-processing-58-depend'. Stop.

make[2]: *** No rule to make target '../python/plugins/processing/modeler/RasterLayerCrsAlgorithm.py', needed by 'python/plugins/processing/modeler/CMakeFiles/zzz-processing-58-depend'. Stop.

make[2]: *** No rule to make target '../python/plugins/processing/modeler/VectorLayerBoundsAlgorithm.py', needed by 'python/plugins/processing/modeler/CMakeFiles/zzz-processing-58-depend'. Stop.

etc.

@alexbruy
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems you need to clean up your build directory

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 66035b6 Oct 11, 2016

Choose a reason for hiding this comment

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

@alexbruy , right, I was commenting on this just as your comment popped up. Not sure why make clean didn't work the first time, but build now proceeding flawlessly.

Sorry for the noise.

Please sign in to comment.