Ejemplo n.º 1
0
 def testParameterExtent(self):
     param = ParameterExtent("name", "desc")
     assert not param.setValue("0,2,0")
     assert not param.setValue("0,2,0,a")
     assert not param.setValue("0,2,2,4")
     assert param.value == "0,2,2,4"
     assert param.setValue(None)
     assert param.value == param.default
     s = param.serialize()
     param2 = ParameterExtent()
     param2.deserialize(s)
     assert param.default == param2.default
     assert param.description == param2.description
     assert param.name == param2.name
 def defineCharacteristicsFromFile(self):
     self.hardcodedStrings = []
     lines = open(self.descriptionFile)
     line = lines.readline().strip("\n").strip()
     self.name = line
     if "|" in self.name:
         tokens = self.name.split("|")
         self.name = tokens[0]
         self.cmdname = tokens[1]
     else:
         self.cmdname = self.name
         self.name = self.name[0].upper() + self.name[1:].lower()
     line = lines.readline().strip("\n").strip()
     self.undecoratedGroup = line
     self.group = SagaGroupNameDecorator.getDecoratedName(
         self.undecoratedGroup)
     while line != "":
         line = line.strip("\n").strip()
         if line.startswith("Hardcoded"):
             self.hardcodedStrings.append(line[len("Harcoded|") + 1:])
         elif line.startswith("Parameter"):
             self.addParameter(ParameterFactory.getFromString(line))
         elif line.startswith("DontResample"):
             self.resample = False
         elif line.startswith(
                 "Extent"
         ):  #An extent parameter that wraps 4 SAGA numerical parameters
             self.extentParamNames = line[6:].strip().split(" ")
             self.addParameter(
                 ParameterExtent(self.OUTPUT_EXTENT, "Output extent",
                                 "0,1,0,1"))
         else:
             self.addOutput(OutputFactory.getFromString(line))
         line = lines.readline().strip("\n").strip()
     lines.close()
Ejemplo n.º 3
0
 def defineCharacteristicsFromFile(self):
     lines = open(self.descriptionFile)
     line = lines.readline().strip("\n").strip()
     self.name = line
     line = lines.readline().strip("\n").strip()
     self.undecoratedGroup = line
     self.group = SagaGroupNameDecorator.getDecoratedName(
         self.undecoratedGroup)
     while line != "":
         line = line.strip("\n").strip()
         if line.startswith("Parameter"):
             self.addParameter(ParameterFactory.getFromString(line))
         elif line.startswith("DontResample"):
             self.resample = False
         elif line.startswith(
                 "Extent"
         ):  #An extent parameter that wraps 4 SAGA numerical parameters
             self.extentParamNames = line[6:].strip().split(" ")
             self.addParameter(
                 ParameterExtent(self.OUTPUT_EXTENT, "Output extent",
                                 "0,1,0,1"))
         else:
             self.addOutput(OutputFactory.getFromString(line))
         line = lines.readline().strip("\n").strip()
     lines.close()
