Skip to content
Permalink
Browse files

[sextante] corrected parameter serialization scheme

  • Loading branch information
volaya committed Apr 12, 2013
1 parent 15953a7 commit bcd1c91f5fc1c5ccca4487e4ef0b012e9a21a869
@@ -44,7 +44,7 @@ def serialize(self):

def deserialize(self, s):
tokens = s.split("|")
return ParameterBoolean (tokens[0], tokens[1], tokens[2] == str(True))
return ParameterBoolean (tokens[1], tokens[2], tokens[3] == str(True))

def getAsScriptCode(self):
return "##" + self.name + "=boolean " + str(self.default)
@@ -50,9 +50,9 @@ def serialize(self):

def deserialize(self, s):
tokens = s.split("|")
if tokens[2]==str(None):
tokens[2] = None
return ParameterCrs(tokens[0], tokens[1], tokens[2])
if tokens[3]==str(None):
tokens[3] = None
return ParameterCrs(tokens[1], tokens[2], tokens[3])

def getAsScriptCode(self):
return "##" + self.name + "=crs " + str(self.default)
@@ -39,13 +39,13 @@ def setValue(self, text):
self.value = self.default
return True
tokens = text.split(",")
if len(tokens)!= 4:
if len(tokens)!= 5:
return False
try:
n1 = float(tokens[0])
n2 = float(tokens[1])
n3 = float(tokens[2])
n4 = float(tokens[3])
n1 = float(tokens[1])
n2 = float(tokens[2])
n3 = float(tokens[3])
n4 = float(tokens[4])
self.value=text
return True
except:
@@ -48,4 +48,4 @@ def getFromString(s):
ParameterExtent, ParameterFile, ParameterCrs]
for clazz in classes:
if s.startswith(clazz().parameterName()):
return clazz().deserialize(s[len(clazz().parameterName())+1:])
return clazz().deserialize(s)
@@ -49,10 +49,10 @@ def setValue(self, obj):

def deserialize(self, s):
tokens = s.split("|")
if len(tokens) == 4:
return ParameterFile(tokens[0], tokens[1], tokens[2] == str(True), tokens[3] == str(True))
if len(tokens) == 5:
return ParameterFile(tokens[1], tokens[2], tokens[3] == str(True), tokens[4] == str(True))
else:
return ParameterFile(tokens[0], tokens[1], tokens[2] == str(True))
return ParameterFile(tokens[1], tokens[2], tokens[3] == str(True))

def getAsScriptCode(self):
if self.isFolder:
@@ -56,7 +56,7 @@ def tableToString(table):

def deserialize(self, s):
tokens = s.split("|")
return ParameterFixedTable(tokens[0], tokens[1], tokens[3].split(";"), int(tokens[2]), tokens[4] == str(True))
return ParameterFixedTable(tokens[1], tokens[2], tokens[4].split(";"), int(tokens[3]), tokens[5] == str(True))

def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
@@ -150,7 +150,7 @@ def serialize(self):

def deserialize(self, s):
tokens = s.split("|")
return ParameterMultipleInput(tokens[0], tokens[1], float(tokens[2]), tokens[3] == str(True))
return ParameterMultipleInput(tokens[1], tokens[2], float(tokens[3]), tokens[4] == str(True))

def getAsScriptCode(self):
if self.datatype == ParameterMultipleInput.TYPE_RASTER:
@@ -69,18 +69,18 @@ def serialize(self):

def deserialize(self, s):
tokens = s.split("|")
for i in range (2,4):
for i in range (3,5):
if tokens[i] == str(None):
tokens[i] = None
else:
tokens[i] = float(tokens[i])
'''we force the default to int if possible, since that indicates if it is restricted
to ints or not'''
try:
val = int(tokens[4])
val = int(tokens[5])
except:
val = float(tokens[4])
return ParameterNumber(tokens[0], tokens[1], tokens[2], tokens[3], val)
val = float(tokens[5])
return ParameterNumber(tokens[1], tokens[2], tokens[3], tokens[4], val)

def getAsScriptCode(self):
return "##" + self.name + "=number " + str(self.default)
@@ -52,7 +52,7 @@ def getValueAsCommandLineParameter(self):

def deserialize(self, s):
tokens = s.split("|")
if len(tokens) == 3:
return ParameterRange(tokens[0], tokens[1], tokens[2])
if len(tokens) == 4:
return ParameterRange(tokens[1], tokens[2], tokens[3])
else:
return ParameterRange(tokens[0], tokens[1])
@@ -88,7 +88,7 @@ def serialize(self):

def deserialize(self, s):
tokens = s.split("|")
return ParameterRaster(tokens[0], tokens[1], str(True) == tokens[2])
return ParameterRaster(tokens[1], tokens[2], str(True) == tokens[3])

def getAsScriptCode(self):
return "##" + self.name + "=raster"
@@ -49,10 +49,10 @@ def getAsScriptCode(self):

def deserialize(self, s):
tokens = s.split("|")
if len(tokens) == 4:
return ParameterSelection(tokens[0], tokens[1], tokens[2].split(";"), int(tokens[3]))
if len(tokens) == 5:
return ParameterSelection(tokens[1], tokens[2], tokens[3].split(";"), int(tokens[4]))
else:
return ParameterSelection(tokens[0], tokens[1], tokens[2].split(";"))
return ParameterSelection(tokens[1], tokens[2], tokens[3].split(";"))

def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
@@ -52,7 +52,7 @@ def serialize(self):

def deserialize(self, s):
tokens = s.split("|")
return ParameterString(tokens[0], tokens[1], tokens[2])
return ParameterString(tokens[1], tokens[2], tokens[3])

def getAsScriptCode(self):
return "##" + self.name + "=string " + self.default
@@ -91,7 +91,7 @@ def serialize(self):

def deserialize(self, s):
tokens = s.split("|")
return ParameterTable(tokens[0], tokens[1], str(True) == tokens[2])
return ParameterTable(tokens[1], tokens[2], str(True) == tokens[3])

def getAsScriptCode(self):
return "##" + self.name + "=table"
@@ -56,7 +56,7 @@ def serialize(self):

def deserialize(self, s):
tokens = s.split("|")
return ParameterTableField(tokens[0], tokens[1], tokens[2], int(tokens[3]), tokens[4] == str(True))
return ParameterTableField(tokens[1], tokens[2], tokens[3], int(tokens[4]), tokens[5] == str(True))

def __str__(self):
return self.name + " <" + self.__module__.split(".")[-1] +" from " + self.parent + ">"
@@ -96,7 +96,7 @@ def serialize(self):

def deserialize(self, s):
tokens = s.split("|")
return ParameterVector(tokens[0], tokens[1], int(tokens[2]), str(True) == tokens[3])
return ParameterVector(tokens[1], tokens[2], int(tokens[3]), str(True) == tokens[4])

def getAsScriptCode(self):
return "##" + self.name + "=vector"

0 comments on commit bcd1c91

Please sign in to comment.
You can’t perform that action at this time.