Fix optional None input parameters handling

This commit is contained in:
Médéric RIBREUX 2017-12-26 18:53:30 +01:00
parent 5321ee5ea2
commit 433d376c8a

View File

@ -409,8 +409,12 @@ class Grass7Algorithm(QgsProcessingAlgorithm):
paramName = param.name() paramName = param.name()
if not paramName in parameters: if not paramName in parameters:
continue continue
if isinstance(parameters[paramName], str) and len(parameters[paramName]) == 0: # Handle Null parameter
if parameters[paramName] is None:
continue continue
elif isinstance(parameters[paramName], str) and len(parameters[paramName]) == 0:
continue
# Raster inputs needs to be imported into temp GRASS DB # Raster inputs needs to be imported into temp GRASS DB
if isinstance(param, QgsProcessingParameterRasterLayer): if isinstance(param, QgsProcessingParameterRasterLayer):
if paramName not in self.exportedLayers: if paramName not in self.exportedLayers:
@ -622,6 +626,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm):
:param band: imports only specified band. None for all bands. :param band: imports only specified band. None for all bands.
""" """
layer = self.parameterAsRasterLayer(parameters, name, context) layer = self.parameterAsRasterLayer(parameters, name, context)
QgsMessageLog.logMessage('raster: {0}'.format(name), 'DEBUG', QgsMessageLog.INFO)
self.loadRasterLayer(name, layer, external, band) self.loadRasterLayer(name, layer, external, band)
def loadRasterLayer(self, name, layer, external=True, band=1): def loadRasterLayer(self, name, layer, external=True, band=1):