Exemple #1
0
def writeList(listObject, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    indentString = makeIndentString(indentStr, level)
    nextIndentString = makeIndentString(indentStr, level + 1)
    outstream.write("(")
    for value in listObject:
        outstream.write(nextIndentString)
        writeObject(value, outstream, indentStr, level + 1)
        outstream.write(";")
    outstream.write("%s)" % indentString)
    return outstream
Exemple #2
0
def writeList(listObject, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    indentString = makeIndentString(indentStr, level)
    nextIndentString = makeIndentString(indentStr, level + 1)
    outstream.write("(")
    for value in listObject:
        outstream.write(nextIndentString)
        writeObject(value, outstream, indentStr, level + 1)
        outstream.write(";")
    outstream.write("%s)" % indentString)
    return outstream
Exemple #3
0
def writeList(listObject, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    indentString = makeIndentString(indentStr, level)
    outstream.write("%s<array>" % indentString)
    for value in listObject:
        writeObject(value, outstream, indentStr, level + 1)
    outstream.write("%s</array>" % indentString)
    return outstream
Exemple #4
0
def writeList(listObject, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    indentString = makeIndentString(indentStr, level)
    outstream.write("%s<array>" % indentString)
    for value in listObject:
        writeObject(value, outstream, indentStr, level + 1)
    outstream.write("%s</array>" % indentString)
    return outstream
Exemple #5
0
def writeDict(dictObject, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    indentString = makeIndentString(indentStr, level)
    outstream.write("%s<dict>" % indentString)
    for key, value in dictObject.iteritems():
        writeKey(key, outstream, indentStr, level + 1)
        writeObject(value, outstream, indentStr, level + 1)
    outstream.write("%s</dict>" % indentString)
    return outstream
Exemple #6
0
def writeDict(dictObject, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    indentString = makeIndentString(indentStr, level)
    outstream.write("%s<dict>" % indentString)
    for key, value in dictObject.iteritems():
        writeKey(key, outstream, indentStr, level + 1)
        writeObject(value, outstream, indentStr, level + 1)
    outstream.write("%s</dict>" % indentString)
    return outstream
Exemple #7
0
def write(obj, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    indStr = makeIndentString(indentStr, level)
    pos = outstream.tell()
    outstream.write("""%s<?xml version="1.0" encoding="UTF-8"?>""", indStr)
    outstream.write("""%s<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">""", indStr)
    outstream.write("""%s<plist version="1.0">""", indStr)
    writeObject(obj, outstream, indentStr, level)
    outstream.write("""%s</plist>""", indStr)
    outstream.seek(pos)
    return outstream
Exemple #8
0
def write(obj, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    indStr = makeIndentString(indentStr, level)
    pos = outstream.tell()
    outstream.write("""%s<?xml version="1.0" encoding="UTF-8"?>""", indStr)
    outstream.write(
        """%s<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">""",
        indStr)
    outstream.write("""%s<plist version="1.0">""", indStr)
    writeObject(obj, outstream, indentStr, level)
    outstream.write("""%s</plist>""", indStr)
    outstream.seek(pos)
    return outstream
Exemple #9
0
def writeKey(key, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    outstream.write("%s%s = " % (makeIndentString(indentStr, level), str(key)))
    return outstream
Exemple #10
0
def writeString(value, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    outstream.write("%s<string>%s</string>" %
                    (makeIndentString(indentStr, level), value))
    return outstream
Exemple #11
0
def writeBoolean(value, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    outstream.write("%s<%s/>" % (makeIndentString(indentStr, level),
                                 ("true" if value else "false")))
    return outstream
Exemple #12
0
def writeKey(key, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    outstream.write("%s%s = " %
                    (makeIndentString(indentStr, level), str(key)))
    return outstream
Exemple #13
0
def writeString(value, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    outstream.write("%s<string>%s</string>" %
                    (makeIndentString(indentStr, level), value))
    return outstream
Exemple #14
0
def writeBoolean(value, outstream=None, indentStr=None, level=0):
    outstream = outstream or cStringIO.StringIO()
    outstream.write("%s<%s/>" %
                    (makeIndentString(indentStr, level),
                     ("true" if value else "false")))
    return outstream