Ejemplo n.º 4
0
    def buildParametersDialog(self):
        for input in self.process.inputs:
            inputType = type(input)
            if inputType == VectorInput:
                self.addParameter(ParameterVector(str(input.identifier), str(input.title), ParameterVector.VECTOR_TYPE_ANY, input.minOccurs == 0))
            elif inputType == MultipleVectorInput:
                self.addParameter(ParameterMultipleInput(str(input.identifier), str(input.title), ParameterVector.VECTOR_TYPE_ANY, input.minOccurs == 0))
            elif inputType == StringInput:
                self.addParameter(ParameterString(str(input.identifier), str(input.title)))
            elif inputType == TextInput:
                self.addParameter(ParameterString(str(input.identifier), str(input.title)))
            elif inputType == RasterInput:
                self.addParameter(ParameterRaster(str(input.identifier), str(input.title), input.minOccurs == 0))
            elif inputType == MultipleRasterInput:
                self.addParameter(ParameterMultipleInput(str(input.identifier), str(input.title), ParameterMultipleInput.TYPE_RASTER, input.minOccurs == 0))
            elif inputType == FileInput:
                #self.addParameter(ParameterFile(str(input.identifier), str(input.title), False, input.minOccurs == 0))
                self.addParameter(ParameterFile(str(input.identifier), str(input.title)))
            elif inputType == MultipleFileInput:
                pass #Not supported
            elif inputType == SelectionInput:
                self.addParameter(ParameterSelection(str(input.identifier), str(input.title), input.valList))
            elif inputType == ExtentInput:
                self.addParameter(ParameterExtent(str(input.identifier), str(input.title)))
            elif inputType == CrsInput:
                self.addParameter(ParameterCrs(str(input.identifier), "Projection", None))

        for output in self.process.outputs:
            outputType = type(output)
            if outputType == VectorOutput:
                self.addOutput(OutputVector(str(output.identifier), str(output.title)))
            elif outputType == RasterOutput:
                self.addOutput(OutputRaster(str(output.identifier), str(output.title)))
            elif outputType == StringOutput:
                self.addOutput(OutputString(str(output.identifier), str(output.title)))
Ejemplo n.º 5
0
    def defineCharacteristicsFromFile(self):
        lines = open(self.descriptionFile)
        line = lines.readline().strip("\n").strip()
        self.appkey = line
        line = lines.readline().strip("\n").strip()
        self.cliName = line
        line = lines.readline().strip("\n").strip()
        self.name = line
        line = lines.readline().strip("\n").strip()
        self.group = line
        while line != "":
            try:
                line = line.strip("\n").strip()
                if line.startswith("Parameter"):
                    param = ParameterFactory.getFromString(line)

                    # Hack for initializing the elevation parameters from Sextante configuration
                    if param.name == "-elev.dem.path":
                        param.default = OTBUtils.otbSRTMPath()
                    if param.name == "-elev.dem.geoid":
                        param.default = OTBUtils.otbGeoidPath()
                    self.addParameter(param)
                elif line.startswith("Extent"):
                    self.addParameter(
                        ParameterExtent(self.REGION_OF_INTEREST,
                                        "Region of interest", "0,1,0,1"))
                    self.hasROI = True
                else:
                    self.addOutput(OutputFactory.getFromString(line))
                line = lines.readline().strip("\n").strip()
            except Exception, e:
                SextanteLog.addToLog(
                    SextanteLog.LOG_ERROR, "Could not open OTB algorithm: " +
                    self.descriptionFile + "\n" + line)
                raise e
Ejemplo n.º 6
0
 def defineCharacteristics(self):
     self.name = "Clip Data"
     self.group = "Points"
     self.addParameter(ParameterFile(self.INPUT, "Input las layer"))
     self.addParameter(ParameterExtent(self.EXTENT, "Extent"))
     self.addParameter(
         ParameterSelection(self.SHAPE, "Shape", ["Rectangle", "Circle"]))
     self.addOutput(OutputFile(self.OUTPUT, "Output clipped las file"))
     self.addAdvancedModifiers()
Ejemplo n.º 7
0
 def testParameterExtent(self):
     param = ParameterExtent("name", "desc")
     assert not param.setValue("0,2,0")
     assert not param.setValue("0,2,0,a")
     assert not param.setValue("0,2,2,4")
     assert param.value ==  "0,2,2,4"
     assert param.setValue(None)
     assert param.value == param.default
     s = param.serialize()
     param2 = ParameterExtent()
     param2.deserialize(s)
     assert param.default == param2.default
     assert param.description == param2.description
     assert param.name == param2.name
