Qfn gdZddlZddlZddlZddlZddlmZddlZddlZddl Z ddl Z ddl m Z ejddeZej#ej$Gdd Zd Ze j*d Zd0d Zd Ze j*de j2ZdZdZdZGddZGddZGddeZ dZ!Gdde"Z#dddddZ$e%Z&Gd d!Z'd"Z(e)e*e+eje,fZ-Gd#d$e%Z.d%Z/e0e1e!ee &e2e1e/e'e.&iZ3de1d'd(Z4de1d'd)Z5e0d*d+d,d-Z6e0d+d*d.d/Z7y)1)InvalidFileExceptionFMT_XML FMT_BINARYloaddumploadsdumpsUIDN)BytesIO) ParserCreate PlistFormatzFMT_XML FMT_BINARY)modulec0eZdZdZdZdZdZdZdZy)r ct|ts td|dk\r td|dkr td||_y)Nzdata must be an intzUIDs cannot be >= 2**64r UIDs must be positive) isinstanceint TypeError ValueErrordataselfrs //opt/alt/python312/lib64/python3.12/plistlib.py__init__z UID.__init__NsE$$12 2 7?67 7 !845 5 c|jSN)rrs r __index__z UID.__index__Ws yyrc`|jjdt|jdS)N()) __class____name__reprrrs r__repr__z UID.__repr__Zs>>22DODDrc4|j|jffSr)r$rrs r __reduce__zUID.__reduce__]s~~ |++rc`t|tstS|j|jk(Sr)rr NotImplementedr)rothers r__eq__z UID.__eq__`s%%%! !yyEJJ&&rc,t|jSr)hashrrs r__hash__z UID.__hash__esDIIrN) r% __module__ __qualname__rr r'r)r-r0rrr r Ms!E,' rr s zv[\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]c|dzdz}g}tdt||D].}||||z}|jtj|0dj |S)Nr r)rangelenappendbinascii b2a_base64join)s maxlinelength maxbinsizepiecesichunks r_encode_base64rCyse"A%J F 1c!fj )!a*n% h))%01* 88F rct|tr$tj|j dStj|S)Nutf-8)rstrr: a2b_base64encode)r=s r_decode_base64rIs9!S""188G#455""1%%rz{(?P\d\d\d\d)(?:-(?P\d\d)(?:-(?P\d\d)(?:T(?P\d\d)(?::(?P\d\d)(?::(?P\d\d))?)?)?)?)?Zcd}tj|j}g}|D]%}||}|n|jt |'t j |S)Nyearmonthdayhourminutesecond) _dateParsermatch groupdictr9rdatetime)r=ordergdlstkeyvals r_date_from_stringr[sc @E   1  ' ' )B Cg ;  3s8    c ""rcd|j|j|j|j|j|j fzS)Nz%04d-%02d-%02dT%02d:%02d:%02dZrK)ds r_date_to_stringr^s: +  !((/ rctj|}| td|jdd}|jdd}|jdd}|jdd}|jd d }|S) Nz;strings can't contain control characters; use bytes insteadz   &z&z>)_controlCharPatsearchrreplace)textms r_escaperjs~t$A}-. . << %D <<d #D <<W %D <<V $D <<V $D KrceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZy) _PlistParserc<g|_d|_d|_||_yr)stack current_keyroot _dict_typer dict_types rrz_PlistParser.__init__s  #rcFt|_|j|j_|j|j_|j |j_|j|j_ |jj||jSr) r parserhandle_begin_elementStartElementHandlerhandle_end_elementEndElementHandler handle_dataCharacterDataHandlerhandle_entity_declEntityDeclHandler ParseFilerp)rfileobjs rparsez_PlistParser.parseso"n *.*C*C '(,(?(? %+/+;+; ((,(?(? % g&yyrctd)Nz8XML entity declarations are not supported in plist files)r)r entity_nameis_parameter_entityvaluebase system_id public_id notation_names rr|z_PlistParser.handle_entity_decls##]^^rcHg|_t|d|zd}| ||yy)Nbegin_)rgetattr)relementattrshandlers rrvz!_PlistParser.handle_begin_elements. $7 2D9   EN rc8t|d|zd}||yy)Nend_)r)rrrs rrxz_PlistParser.handle_end_elements%$ 0$7   I rc:|jj|yr)rr9rs rrzz_PlistParser.handle_datas rc|jct|jdts"t d|j j z||jd|j<d|_y|js||_yt|jdts"t d|j j z|jdj|y)Nzunexpected element at line %d) rorrndictrruCurrentLineNumberrplistr9rrs r add_objectz_PlistParser.add_objects    'djjnd3 !@!%!>!>"?@@/4DJJrN4++ ,#D DIdjjnd3 !@!%!>!>"?@@ JJrN ! !% (rcJdj|j}g|_|S)N)r<rrs rget_dataz_PlistParser.get_datas wwtyy!  rc||j}|j||jj|yr)rqrrnr9)rrr]s r begin_dictz_PlistParser.begin_dicts, OO   !rc|jr.td|j|jjfz|jj y)Nz%missing value for key '%s' at line %d)rorrurrnpoprs rend_dictz_PlistParser.end_dictsI   D"..t{{/L/LMNO O rc|jst|jdts"t d|j j z|j|_y)Nrzunexpected key at line %d)rorrnrrrurrrs rend_keyz_PlistParser.end_keysL   :djjnd#C8![[::;< <==?rc`g}|j||jj|yr)rrnr9)rras r begin_arrayz_PlistParser.begin_arrays%   !rc8|jjyr)rnrrs r end_arrayz_PlistParser.end_arrays rc&|jdy)NTrrs rend_truez_PlistParser.end_trues rc&|jdy)NFrrs r end_falsez_PlistParser.end_falses rc|j}|jds|jdr|jt|dy|jt|y)N0x0X)r startswithrr)rraws r end_integerz_PlistParser.end_integersFmmo >>$ 3>>$#7 OOCRL ) OOCH %rcT|jt|jyr)rfloatrrs rend_realz_PlistParser.end_reals dmmo./rcB|j|jyr)rrrs r end_stringz_PlistParser.end_strings  (rcT|jt|jyr)rrIrrs rend_dataz_PlistParser.end_datas t}}78rcT|jt|jyr)rr[rrs rend_datez_PlistParser.end_dates )$--/:;rN)r%r1r2rrr|rvrxrzrrrrrrrrrrrrrrr3rrrlrlsg$ _   )   +  &0)9)rnr9writelnrrrs r begin_elementz_DumbXMLWriter.begin_element"s6 '" Vg%& arcV|xjdzc_|jd|zy)Nrz)rrrs r end_elementz_DumbXMLWriter.end_element's& a Ww&'rNc ~|'t|}|jd|d|d|dy|jd|zy)Nrcrdz)rjr)rrrs rsimple_elementz_DumbXMLWriter.simple_element-s7  ENE LL'5'B C LL7* +rc|rnt|tr|jd}|jj |j |j z|jj ||jj dy)NrE )rrFrHrwriterr)rlines rrz_DumbXMLWriter.writeln5s^ $${{7+ IIOOD..< = IIOOD ! r)r  r)r%r1r2rrrrrr3rrrrs  ( , rrc6eZdZ ddZdZdZdZdZdZy) _PlistWriterc~|r|jttj||||||_||_yr)r PLISTHEADERrr _sort_keys _skipkeys)rrrr writeHeader sort_keysskipkeyss rrz_PlistWriter.__init__Bs5  JJ{ #dL&A#!rcj|jd|j||jdy)Nzz)r write_valuers rrz_PlistWriter.writeLs) ./  Z rct|tr|jd|y|dur|jdy|dur|jdyt|tr9d|cxkrdkr#n t ||jdd |zyt |t|t r|jd t |yt|tr|j|yt|ttfr|j|yt|tjr|jd t|yt|ttfr|j!|yt#d t%|z) NstringTtrueFfalselrintegerz%drealdatezunsupported type: %s)rrFrr OverflowErrorrr&r write_dictbytes bytearray write_bytesrUr^tupler write_arrayrtypers rrz_PlistWriter.write_valueQs4 eS !   % 0 d]    ' e^    ( s #5*7*$E**##Ite|<#E** u %   U 4 t $ OOE " y1 2   U # x00 1   (> ? t} -   U #2T%[@A Arc |jd|xjdzc_tddt|jj dd|jzz }t ||jdD]}|s|j||xjdz c_|jdy)NrrrL s r) rrmaxr8rrgrCsplitrr)rrr>rs rrz_PlistWriter.write_bytesss 6" a  T[[((9D6xBBQQQ)_fpseekosSEEK_ENDreadr8rstructunpack _ref_size _read_ints_object_offsets _undefined_objects _read_objectOSError IndexErrorerrorrr)rfptrailer offset_size num_objects top_objectoffset_table_offsets rrz_BinaryPlistParser.parses ) DH HHMM#r{{ +hhmmB'G7|r!*,, j'2 T^[*# HHMM- .#'??; #LD 'L;6DM$$Z0 0V\\= )&( ( )s CC3D c |dk(rd|jjdddz}d|z}dt|z}tj||jj|dS|S)Nrr r6rd)rr_BINARY_FORMATrr)rtokenLrir=fs r _get_sizez_BinaryPlistParser._get_sizesh2 S= a #c)AQAnQ''A==DHHMM!$45a8 8 rc|jj|ztvr"tjd|tSrt |zk7r t tfdtd|zDS)Nrdc3VK|] }tj||zd"yw)bigN)r from_bytes).0rArsizes r z0_BinaryPlistParser._read_ints..s/<":QQD(95A":s&)r ) rrr,rrr8rrr7)rnr5rs `@rrz_BinaryPlistParser._read_intssxx}}TAX& > !==1QCt(<'=!>E E3t9q0*,,<"'4!8T":<< fr5#z>d3)seconds@Pr`r utf-16bec3@K|]}j|ywr)r )r4xrs rr6z2_BinaryPlistParser._read_object..OsA1$++A.s)rrrrrrrr3rrrU timedeltar/r8rrr r9extendrqzipr r)rrefresultoffsettokentokenHr-r.r=robj_refskey_refskos` rr z_BinaryPlistParser._read_objects s#  #M%%c*  f a #ut| D=F d]F d]F d]F t^^^DHHMM!v+$>$)&A+$?Fd]]]4q)9:1=F d]]]4q)9:1=F d] dDHHMM!$45a8A''a3((34Ft^v&AXX]]1%F6{a*,, t^v&A88==#D4yA~*,,[[)F t^v&*A88==#D4yA~*,,[[,F t^ a&j(A5IJF t^v&Aq)HF!'DMM#  MMAA At^v&Aq)Hq)H__&F!'DMM#  -(3DAq373D3DQ3GF4,,Q/04 '( (# c  -*,, -s 7O--PN) r%r1r2rrr/rr9r r3rrrrs&$)2<2crrc(|dkry|dkry|dkryy)Nrr r5rr3)counts r_count_to_sizer^hs% v~  rc0eZdZdZdZdZdZdZdZy)_BinaryPlistWriterc.||_||_||_yr)rrr)rr$rrs rrz_BinaryPlistWriter.__init__xs#!rcg|_i|_i|_|j|t |j}dg|z|_t ||_t|j|_ |jjd|jD]}|j||j|}|jj}t |}dt||zz}|jjtj |g|j d}|||j|||f} |jjtj dg| y)Nr bplist00rdz >5xBBBQQQ)_objlist _objtable _objidtable_flattenr8rr^rr, _ref_formatrr _write_object _getrefnumtellrpack) rrr'objr(r)r& offset_format sort_versionr%s rrz_BinaryPlistWriter.write}s9  e$--( !s;' 4)$..9 {#==C   s #!__U+ "hhmmo$%89 n[9KGG  v{{=H43G3GHI +t~~{ +  v{{;99:rcDt|trt||f|jvryt ||j vryt |j}|jj|t|tr||jt||f<n||j t |<t|trg}g}|j}|jr t|}|D]O\}}t|ts|jr#td|j||j|Qt!j"||D]}|j%|yt|t&t(fr|D]}|j%|yy)Nr)r_scalarsrreidrfr8rdr9rrrrrFrr itertoolschainrgrr) rrrefnumkeysvaluesrrWvrXs rrgz_BinaryPlistWriter._flattensV eX &U U#t~~5 Y$** * T]]# U# eX &39DNNDK/ 0*0D  RY ' eT "DFKKMEu 1!!S)~~ #$:;; A a __T62 a 3e} - a .rct|tr|jt||fS|jt |Sr)rrqrerrfrrrs rrjz_BinaryPlistWriter._getrefnums9 eX &>>4;"67 7##BuI. .rc8|dkr3|jjtjd||zy|dkr5|jjtjd|dzd|y|dkr5|jjtjd|dzd|y|d kr5|jjtjd |dzd |y|jjtjd |dzd |y)Nr+z>BrZz>BBBrr[z>BBHr\z>BBLz>BBQ)rrrrl)rrSr5s r _write_sizez_BinaryPlistWriter._write_sizes "9 HHNN6;;tUT\: ; F] HHNN6;;vus{D$G H G^ HHNN6;;vus{D$G H G^ HHNN6;;vus{D$G H HHNN6;;vus{D$G Hrc |j|}|jj|j|<||jj dy|dur|jj dy|dur|jj dyt |t rP|dkr2 |jj tjdd|y|d kr1|jj tjd d |y|d kr1|jj tjd d|y|dkr1|jj tjdd|y|dkr1|jj tjdd|y|dkr1|jj d|jd ddzyt|t |tr1|jj tjdd|yt |tjrY|tjdddz j}|jj tjdd|yt |tt fr7|j#dt%||jj |yt |t&rI |j)d}|j#dt%||jj |yt |t,r%|j.dkr t1d#|j.d kr1|jj tjd d$|y|j.d kr1|jj tjd d%|y|j.dkr1|jj tjdd&|y|j.dkr1|jj tjdd'|yt|t |t2t4fr{|Dcgc]}|j|}}t%|}|j#d(||jj tjd)|j6|zzg|yt |t8rHgg} }|j:rt=|j?} n|j?} | D]m\} } t | t&s|j@r#tCd*|jE|j| | jE|j| ot%|}|j#d+||jj tjd)|j6|zzg||jj tjd)|j6|zzg| ytC|#tj$r t|dwxYw#t*$r3|j)d }|j#d!t%|d"zYwxYwcc}w),NFTrr z>Bqr}rZz>BBrr[z>BHr{r\z>BLr|lz>BQrr2r=z>Bdr@rBrrArDrrErGrFr rrHrIrdrrL)#rjrrkrrrrrrlr#rto_bytesrrU total_secondsrrr~r8rFrHUnicodeEncodeErrorr rrrrrhrrrrrrr9) rrrPr.trXrefsr=keyRefsvalRefs rootItemsrWrxs rriz _BinaryPlistWriter._write_objectsooe$$(HHMMOS! = HHNN7 # e^ HHNN7 # d] HHNN7 # s #qy9HHNN6;;udE#BCv{{5$>?v{{5$>?v{{5$>?v{{5$>?wE$)OOP#E** u % HHNN6;;udE: ; x00 1**4A66EEGA HHNN6;;udA6 7 y1 2   T3u: . HHNN5 ! s # 4LL)  s5z2 HHNN1  s #zzA~ !899f$v{{5$>?g%v{{5$>?g%v{{5$>?g%v{{5$>?#E** e} -0561DOOA&D6D A   T1 % HHNN6;;sT-=-=-A'AIDI J t $!2WG"5;;=1 !KKM !1!!S)~~ #$:;;tq12tq12 "G A   T1 % HHNN6;;sT-=-=-A'ALGL M HHNN6;;sT-=-=-A'ALGL ME" "]||9'.D89<& 4LL,  s1v{3 4*7s$.0Y= ,Z "[= Z 8[[N) r%r1r2rrrgrjr~rir3rrr`r`ws$" +;Z(!T/ I ^#rr`c|dddk(S)Nrrcr3)rs r_is_fmt_binaryrKs "1: $$r)detectruwriterfmtrsc |W|jd}|jdtjD]}|d|s|d}nt t|d}||}|j |S)Nrr rru)rs)rr_FORMATSrwrr)r$rrsrinfoPps rrras {  OO%DtH~f%N& '( ( SM( # IA 772;rc6 t|}t|||S)Nr)r r)rrrsr$s rrrws! B y 11rTF)rrrc| |tvrtd|t|d|||}|j|y)NzUnsupported format: r)rr)rrr)rr$rrrrs rrrsB (3899 c]8 $R9x PF LLrrrrcX t}t||||||jS)Nr)r rgetvalue)rrrrr$s rrrs* Bh)D ;;=r)r)8__all__r:rrUenumior rsrrerxml.parsers.expatr Enumr%r globalsupdate __members__r rcompilererCrIASCIIrRr[r^rjrlrrrrrr,objectrrr^rFrrrrqr`rrrrrrrrrr3rrrs7p    *dii ';HM  (()B "**IJ&bjjXZ\ZbZbc  # k<k<\##L[)>[)|B+J+SSS1 X ^^@  eX.. 6Q#&Q#h% T !! D,2#dU %4r