Skip to content

Commit

Permalink
[sextante] corrected parameter serialization scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Apr 12, 2013
1 parent 15953a7 commit bcd1c91
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion python/plugins/sextante/parameters/ParameterBoolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions python/plugins/sextante/parameters/ParameterCrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 5 additions & 5 deletions python/plugins/sextante/parameters/ParameterExtent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/parameters/ParameterFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions python/plugins/sextante/parameters/ParameterFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/parameters/ParameterFixedTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 +\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/parameters/ParameterNumber.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions python/plugins/sextante/parameters/ParameterRange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
2 changes: 1 addition & 1 deletion python/plugins/sextante/parameters/ParameterRaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 3 additions & 3 deletions python/plugins/sextante/parameters/ParameterSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 +\
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/parameters/ParameterString.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion python/plugins/sextante/parameters/ParameterTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion python/plugins/sextante/parameters/ParameterTableField.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ">"
2 changes: 1 addition & 1 deletion python/plugins/sextante/parameters/ParameterVector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.