Ejemplo n.º 8
0
 def defineCharacteristics(self):
     self.name = "Translate (convert format)"
     self.group = "[GDAL] Conversion"
     self.addParameter(ParameterRaster(translate.INPUT, "Input layer", False))
     self.addParameter(ParameterNumber(translate.OUTSIZE, "Set the size of the output file (In pixels or %)", 1, None, 100))
     self.addParameter(ParameterBoolean(translate.OUTSIZE_PERC, "Output size is a percentage of input size", True))
     self.addParameter(ParameterString(translate.NO_DATA, "Nodata value, leave as none to take the nodata value from input", "none"))
     self.addParameter(ParameterSelection(translate.EXPAND, "Expand", ["none","gray","rgb","rgba"]))
     self.addParameter(ParameterCrs(translate.SRS, "Override the projection for the output file", None))
     self.addParameter(ParameterExtent(translate.PROJWIN, "Subset based on georeferenced coordinates"))
     self.addParameter(ParameterBoolean(translate.SDS, "Copy all subdatasets of this file to individual output files", False))
     self.addParameter(ParameterString(translate.EXTRA, "Additional creation parameters", ""))
     self.addOutput(OutputRaster(translate.OUTPUT, "Output layer"))
 def okPressed(self):
     description = unicode(self.nameTextBox.text())
     if description.strip() == "":
         QMessageBox.critical(self, "Unable to define parameter", "Invalid parameter name")
         return
     if self.param is None:
         validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
         safeName = ''.join(c for c in description if c in validChars)
         name = self.paramType.upper().replace(" ","") + "_" + safeName.upper()
     else:
         name = self.param.name
     if self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN or isinstance(self.param, ParameterBoolean):
         self.param = ParameterBoolean(name, description, self.yesNoCombo.currentIndex() == 0)
     elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD or isinstance(self.param, ParameterTableField):
         if self.parentCombo.currentIndex() < 0:
             QMessageBox.critical(self, "Unable to define parameter", "Wrong or missing parameter values")
             return
         parent = self.parentCombo.itemData(self.parentCombo.currentIndex())
         self.param = ParameterTableField(name, description, parent)
     elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or isinstance(self.param, ParameterRaster):
         self.param = ParameterRaster(name, description, self.yesNoCombo.currentIndex() == 1)
     elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE or isinstance(self.param, ParameterTable):
         self.param = ParameterTable(name, description, self.yesNoCombo.currentIndex() == 1)
     elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_VECTOR or isinstance(self.param, ParameterVector):
         self.param = ParameterVector(name, description, self.shapetypeCombo.currentIndex()-1, self.yesNoCombo.currentIndex() == 1)
     elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_MULTIPLE or isinstance(self.param, ParameterMultipleInput):
         self.param = ParameterMultipleInput(name, description, self.datatypeCombo.currentIndex()-1, self.yesNoCombo.currentIndex() == 1)
     elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_NUMBER or isinstance(self.param, ParameterNumber):
         try:
             vmin = str(self.minTextBox.text()).strip()
             if vmin == "":
                 vmin = None
             else:
                 vmin = float(vmin)
             vmax = str(self.maxTextBox.text()).strip()
             if vmax == "":
                 vmax = None
             else:
                 vmax = float(vmax)
             self.param = ParameterNumber(name, description, vmin, vmax, float(str(self.defaultTextBox.text())))
         except:
             QMessageBox.critical(self, "Unable to define parameter", "Wrong or missing parameter values")
             return
     elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_STRING or isinstance(self.param, ParameterString):
         self.param = ParameterString(name, description, str(self.defaultTextBox.text()))
     elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXTENT or isinstance(self.param, ParameterExtent):
         self.param = ParameterExtent(name, description)
     elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_FILE or isinstance(self.param, ParameterFile):
         self.param = ParameterFile(name, description)
     self.close()
