コード例 #1
0
ファイル: basicvalues.py プロジェクト: jbalint/spark
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)
コード例 #2
0
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)
コード例 #3
0
 def set_value(self, v):
     if isList(v):
         self.value = list(v)
     else:
         self.value = v
     return True
コード例 #4
0
ファイル: rebindable.py プロジェクト: jbalint/spark
 def set_value(self, v):
     if isList(v):
         self.value = list(v)
     else:
         self.value = v
     return True