QGIS/python/plugins/sextante/parameters/ParameterString.py

30 lines
981 B
Python
Raw Normal View History

from sextante.parameters.Parameter import Parameter
class ParameterString(Parameter):
def __init__(self, name="", description="", default="", multiline = False):
Parameter.__init__(self, name, description)
self.default = default
self.value = None
self.multiline = multiline
def setValue(self, obj):
if obj is None:
self.value = self.default
return True
self.value = str(obj)
return True
def getValueAsCommandLineParameter(self):
return "\"" + str(self.value) + "\""
def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
"|" + str(self.default)
def deserialize(self, s):
tokens = s.split("|")
return ParameterString(tokens[0], tokens[1], tokens[2])
def getAsScriptCode(self):
return "##" + self.name + "=string " + self.default