Ejemplo n.º 10
0
 def defineCharacteristics(self):
     self.name = "nviz"
     self.group = "Visualization(NVIZ)"
     self.addParameter(
         ParameterMultipleInput(nviz.ELEVATION, "Elevation layers",
                                ParameterMultipleInput.TYPE_RASTER, True))
     self.addParameter(
         ParameterMultipleInput(nviz.VECTOR, "Vector layers",
                                ParameterMultipleInput.TYPE_VECTOR_ANY,
                                True))
     self.addParameter(
         ParameterExtent(nviz.GRASS_REGION_EXTENT_PARAMETER,
                         "GRASS region extent"))
     self.addParameter(
         ParameterNumber(self.GRASS_REGION_CELLSIZE_PARAMETER,
                         "GRASS region cellsize (leave 0 for default)", 0,
                         None, 0.0))
Ejemplo n.º 11
0
    def defineCharacteristics(self):
        '''Here we define the inputs and output of the algorithm, along
        with some other properties'''

        #the name that the user will see in the toolbox
        self.name = "Create new layer with selected features"

        #the branch of the toolbox under which the algorithm will appear
        self.group = "Algorithms for vector layers"

        #we add the input vector layer. It can have any kind of geometry
        #It is a mandatory (not optional) one, hence the False argument
        self.addParameter(
            ParameterVector(self.INPUT_LAYER, "Input layer",
                            ParameterVector.VECTOR_TYPE_ANY, False))
        self.addParameter(ParameterExtent("EXTENT", "EXTENT"))
        self.addParameter(ParameterCrs("CRS", "CRS"))
        # we add a vector layer as output
        self.addOutput(
            OutputVector(self.OUTPUT_LAYER,
                         "Output layer with selected features"))
Ejemplo n.º 12
0
class GrassAlgorithm(GeoAlgorithm):

    GRASS_REGION_EXTENT_PARAMETER = "GRASS_REGION_PARAMETER"
    GRASS_REGION_CELLSIZE_PARAMETER = "GRASS_REGION_CELLSIZE_PARAMETER"

    def __init__(self, descriptionfile):
        GeoAlgorithm.__init__(self)
        self.descriptionFile = descriptionfile
        self.defineCharacteristicsFromFile()
        self.numExportedLayers = 0

    def getCopy(self):
        newone = GrassAlgorithm(self.descriptionFile)
        newone.provider = self.provider
        return newone

    def getIcon(self):
        return QIcon(os.path.dirname(__file__) + "/../images/grass.png")

    def helpFile(self):
        folder = GrassUtils.grassHelpPath()
        helpfile = str(folder) + os.sep + self.grassName + ".html"
        if os.path.exists(helpfile):
            return helpfile
        else:
            raise WrongHelpFileException(
                "Grass help folder is not correctly configured.\nPlease configure it"
            )
        #return None

    def getParameterDescriptions(self):
        descs = {}
        try:
            helpfile = self.helpFile()
        except WrongHelpFileException:
            return descs
        if helpfile:
            try:
                infile = open(helpfile)
                lines = infile.readlines()
                for i in range(len(lines)):
                    if lines[i].startswith("<DT><b>"):
                        for param in self.parameters:
                            searchLine = "<b>" + param.name + "</b>"
                            if searchLine in lines[i]:
                                i += 1
                                descs[param.name] = lines[i][4:-6]
                                break

                infile.close()
            except Exception:
                pass
        return descs

    def defineCharacteristicsFromFile(self):
        lines = open(self.descriptionFile)
        line = lines.readline().strip("\n").strip()
        self.grassName = line
        line = lines.readline().strip("\n").strip()
        self.name = line
        line = lines.readline().strip("\n").strip()
        self.group = line
        while line != "":
            try:
                line = line.strip("\n").strip()
                if line.startswith("Parameter"):
                    self.addParameter(ParameterFactory.getFromString(line))
                elif line.startswith("*Parameter"):
                    param = ParameterFactory.getFromString(line[1:])
                    param.isAdvanced = True
                    self.addParameter(param)
                else:
                    self.addOutput(OutputFactory.getFromString(line))
                line = lines.readline().strip("\n").strip()
            except Exception, e:
                SextanteLog.addToLog(
                    SextanteLog.LOG_ERROR, "Could not open GRASS algorithm: " +
                    self.descriptionFile + "\n" + line)
                raise e
        lines.close()

        self.addParameter(
            ParameterExtent(self.GRASS_REGION_EXTENT_PARAMETER,
                            "GRASS region extent"))
        self.addParameter(
            ParameterNumber(self.GRASS_REGION_CELLSIZE_PARAMETER,
                            "GRASS region cellsize", 0, None, 1))
