Skip to content

Commit

Permalink
added option to add hardcoded params to GRASS algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Oct 24, 2015
1 parent 5575d04 commit 4550890
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion python/plugins/processing/algs/grass/GrassAlgorithm.py
Expand Up @@ -66,6 +66,7 @@ class GrassAlgorithm(GeoAlgorithm):

def __init__(self, descriptionfile):
GeoAlgorithm.__init__(self)
self.hardcodedStrings = []
self.descriptionFile = descriptionfile
self.defineCharacteristicsFromFile()
self.numExportedLayers = 0
Expand Down Expand Up @@ -121,7 +122,9 @@ def defineCharacteristicsFromFile(self):
while line != '':
try:
line = line.strip('\n').strip()
if line.startswith('Parameter'):
if line.startswith('Hardcoded'):
self.hardcodedStrings.append(line[len('Hardcoded|'):])
elif line.startswith('Parameter'):
parameter = getParameterFromString(line)
self.addParameter(parameter)
if isinstance(parameter, ParameterVector):
Expand Down Expand Up @@ -297,6 +300,8 @@ def processAlgorithm(self, progress):
# 2: Set parameters and outputs

command = self.grassName
command += ' ' + ' '.join(self.hardcodedStrings)

for param in self.parameters:
if param.value is None or param.value == '':
continue
Expand Down
7 changes: 6 additions & 1 deletion python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -65,6 +65,7 @@ class Grass7Algorithm(GeoAlgorithm):

def __init__(self, descriptionfile):
GeoAlgorithm.__init__(self)
self.hardcodedStrings = []
self.descriptionFile = descriptionfile
self.defineCharacteristicsFromFile()
self.numExportedLayers = 0
Expand Down Expand Up @@ -120,7 +121,9 @@ def defineCharacteristicsFromFile(self):
while line != '':
try:
line = line.strip('\n').strip()
if line.startswith('Parameter'):
if line.startswith('Hardcoded'):
self.hardcodedStrings.append(line[len('Hardcoded|'):])
elif line.startswith('Parameter'):
parameter = getParameterFromString(line)
self.addParameter(parameter)
if isinstance(parameter, ParameterVector):
Expand Down Expand Up @@ -297,6 +300,8 @@ def processAlgorithm(self, progress):
# 2: Set parameters and outputs

command = self.grass7Name
command += ' ' + ' '.join(self.hardcodedStrings)

for param in self.parameters:
if param.value is None or param.value == '':
continue
Expand Down

0 comments on commit 4550890

Please sign in to comment.