def convertToSparkValueIfNecessary(x): "If x is a standard, persistable SPARK value, return None, otherwise, return the closest similar SPARK value." # Check if we have a List if isList(x): result = None for i in range(len(x)): new = convertToSparkValueIfNecessary(x[i]) if new is not None: if result is None: result = list(x) result[i] = new if result is None: return None else: return List(result) # Check for an ordinary SPARK value - assume it is persistable # i.e., it doesn't have any non-SPARK values nested within it if isString(x) or isStructure(x) or isSymbol(x) or isInteger(x) \ or isFloat(x): return None # Check if you can coerce it to a list try: listEquivalent = List(x) except TypeError: print "WARNING - Cannot coerce to a SPARK value: %r"%(x,) return None return coerceToSparkValue(listEquivalent)
def convertToSparkValueIfNecessary(x): "If x is a standard, persistable SPARK value, return None, otherwise, return the closest similar SPARK value." # Check if we have a List if isList(x): result = None for i in range(len(x)): new = convertToSparkValueIfNecessary(x[i]) if new is not None: if result is None: result = list(x) result[i] = new if result is None: return None else: return List(result) # Check for an ordinary SPARK value - assume it is persistable # i.e., it doesn't have any non-SPARK values nested within it if isString(x) or isStructure(x) or isSymbol(x) or isInteger(x) \ or isFloat(x): return None # Check if you can coerce it to a list try: listEquivalent = List(x) except TypeError: print "WARNING - Cannot coerce to a SPARK value: %r" % (x, ) return None return coerceToSparkValue(listEquivalent)
def set_value(self, v): if isList(v): self.value = list(v) else: self.value = v return True