Skip to content

Commit

Permalink
Fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Médéric RIBREUX committed Mar 7, 2016
1 parent 2275ce4 commit 5b11ba1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
20 changes: 11 additions & 9 deletions python/plugins/processing/algs/grass7/ext/r_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@
import codecs
from processing.tools.system import getTempFilename


def checkParameterValuesBeforeExecuting(alg):
""" Verify if we have the right parameters """
rules = alg.getParameterValue(u'rules')
txtrules = alg.getParameterValue(u'txtrules')
raster = alg.getParameterValue(u'raster')

if rules and txtrules:
return alg.tr("You need to set either a rules file or write directly the rules !")
elif (rules and raster) or (txtrules and raster):
return alg.tr("You need to set either rules or a raster from which to copy categories !")

return None


def processInputs(alg):
# If there is another raster to copy categories from
# we need to import it with r.in.gdal rather than r.external
Expand All @@ -49,17 +51,17 @@ def processInputs(alg):
if copyRaster:
if copyRaster in alg.exportedLayers.keys():
return
for raster,method in (inputRaster, 'r.external'),(copyRaster, 'r.in.gdal'):

for raster, method in (inputRaster, 'r.external'), (copyRaster, 'r.in.gdal'):
alg.setSessionProjectionFromLayer(raster, alg.commands)

destFilename = alg.getTempFilename()
alg.exportedLayers[raster] = destFilename
command = '{} input={} output={} band=1 --overwrite -o'.format(method, raster, destFilename)
alg.commands.append(command)

alg.setSessionProjectionFromProject(alg.commands)

region = unicode(alg.getParameterValue(alg.GRASS_REGION_EXTENT_PARAMETER))
regionCoords = region.split(',')
command = 'g.region'
Expand Down Expand Up @@ -94,15 +96,15 @@ def processCommand(alg):
if txtRulesParam.value:
# Creates a temporary txt file
tempRulesName = getTempFilename('txt')

# Inject rules into temporary txt file
with codecs.open(tempRulesName, 'w', 'utf-8') as tempRules:
tempRules.write(txtRulesParam.value)

# Replace rules with temporary file
rules.value = tempRulesName
alg.parameters.remove(txtRulesParam)

alg.processCommand()

# We re-add the new output
Expand Down
12 changes: 6 additions & 6 deletions python/plugins/processing/algs/grass7/ext/r_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def processOutputs(alg):
for method in methodList:
out = alg.getOutputValue(u'output')
for angle in angles:
inputRaster = "{}_{}{}".format(alg.exportedLayers[out], methodRef[method], angle)
outputFile = "{}/{}.{}".format(out, inputRaster, ext)
command = u"r.out.gdal --overwrite -c createopt=\"TFW=YES,COMPRESS=LZW\" input={} output=\"{}\"".format(
inputRaster, outputFile)
alg.commands.append(command)
alg.outputCommands.append(command)
inputRaster = "{}_{}{}".format(alg.exportedLayers[out], methodRef[method], angle)
outputFile = "{}/{}.{}".format(out, inputRaster, ext)
command = u"r.out.gdal --overwrite -c createopt=\"TFW=YES,COMPRESS=LZW\" input={} output=\"{}\"".format(
inputRaster, outputFile)
alg.commands.append(command)
alg.outputCommands.append(command)

0 comments on commit 5b11ba1

Please sign in to comment.