Skip to content

Commit

Permalink
[processing] Pass context argument to processAlgorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent 241d283 commit dd4f530
Show file tree
Hide file tree
Showing 177 changed files with 208 additions and 188 deletions.
Expand Up @@ -79,8 +79,10 @@ def defineCharacteristics(self):
self.addOutput(OutputVector(self.OUTPUT_LAYER,
self.tr('Output layer with selected features')))

def processAlgorithm(self, feedback):
"""Here is where the processing itself takes place."""
def processAlgorithm(self, context, feedback):
"""Here is where the processing itself takes place.
:param context:
"""

# The first thing to do is retrieve the values of the parameters
# entered by the user
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GdalAlgorithm.py
Expand Up @@ -58,7 +58,7 @@ def svgIconPath(self):
def getCustomParametersDialog(self):
return GdalAlgorithmDialog(self)

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
commands = self.getConsoleCommands()
layers = QgsProcessingUtils.compatibleVectorLayers(QgsProject.instance())
supported = QgsVectorFileWriter.supportedFormatExtensions()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/extractprojection.py
Expand Up @@ -64,7 +64,7 @@ def defineCharacteristics(self):
def getConsoleCommands(self):
return ["extractprojection"]

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
rasterPath = self.getParameterValue(self.INPUT)
createPrj = self.getParameterValue(self.PRJ_FILE)

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/information.py
Expand Up @@ -77,7 +77,7 @@ def getConsoleCommands(self):
arguments.append(self.getParameterValue(information.INPUT))
return ['gdalinfo', GdalUtils.escapeAndJoin(arguments)]

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
GdalUtils.runGdal(self.getConsoleCommands(), feedback)
output = self.getOutputValue(information.OUTPUT)
with open(output, 'w') as f:
Expand Down
Expand Up @@ -125,9 +125,9 @@ def defineCharacteristics(self):
self.addParameter(ParameterString(self.OPTIONS,
self.tr('Additional creation options'), '', optional=True))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
self.processing = True
GdalAlgorithm.processAlgorithm(self, feedback)
GdalAlgorithm.processAlgorithm(self, context, feedback)
self.processing = False

def getConsoleCommands(self):
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/gdal/ogr2ogrtopostgislist.py
Expand Up @@ -177,9 +177,9 @@ def defineCharacteristics(self):
self.addParameter(ParameterString(self.OPTIONS,
self.tr('Additional creation options'), '', optional=True))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
self.processing = True
GdalAlgorithm.processAlgorithm(self, feedback)
GdalAlgorithm.processAlgorithm(None, self)
self.processing = False

def getConsoleCommands(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/ogrinfo.py
Expand Up @@ -70,7 +70,7 @@ def getConsoleCommands(self):
arguments.append(conn)
return arguments

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
GdalUtils.runGdal(self.getConsoleCommands(), feedback)
output = self.getOutputValue(self.OUTPUT)
with open(output, 'w') as f:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -247,7 +247,7 @@ def getDefaultCellsize(self):
cellsize = 100
return cellsize

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
if system.isWindows():
path = Grass7Utils.grassPath()
if path == '':
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/nviz7.py
Expand Up @@ -92,7 +92,7 @@ def defineCharacteristics(self):
self.tr('GRASS region cellsize (leave 0 for default)'),
0, None, 0.0))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
commands = []
vector = self.getParameterValue(self.VECTOR)
elevation = self.getParameterValue(self.ELEVATION)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/AddTableField.py
Expand Up @@ -83,7 +83,7 @@ def defineCharacteristics(self):
self.addOutput(OutputVector(
self.OUTPUT_LAYER, self.tr('Added')))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
fieldType = self.getParameterValue(self.FIELD_TYPE)
fieldName = self.getParameterValue(self.FIELD_NAME)
fieldLength = self.getParameterValue(self.FIELD_LENGTH)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Aspect.py
Expand Up @@ -66,7 +66,7 @@ def defineCharacteristics(self):
self.addOutput(OutputRaster(self.OUTPUT_LAYER,
self.tr('Aspect')))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
inputFile = self.getParameterValue(self.INPUT_LAYER)
zFactor = self.getParameterValue(self.Z_FACTOR)
outputFile = self.getOutputValue(self.OUTPUT_LAYER)
Expand Down
Expand Up @@ -60,7 +60,7 @@ def defineCharacteristics(self):
self.tr('Input layer')))
self.addOutput(OutputVector(self.OUTPUT, self.tr('Incremented')))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
output = self.getOutputFromName(self.OUTPUT)
vlayer = \
dataobjects.getLayerFromString(self.getParameterValue(self.INPUT))
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/BarPlot.py
Expand Up @@ -73,7 +73,7 @@ def defineCharacteristics(self):

self.addOutput(OutputHTML(self.OUTPUT, self.tr('Bar plot')))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
layer = dataobjects.getLayerFromString(
self.getParameterValue(self.INPUT))
namefieldname = self.getParameterValue(self.NAME_FIELD)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/BasicStatistics.py
Expand Up @@ -120,7 +120,7 @@ def defineCharacteristics(self):
self.addOutput(OutputNumber(self.THIRDQUARTILE, self.tr('Third quartile')))
self.addOutput(OutputNumber(self.IQR, self.tr('Interquartile Range (IQR)')))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
layer = dataobjects.getLayerFromString(
self.getParameterValue(self.INPUT_LAYER))
field_name = self.getParameterValue(self.FIELD_NAME)
Expand Down
Expand Up @@ -114,7 +114,7 @@ def defineCharacteristics(self):
self.addOutput(OutputNumber(self.NULLVALUES, self.tr('NULL (missed) values')))
self.addOutput(OutputNumber(self.IQR, self.tr('Interquartile Range (IQR)')))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
layer = dataobjects.getLayerFromString(
self.getParameterValue(self.INPUT_LAYER))
fieldName = self.getParameterValue(self.FIELD_NAME)
Expand Down
Expand Up @@ -100,7 +100,7 @@ def defineCharacteristics(self):
self.addOutput(OutputNumber(self.MIN_VALUE, self.tr('Minimum string value')))
self.addOutput(OutputNumber(self.MAX_VALUE, self.tr('Maximum string value')))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
layer = dataobjects.getLayerFromString(
self.getParameterValue(self.INPUT_LAYER))
fieldName = self.getParameterValue(self.FIELD_NAME)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Boundary.py
Expand Up @@ -63,7 +63,7 @@ def defineCharacteristics(self):
dataobjects.TYPE_VECTOR_POLYGON]))
self.addOutput(OutputVector(self.OUTPUT_LAYER, self.tr('Boundary')))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
layer = dataobjects.getLayerFromString(
self.getParameterValue(self.INPUT_LAYER))

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/BoundingBox.py
Expand Up @@ -62,7 +62,7 @@ def defineCharacteristics(self):
self.tr('Input layer')))
self.addOutput(OutputVector(self.OUTPUT_LAYER, self.tr('Bounds'), datatype=[dataobjects.TYPE_VECTOR_POLYGON]))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
layer = dataobjects.getLayerFromString(
self.getParameterValue(self.INPUT_LAYER))

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/BoxPlot.py
Expand Up @@ -82,7 +82,7 @@ def defineCharacteristics(self):

self.addOutput(OutputHTML(self.OUTPUT, self.tr('Box plot')))

def processAlgorithm(self, feedback):
def processAlgorithm(self, context, feedback):
layer = dataobjects.getLayerFromString(
self.getParameterValue(self.INPUT))
namefieldname = self.getParameterValue(self.NAME_FIELD)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Centroids.py