Ejemplo n.º 13
0
    def processParameterLine(self,line):
        param = None
        out = None
        line = line.replace("#", "");
        # If the line is in the format of the text description files for normal algorithms,
        # then process it using parameter and output factories
        if '|' in line:
            self.processDescriptionParameterLine(line)
            return
        tokens = line.split("=");
        desc = self.createDescriptiveName(tokens[0])
        if tokens[1].lower().strip() == "group":
            self.group = tokens[0]
            return
        if tokens[1].lower().strip() == "name":
            self.name = tokens[0]
            return
        if tokens[1].lower().strip() == "raster":
            param = ParameterRaster(tokens[0], desc, False)
        elif tokens[1].lower().strip() == "vector":
            param = ParameterVector(tokens[0],  desc,ParameterVector.VECTOR_TYPE_ANY)
        elif tokens[1].lower().strip() == "table":
            param = ParameterTable(tokens[0], desc, False)
        elif tokens[1].lower().strip() == "multiple raster":
            param = ParameterMultipleInput(tokens[0], desc, ParameterMultipleInput.TYPE_RASTER)
            param.optional = False
        elif tokens[1].lower().strip() == "multiple vector":
            param = ParameterMultipleInput(tokens[0], desc, ParameterMultipleInput.TYPE_VECTOR_ANY)
            param.optional = False
        elif tokens[1].lower().strip().startswith("selection"):
            options = tokens[1].strip()[len("selection"):].split(";")
            param = ParameterSelection(tokens[0],  desc, options);
        elif tokens[1].lower().strip().startswith("boolean"):
            default = tokens[1].strip()[len("boolean")+1:]
            param = ParameterBoolean(tokens[0],  desc, default)
        elif tokens[1].lower().strip() == "extent":
            param = ParameterExtent(tokens[0],  desc)
        elif tokens[1].lower().strip() == "file":
            param = ParameterFile(tokens[0],  desc, False)
        elif tokens[1].lower().strip() == "folder":
            param = ParameterFile(tokens[0],  desc, True)
        elif tokens[    1].lower().strip().startswith("number"):
            default = tokens[1].strip()[len("number")+1:]
            param = ParameterNumber(tokens[0],  desc, default=default)
        elif tokens[1].lower().strip().startswith("field"):
            field = tokens[1].strip()[len("field")+1:]
            found = False
            for p in self.parameters:
                if p.name == field:
                    found = True
                    break
            if found:
                param = ParameterTableField(tokens[0],  tokens[0], field)
        elif tokens[1].lower().strip().startswith("string"):
            default = tokens[1].strip()[len("string")+1:]
            param = ParameterString(tokens[0],  desc, default)
        elif tokens[1].lower().strip().startswith("output raster"):
            out = OutputRaster()
        elif tokens[1].lower().strip().startswith("output vector"):
            out = OutputVector()
        elif tokens[1].lower().strip().startswith("output table"):
            out = OutputTable()
        elif tokens[1].lower().strip().startswith("output html"):
            out = OutputHTML()
        elif tokens[1].lower().strip().startswith("output file"):
            out = OutputFile()
        elif tokens[1].lower().strip().startswith("output number"):
            out = OutputNumber()
        elif tokens[1].lower().strip().startswith("output string"):
            out = OutputString()

        if param != None:
            self.addParameter(param)
        elif out != None:
            out.name = tokens[0]
            out.description = tokens[0]
            self.addOutput(out)
        else:
            raise WrongScriptException("Could not load script:" + self.descriptionFile + ".\n Problem with line \"" + line + "\"")
