tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
M\¬Qc    @s‰dZddddddddd    g    Zd
d lZd
d lZd
d lmZd
d lZd
d lZd „Zd„Z    d„Z
d„Z ddd„Z ddd„Z dd(d„ƒYZejdƒZd„Zd„ZejdƒZd„ZdZdefd„ƒYZdefd „ƒYZd    efd!„ƒYZdefd"„ƒYZd#d$„Zdd)d%„ƒYZd&d*d'„ƒYZd S(+sùplistlib.py -- a tool to generate and parse MacOSX .plist files.
 
The PropertyList (.plist) file format is a simple XML pickle supporting
basic object types, like dictionaries, lists, numbers and strings.
Usually the top level object is a dictionary.
 
To write out a plist file, use the writePlist(rootObject, pathOrFile)
function. 'rootObject' is the top level object, 'pathOrFile' is a
filename or a (writable) file object.
 
To parse a plist from a file, use the readPlist(pathOrFile) function,
with a file name or a (readable) file object as the only argument. It
returns the top level object (again, usually a dictionary).
 
To work with plist data in strings, you can use readPlistFromString()
and writePlistToString().
 
Values can be strings, integers, floats, booleans, tuples, lists,
dictionaries, Data or datetime.datetime objects. String values (including
dictionary keys) may be unicode strings -- they will be written out as
UTF-8.
 
The <data> plist type is supported through the Data class. This is a
thin wrapper around a Python string.
 
Generate Plist example:
 
    pl = dict(
        aString="Doodah",
        aList=["A", "B", 12, 32.1, [1, 2, 3]],
        aFloat=0.1,
        anInt=728,
        aDict=dict(
            anotherString="<hello & hi there!>",
            aUnicodeValue=u'M\xe4ssig, Ma\xdf',
            aTrueValue=True,
            aFalseValue=False,
        ),
        someData=Data("<binary gunk>"),
        someMoreData=Data("<lots of binary gunk>" * 10),
        aDate=datetime.datetime.fromtimestamp(time.mktime(time.gmtime())),
    )
    # unicode keys are possible, but a little awkward to use:
    pl[u'\xc5benraa'] = "That was a unicode key."
    writePlist(pl, fileName)
 
Parse Plist example:
 
    pl = readPlist(pathOrFile)
    print pl["aKey"]
t    readPlistt
writePlisttreadPlistFromStringtwritePlistToStringtreadPlistFromResourcetwritePlistToResourcetPlisttDatatDictiÿÿÿÿN(tStringIOcCs_d}t|ttfƒr0t|ƒ}d}ntƒ}|j|ƒ}|r[|jƒn|S(s¥Read a .plist file. 'pathOrFile' may either be a file name or a
    (readable) file object. Return the unpacked root object (which
    usually is a dictionary).
    ii(t
isinstancetstrtunicodetopent PlistParsertparsetclose(t
pathOrFiletdidOpentpt
rootObject((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRDs          cCs}d}t|ttfƒr3t|dƒ}d}nt|ƒ}|jdƒ|j|ƒ|jdƒ|ry|jƒndS(sqWrite 'rootObject' to a .plist file. 'pathOrFile' may either be a
    file name or a (writable) file object.
    itwis<plist version="1.0">s</plist>N(R
R R R t PlistWritertwritelnt
writeValueR(RRRtwriter((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRTs        cCstt|ƒƒS(s=Read a plist data from a string. Return the root object.
    (RR    (tdata((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRdscCs tƒ}t||ƒ|jƒS(s5Return 'rootObject' as a plist-formatted string.
    (R    Rtgetvalue(Rtf((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRjs     tplstic
Cs¦tjdddƒddlm}m}ddlm}ddlm}||ƒ}|j    ||ƒ|ƒ}|j
|ƒ|j ||ƒj }    |j |ƒt|    ƒS(s7Read plst resource from the resource fork of path.
    s)In 3.x, readPlistFromResource is removed.t
stackleveliiÿÿÿÿ(tFSReftFSGetResourceForkName(tfsRdPerm(tRes(twarningstwarnpy3kt Carbon.FileRR t Carbon.FilesR!tCarbonR"tFSOpenResourceFilet
UseResFilet Get1ResourceRt CloseResFileR(
tpathtrestypetresidRR R!R"tfsReftresNumt    plistData((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRrs    c Csôtjdddƒddlm}m}ddlm}ddlm}t    |ƒ}||ƒ}    |j
|    |ƒ|ƒ}
|j |
ƒy|j ||ƒj ƒWn|jk
r¶nX|j|ƒ} | j||dƒ| jƒ|j|
ƒd    S(
sHWrite 'rootObject' as a plst resource to the resource fork of path.
    s(In 3.x, writePlistToResource is removed.Riiÿÿÿÿ(RR (t
fsRdWrPerm(R"tN(R#R$R%RR R&R2R'R"RR(R)R*tRemoveResourcetErrortResourcet AddResourcet WriteResourceR+( RR,R-R.RR R2R"R1R/R0tres((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR‚s    
t DumbXMLWritercBs>eZddd„Zd„Zd„Zdd„Zd„ZRS(is    cCs(||_g|_||_||_dS(N(tfiletstackt indentLeveltindent(tselfR;R=R>((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt__init__™s            cCs4|jj|ƒ|jd|ƒ|jd7_dS(Ns<%s>i(R<tappendRR=(R?telement((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt beginElementŸscCsT|jdkst‚|jjƒ|ks0t‚|jd8_|jd|ƒdS(Niis</%s>(R=tAssertionErrorR<tpopR(R?RB((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt
endElement¤scCsJ|dk    r5t|ƒ}|jd|||fƒn|jd|ƒdS(Ns <%s>%s</%s>s<%s/>(tNonet_escapeAndEncodeR(R?RBtvalue((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt simpleElementªs  cCs?|r+|jj|j|j|dƒn|jjdƒdS(Ns
(R;twriteR=R>(R?tline((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR±s%N(t__name__t
__module__R@RCRFRGRJR(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR:—s
         s{(?P<year>\d\d\d\d)(?:-(?P<month>\d\d)(?:-(?P<day>\d\d)(?:T(?P<hour>\d\d)(?::(?P<minute>\d\d)(?::(?P<second>\d\d))?)?)?)?)?ZcCsld}tj|ƒjƒ}g}x;|D]3}||}|dkrHPn|jt|ƒƒq(Wtj|ŒS(Ntyeartmonthtdaythourtminutetsecond(syearsmonthsdayshoursminutessecond(t _dateParsertmatcht    groupdictRGRAtinttdatetime(tstordertgdtlsttkeytval((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt_dateFromString½s 
 cCs,d|j|j|j|j|j|jfS(Ns%04d-%02d-%02dT%02d:%02d:%02dZ(RORPRQRRRSRT(td((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt _dateToStringÈssv[\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f]cCs‘tj|ƒ}|dk    r*tdƒ‚n|jddƒ}|jddƒ}|jddƒ}|jddƒ}|jd    d
ƒ}|jd ƒS( NsDstrings can't contains control characters; use plistlib.Data insteads
s
s t&s&amp;t<s&lt;t>s&gt;sutf-8(t_controlCharPattsearchRGt
ValueErrortreplacetencode(ttexttm((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRHÔs sŽ<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
RcBs>eZdddd„Zd„Zd„Zd„Zd„ZRS(is    icCs0|r|jtƒntj||||ƒdS(N(RKt PLISTHEADERR:R@(R?R;R=R>t writeHeader((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR@èscCsYt|ttfƒr(|jd|ƒn-t|tƒr]|rM|jdƒqU|jdƒnøt|ttfƒr‰|jdd|ƒnÌt|tƒr±|jdt|ƒƒn¤t|t    ƒrÐ|j
|ƒn…t|t ƒrï|j |ƒnft|t j ƒr|jdt|ƒƒn;t|ttfƒr?|j|ƒntdt|ƒƒ‚dS(    Ntstringttruetfalsetintegers%dtrealtdatesunsuported type: %s(R
R R RJtboolRXtlongtfloattreprtdictt    writeDictRt    writeDataRYRbttupletlistt
writeArrayt    TypeErrorttype(R?RI((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRís&cCs¤|jdƒ|jd8_tddt|jjdd    ƒ|jƒƒ}x6|j|ƒjdƒD]}|rd|j|ƒqdqdW|jd7_|j    dƒdS(
NRiiiLs    t is
s        (
RCR=tmaxtlenR>RitasBase64tsplitRRF(R?Rt maxlinelengthRL((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR{s cCsŒ|jdƒ|jƒ}|jƒxU|D]M\}}t|ttfƒsZtdƒ‚n|jd|ƒ|j|ƒq*W|j    dƒdS(NRyskeys must be stringsR^(
RCtitemstsortR
R R RRJRRF(R?RaR‡R^RI((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRzs  
cCs<|jdƒx|D]}|j|ƒqW|jdƒdS(Ntarray(RCRRF(R?R‰RI((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR~s  (RMRNR@RR{RzR~(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRæs
             t _InternalDictcBs#eZd„Zd„Zd„ZRS(cCsOy||}Wntk
r*t|‚nXddlm}|dtdƒ|S(Niÿÿÿÿ(twarnsLAttribute access from plist dicts is deprecated, use d[key] notation insteadi(tKeyErrortAttributeErrorR#R‹tPendingDeprecationWarning(R?tattrRIR‹((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt __getattr__)s  
cCs.ddlm}|dtdƒ|||<dS(Niÿÿÿÿ(R‹sLAttribute access from plist dicts is deprecated, use d[key] notation insteadi(R#R‹RŽ(R?RRIR‹((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt __setattr__3s
cCsLy ||=Wntk
r't|‚nXddlm}|dtdƒdS(Niÿÿÿÿ(R‹sLAttribute access from plist dicts is deprecated, use d[key] notation insteadi(RŒRR#R‹RŽ(R?RR‹((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt __delattr__9s   (RMRNRR‘R’(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRŠ#s    
   cBseZd„ZRS(cKs:ddlm}|dtdƒtt|ƒj|dS(Niÿÿÿÿ(R‹s?The plistlib.Dict class is deprecated, use builtin dict insteadi(R#R‹RŽtsuperRR@(R?tkwargsR‹((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR@Ds
(RMRNR@(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRBscBs5eZdZd„Zd„ZeeƒZd„ZRS(s€This class has been deprecated. Use readPlist() and writePlist()
    functions instead, together with regular dict objects.
    cKs:ddlm}|dtdƒtt|ƒj|dS(Niÿÿÿÿ(R‹sUThe Plist class is deprecated, use the readPlist() and writePlist() functions insteadi(R#R‹RŽR“RR@(R?R”R‹((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR@Qs
cCs&t|ƒ}|ƒ}|j|ƒ|S(s1Deprecated. Use the readPlist() function instead.(Rtupdate(tclsRRtplist((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pytfromFileWs      cCst||ƒdS(s2Deprecated. Use the writePlist() function instead.N(R(R?R((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRK_s(RMRNt__doc__R@R˜t classmethodRK(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRKs
         iLcCsk|dd}g}xGtdt|ƒ|ƒD]-}||||!}|jtj|ƒƒq-Wdj|ƒS(NiiiR3(trangeRƒRAtbinasciit
b2a_base64tjoin(RZR†t
maxbinsizetpiecestitchunk((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt _encodeBase64ds cBsJeZdZd„Zd„ZeeƒZdd„Zd„Zd„ZRS(sWrapper for binary data.cCs ||_dS(N(R(R?R((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR@qscCs|tj|ƒƒS(N(Rœt
a2b_base64(R–R((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt
fromBase64tsiLcCst|j|ƒS(N(R£R(R?R†((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR„zscCsat||jƒr%t|j|jƒSt|tƒrDt|j|ƒStt|ƒt|ƒƒSdS(N(R
t    __class__tcmpRR tid(R?tother((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt__cmp__}s
cCsd|jjt|jƒfS(Ns%s(%s)(R¦RMRxR(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt__repr__…s(    RMRNR™R@R¥RšR„RªR«(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRms              RcBs³eZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z    d„Z
d    „Z d
„Z d „Z d „Zd „Zd„Zd„Zd„Zd„Zd„ZRS(cCsg|_d|_d|_dS(N(R<RGt
currentKeytroot(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR@‹s        cCsQddlm}|ƒ}|j|_|j|_|j|_|j|ƒ|j    S(Niÿÿÿÿ(t ParserCreate(
txml.parsers.expatR®thandleBeginElementtStartElementHandlerthandleEndElementtEndElementHandlert
handleDatatCharacterDataHandlert    ParseFileR­(R?tfileobjR®tparser((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyRs        cCs<g|_t|d|dƒ}|dk    r8||ƒndS(Ntbegin_(RtgetattrRG(R?RBtattrsthandler((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR°™s     cCs0t|d|dƒ}|dk    r,|ƒndS(Ntend_(RºRG(R?RBR¼((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR²Ÿs cCs|jj|ƒdS(N(RRA(R?R((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR´¤scCs\|jdk    r/||jd|j<d|_n)|jsD||_n|jdj|ƒdS(Niÿÿÿÿ(R¬RGR<R­RA(R?RI((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt    addObject§s       cCsFdj|jƒ}y|jdƒ}Wntk
r8nXg|_|S(NR3tascii(RžRRjt UnicodeError(R?R((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pytgetData±s     cCs*tƒ}|j|ƒ|jj|ƒdS(N(RŠR¾R<RA(R?R»Ra((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt
begin_dict¼s     cCs|jjƒdS(N(R<RE(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pytend_dictÀscCs|jƒ|_dS(N(RÁR¬(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pytend_keyÃscCs'g}|j|ƒ|jj|ƒdS(N(R¾R<RA(R?R»ta((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt begin_arrayÆs cCs|jjƒdS(N(R<RE(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt    end_arrayÊscCs|jtƒdS(N(R¾tTrue(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pytend_trueÍscCs|jtƒdS(N(R¾tFalse(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt    end_falseÏscCs|jt|jƒƒƒdS(N(R¾RXRÁ(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt end_integerÑscCs|jt|jƒƒƒdS(N(R¾RwRÁ(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pytend_realÓscCs|j|jƒƒdS(N(R¾RÁ(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt
end_stringÕscCs |jtj|jƒƒƒdS(N(R¾RR¥RÁ(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pytend_data×scCs|jt|jƒƒƒdS(N(R¾R`RÁ(R?((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pytend_dateÙs(RMRNR@RR°R²R´R¾RÁRÂRÃRÄRÆRÇRÉRËRÌRÍRÎRÏRÐ(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyR‰s&                            
                                               ((((R™t__all__RœRYt    cStringIOR    treR#RRRRRRR:tcompileRUR`RbRfRHRmRRyRŠRRR£RR(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plistlib.pyt<module>3s:                     $                =