Exemple #1
0
def encodeXMLValue(sparkValue):
    "Converts a SPARK value to a python value that can be passed by XML"
    if isinstance(sparkValue, UNCHANGED_TYPES):
        return sparkValue
    if sparkValue == sparkNULL():
        return None
    elif isStructure(sparkValue):
        d = mapDict(sparkValue, encodeXMLValue)
        if d != None:
            return d
        else:
            # Use FUNCTOR/ARGS notation
            return {FUNCTOR:sparkValue.functor.name,
                    ARGS:encodeXMLValues(sparkValue)}
    elif isList(sparkValue):
        return encodeXMLValues(sparkValue)
    elif isSymbol(sparkValue):
        return {SYM:sparkValue.name}
    elif isVariable(sparkValue):
        return {VAR:sparkValue.name}
    else:
        raise LowError("Cannot convert python type %r to XML"%sparkValue.__class__)
Exemple #2
0
def mapFromSpark(obj):
    "Given a SPARK map, return the correponding Python dict (or None if not a map)"
    try:
        return mapDict(obj)
    except:
        return None
Exemple #3
0
def mapFromSpark(obj):
    "Given a SPARK map, return the correponding Python dict (or None if not a map)"
    try:
        return mapDict(obj)
    except:
        return None