Ejemplo n.º 14
0
    def processParameterLine(self, line):
        param = None
        out = None
        line = line.replace("#", "")
        if line.lower().strip().startswith("showplots"):
            self.showPlots = True
            self.addOutput(OutputHTML(RAlgorithm.RPLOTS, "R Plots"))
            return
        if line.lower().strip().startswith("dontuserasterpackage"):
            self.useRasterPackage = False
            return
        if line.lower().strip().startswith("passfilenames"):
            self.passFileNames = True
            return
        tokens = line.split("=")
        desc = self.createDescriptiveName(tokens[0])
        if tokens[1].lower().strip() == "group":
            self.group = tokens[0]
            return
        if tokens[1].lower().strip().startswith("raster"):
            param = ParameterRaster(tokens[0], desc, False)
        elif tokens[1].lower().strip() == "vector":
            param = ParameterVector(tokens[0], desc,
                                    ParameterVector.VECTOR_TYPE_ANY)
        elif tokens[1].lower().strip() == "table":
            param = ParameterTable(tokens[0], desc, False)
        elif tokens[1].lower().strip().startswith("multiple raster"):
            param = ParameterMultipleInput(tokens[0], desc,
                                           ParameterMultipleInput.TYPE_RASTER)
            param.optional = False
        elif tokens[1].lower().strip() == "multiple vector":
            param = ParameterMultipleInput(
                tokens[0], desc, ParameterMultipleInput.TYPE_VECTOR_ANY)
            param.optional = False
        elif tokens[1].lower().strip().startswith("selection"):
            options = tokens[1].strip()[len("selection"):].split(";")
            param = ParameterSelection(tokens[0], desc, options)
        elif tokens[1].lower().strip().startswith("boolean"):
            default = tokens[1].strip()[len("boolean") + 1:]
            param = ParameterBoolean(tokens[0], desc, default)
        elif tokens[1].lower().strip().startswith("number"):
            try:
                default = float(tokens[1].strip()[len("number") + 1:])
                param = ParameterNumber(tokens[0], desc, default=default)
            except:
                raise WrongScriptException("Could not load R script:" +
                                           self.descriptionFile +
                                           ".\n Problem with line \"" + line +
                                           "\"")
        elif tokens[1].lower().strip().startswith("field"):
            field = tokens[1].strip()[len("field") + 1:]
            found = False
            for p in self.parameters:
                if p.name == field:
                    found = True
                    break
            if found:
                param = ParameterTableField(tokens[0], tokens[0], field)
        elif tokens[1].lower().strip() == "extent":
            param = ParameterExtent(tokens[0], desc)
        elif tokens[1].lower().strip() == "file":
            param = ParameterFile(tokens[0], desc, False)
        elif tokens[1].lower().strip() == "folder":
            param = ParameterFile(tokens[0], desc, True)
        elif tokens[1].lower().strip().startswith("string"):
            default = tokens[1].strip()[len("string") + 1:]
            param = ParameterString(tokens[0], desc, default)
        elif tokens[1].lower().strip().startswith("output raster"):
            out = OutputRaster()
        elif tokens[1].lower().strip().startswith("output vector"):
            out = OutputVector()
        elif tokens[1].lower().strip().startswith("output table"):
            out = OutputTable()
        elif tokens[1].lower().strip().startswith("output file"):
            out = OutputFile()

        if param != None:
            self.addParameter(param)
        elif out != None:
            out.name = tokens[0]
            out.description = tokens[0]
            self.addOutput(out)
        else:
            raise WrongScriptException("Could not load R script:" +
                                       self.descriptionFile +
                                       ".\n Problem with line \"" + line +
                                       "\"")
Ejemplo n.º 15
0
class GrassAlgorithm(GeoAlgorithm):

    GRASS_MIN_AREA_PARAMETER = "GRASS_MIN_AREA_PARAMETER"
    GRASS_SNAP_TOLERANCE_PARAMETER = "GRASS_SNAP_TOLERANCE_PARAMETER"
    GRASS_REGION_EXTENT_PARAMETER = "GRASS_REGION_PARAMETER"
    GRASS_REGION_CELLSIZE_PARAMETER = "GRASS_REGION_CELLSIZE_PARAMETER"

    def __init__(self, descriptionfile):
        GeoAlgorithm.__init__(self)
        self.descriptionFile = descriptionfile
        self.defineCharacteristicsFromFile()
        self.numExportedLayers = 0
        #GRASS console output, needed to do postprocessing in case GRASS dumps results to the console
        self.consoleOutput = []

    def getCopy(self):
        newone = GrassAlgorithm(self.descriptionFile)
        newone.provider = self.provider
        return newone

    def getIcon(self):
        return QIcon(os.path.dirname(__file__) + "/../images/grass.png")

    def helpFile(self):
        folder = GrassUtils.grassHelpPath()
        helpfile = str(folder) + os.sep + self.grassName + ".html"
        if os.path.exists(helpfile):
            return helpfile
        else:
            raise WrongHelpFileException(
                "Grass help folder is not correctly configured.\nPlease configure it"
            )
        #return None

    def getParameterDescriptions(self):
        descs = {}
        try:
            helpfile = self.helpFile()
        except WrongHelpFileException:
            return descs
        if helpfile:
            try:
                infile = open(helpfile)
                lines = infile.readlines()
                for i in range(len(lines)):
                    if lines[i].startswith("<DT><b>"):
                        for param in self.parameters:
                            searchLine = "<b>" + param.name + "</b>"
                            if searchLine in lines[i]:
                                i += 1
                                descs[param.name] = lines[i][4:-6]
                                break

                infile.close()
            except Exception:
                pass
        return descs

    def defineCharacteristicsFromFile(self):
        lines = open(self.descriptionFile)
        line = lines.readline().strip("\n").strip()
        self.grassName = line
        line = lines.readline().strip("\n").strip()
        self.name = line
        line = lines.readline().strip("\n").strip()
        self.group = line
        hasRasterOutput = False
        hasVectorOutput = False
        while line != "":
            try:
                line = line.strip("\n").strip()
                if line.startswith("Parameter"):
                    parameter = ParameterFactory.getFromString(line)
                    self.addParameter(parameter)
                    if isinstance(parameter, ParameterVector):
                        hasVectorOutput = True
                    if isinstance(
                            parameter,
                            ParameterMultipleInput) and parameter.datatype < 3:
                        hasVectorOutput = True
                elif line.startswith("*Parameter"):
                    param = ParameterFactory.getFromString(line[1:])
                    param.isAdvanced = True
                    self.addParameter(param)
                else:
                    output = OutputFactory.getFromString(line)
                    self.addOutput(output)
                    if isinstance(output, OutputRaster):
                        hasRasterOutput = True
                line = lines.readline().strip("\n").strip()
            except Exception, e:
                SextanteLog.addToLog(
                    SextanteLog.LOG_ERROR, "Could not open GRASS algorithm: " +
                    self.descriptionFile + "\n" + line)
                raise e
        lines.close()

        self.addParameter(
            ParameterExtent(self.GRASS_REGION_EXTENT_PARAMETER,
                            "GRASS region extent"))
        if hasRasterOutput:
            self.addParameter(
                ParameterNumber(self.GRASS_REGION_CELLSIZE_PARAMETER,
                                "GRASS region cellsize (leave 0 for default)",
                                0, None, 0.0))
        if hasVectorOutput:
            param = ParameterNumber(self.GRASS_SNAP_TOLERANCE_PARAMETER,
                                    "v.in.ogr snap tolerance (-1 = no snap)",
                                    -1, None, -1.0)
            param.isAdvanced = True
            self.addParameter(param)
            param = ParameterNumber(self.GRASS_MIN_AREA_PARAMETER,
                                    "v.in.ogr min area", 0, None, 0.0001)
            param.isAdvanced = True
            self.addParameter(param)