U /¼^zã @s:dddddddddd d d d g Zd dlZd dlZd dlZd dlZd dlZd dlmZd dlZd dl Z d dl Z d dl Z d dl m Z d dlmZejddedZeƒ ej¡ejdd„ƒZdd„Zdd„Zdd„Zdd„ZGdd„dƒZGdd „d ƒZdZe  d¡Z dKd d!„Z!d"d#„Z"e  d$e j#¡Z$d%d&„Z%d'd(„Z&d)d*„Z'Gd+d,„d,ƒZ(Gd-d.„d.ƒZ)Gd/d0„d0e)ƒZ*d1d2„Z+Gd3d„de,ƒZ-d4d5d6d7d8œZ.e/ƒZ0Gd9d:„d:ƒZ1d;d<„Z2e3e4e5eje6fZ7Gd=d>„d>e/ƒZ8d?d@„Z9e:e;e+e(e*dAeddBe;dCœdEd „Z?e:dBdFdGœdHd „Z@e:dFdBdIœdJd „ZAdS)LÚ readPlistÚ writePlistÚreadPlistFromBytesÚwritePlistToBytesÚDataÚInvalidFileExceptionÚFMT_XMLÚ FMT_BINARYÚloadÚdumpÚloadsÚdumpsÚUIDéN)ÚBytesIO)Úwarn)Ú ParserCreateÚ PlistFormatzFMT_XML FMT_BINARY)Úmodulec cs2t|tƒr(t||ƒ }|VW5QRXn|VdS©N)Ú isinstanceÚstrÚopen)Ú pathOrFileÚmodeÚfp©rú /usr/lib64/python3.8/plistlib.pyÚ _maybe_openOs  rc Cs<tdtdƒt|dƒ}t|dddW5QR£SQRXdS)Nz8The readPlist function is deprecated, use load() insteadéÚrbF©ÚfmtÚuse_builtin_types)rÚDeprecationWarningrr )rrrrrrYs ÿ c Cs8tdtdƒt|dƒ}t||tdddW5QRXdS)Nz9The writePlist function is deprecated, use dump() insteadrÚwbTF©r!Ú sort_keysÚskipkeys)rr#rr r)Úvaluerrrrrrfs ÿ cCstdtdƒtt|ƒdddS)NzBThe readPlistFromBytes function is deprecated, use loads() insteadrFr )rr#r r©Údatarrrrss ÿcCs,tdtdƒtƒ}t||tddd| ¡S)NzAThe writePlistToBytes function is deprecated, use dumps() insteadrTFr%)rr#rr rÚgetvalue)r(Úfrrrr~sÿc@s:eZdZdd„Zedd„ƒZd dd„Zdd „Zd d „Zd S)rcCst|tƒstdƒ‚||_dS)Nzdata must be as bytes)rÚbytesÚ TypeErrorr*©Úselfr*rrrÚ__init__’s z Data.__init__cCs |t|ƒƒSr)Ú_decode_base64)Úclsr*rrrÚ fromBase64—szData.fromBase64éLcCs t|j|ƒSr)Ú_encode_base64r*)r0Ú maxlinelengthrrrÚasBase64sz Data.asBase64cCs4t||jƒr|j|jkSt|tƒr,|j|kStSdSr)rÚ __class__r*r-ÚNotImplemented©r0ÚotherrrrÚ__eq__ s     z Data.__eq__cCsd|jjt|jƒfS©Nz%s(%s)©r9Ú__name__Úreprr*©r0rrrÚ__repr__¨sz Data.__repr__N)r5) r@Ú __module__Ú __qualname__r1Ú classmethodr4r8r=rCrrrrr‹s   c@s<eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd S)r cCs<t|tƒstdƒ‚|dkr"tdƒ‚|dkr2tdƒ‚||_dS)Nzdata must be an intìzUIDs cannot be >= 2**64rúUIDs must be positive)rÚintr.Ú ValueErrorr*r/rrrr1³s z UID.__init__cCs|jSrr)rBrrrÚ __index__¼sz UID.__index__cCsd|jjt|jƒfSr>r?rBrrrrC¿sz UID.__repr__cCs|j|jffSr)r9r*rBrrrÚ __reduce__ÂszUID.__reduce__cCst|tƒstS|j|jkSr)rr r:r*r;rrrr=Ås z UID.__eq__cCs t|jƒSr)Úhashr*rBrrrÚ__hash__Êsz UID.__hash__N) r@rDrEr1rKrCrLr=rNrrrrr ²s  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]r5cCsP|dd}g}tdt|ƒ|ƒD]$}||||…}| t |¡¡q d |¡S)Nééró)ÚrangeÚlenÚappendÚbinasciiZ b2a_base64Újoin)Úsr7Z maxbinsizeÚpiecesÚiÚchunkrrrr6ßs  r6cCs(t|tƒrt | d¡¡St |¡SdS)Núutf-8)rrrUZ a2b_base64Úencode)rWrrrr2ès r2z{(?P\d\d\d\d)(?:-(?P\d\d)(?:-(?P\d\d)(?:T(?P\d\d)(?::(?P\d\d)(?::(?P\d\d))?)?)?)?)?ZcCsLd}t |¡ ¡}g}|D]&}||}|dkr2qB| t|ƒ¡qtj|ŽS)N©ZyearZmonthZdayZhourZminuteÚsecond)Ú _dateParserÚmatchÚ groupdictrTrIÚdatetime)rWÚorderÚgdZlstÚkeyÚvalrrrÚ_date_from_stringõsrgcCs d|j|j|j|j|j|jfS)Nz%04d-%02d-%02dT%02d:%02d:%02dZr])ÚdrrrÚ_date_to_stringsþricCsZt |¡}|dk rtdƒ‚| dd¡}| dd¡}| dd¡}| dd¡}| d d ¡}|S) Nzz>)Ú_controlCharPatÚsearchrJÚreplace)ÚtextÚmrrrÚ_escapes      rtc@s¤eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'S)(Ú _PlistParsercCs"g|_d|_d|_||_||_dSr)ÚstackÚ current_keyÚrootÚ_use_builtin_typesÚ _dict_type©r0r"Ú dict_typerrrr1s z_PlistParser.__init__cCs8tƒ|_|j|j_|j|j_|j|j_|j |¡|j Sr) rÚparserÚhandle_begin_elementZStartElementHandlerÚhandle_end_elementZEndElementHandlerÚ handle_dataZCharacterDataHandlerZ ParseFilerx)r0ÚfileobjrrrÚparses     z_PlistParser.parsecCs*g|_t|d|dƒ}|dk r&||ƒdS)NZbegin_)r*Úgetattr)r0ÚelementÚattrsÚhandlerrrrr~#sz!_PlistParser.handle_begin_elementcCs"t|d|dƒ}|dk r|ƒdS)NZend_)rƒ)r0r„r†rrrr)sz_PlistParser.handle_end_elementcCs|j |¡dSr)r*rTr/rrrr€.sz_PlistParser.handle_datacCsŒ|jdk rFt|jdtiƒƒs.td|jjƒ‚||jd|j<d|_nB|jsT||_n4t|jdtgƒƒsxtd|jjƒ‚|jd |¡dS)Néÿÿÿÿzunexpected element at line %d) rwrrvÚtyperJr}ÚCurrentLineNumberrxrT©r0r(rrrÚ add_object1s ÿÿz_PlistParser.add_objectcCsd |j¡}g|_|S)NÚ)rVr*r/rrrÚget_dataAs z_PlistParser.get_datacCs"| ¡}| |¡|j |¡dSr)rzr‹rvrT)r0r…rhrrrÚ begin_dictHs z_PlistParser.begin_dictcCs*|jrtd|j|jjfƒ‚|j ¡dS)Nz%missing value for key '%s' at line %d)rwrJr}r‰rvÚpoprBrrrÚend_dictMs  ÿz_PlistParser.end_dictcCs8|jst|jdtiƒƒs*td|jjƒ‚| ¡|_dS)Nr‡zunexpected key at line %d)rwrrvrˆrJr}r‰rrBrrrÚend_keySs ÿz_PlistParser.end_keycCsg}| |¡|j |¡dSr)r‹rvrT)r0r…ÚarrrÚ begin_arrayYs z_PlistParser.begin_arraycCs|j ¡dSr)rvrrBrrrÚ end_array^sz_PlistParser.end_arraycCs| d¡dS)NT©r‹rBrrrÚend_trueasz_PlistParser.end_truecCs| d¡dS)NFr•rBrrrÚ end_falsedsz_PlistParser.end_falsecCs| t| ¡ƒ¡dSr)r‹rIrrBrrrÚ end_integergsz_PlistParser.end_integercCs| t| ¡ƒ¡dSr)r‹ÚfloatrrBrrrÚend_realjsz_PlistParser.end_realcCs| | ¡¡dSr)r‹rrBrrrÚ end_stringmsz_PlistParser.end_stringcCs2|jr| t| ¡ƒ¡n| t | ¡¡¡dSr)ryr‹r2rrr4rBrrrÚend_datapsz_PlistParser.end_datacCs| t| ¡ƒ¡dSr)r‹rgrrBrrrÚend_datewsz_PlistParser.end_dateN)r@rDrEr1r‚r~rr€r‹rrŽrr‘r“r”r–r—r˜ršr›rœrrrrrrus&ruc@s8eZdZddd„Zdd„Zdd„Zdd d „Zd d „Zd S)Ú_DumbXMLWriterrú cCs||_g|_||_||_dSr)ÚfilervÚ _indent_levelÚindent)r0r Ú indent_levelr¢rrrr1|sz_DumbXMLWriter.__init__cCs,|j |¡| d|¡|jd7_dS)Nz<%s>é)rvrTÚwritelnr¡©r0r„rrrÚ begin_element‚s z_DumbXMLWriter.begin_elementcCs |jd8_| d|¡dS)Nr¤z)r¡r¥r¦rrrÚ end_element‡sz_DumbXMLWriter.end_elementNcCs8|dk r&t|ƒ}| d|||f¡n| d|¡dS)Nz <%s>%sz<%s/>)rtr¥)r0r„r(rrrÚsimple_elementsz_DumbXMLWriter.simple_elementcCsH|r8t|tƒr| d¡}|j |j|j¡|j |¡|j d¡dS)Nr[ó )rrr\r Úwriter¡r¢)r0Úlinerrrr¥•s    z_DumbXMLWriter.writeln)rrŸ)N)r@rDrEr1r§r¨r©r¥rrrrrž{s   ržc@sFeZdZddd„Zdd „Zd d „Zd d „Zdd„Zdd„Zdd„Z dS)Ú _PlistWriterró r¤TFcCs.|r| t¡t ||||¡||_||_dSr)r«Ú PLISTHEADERržr1Ú _sort_keysÚ _skipkeys)r0r r£r¢Z writeHeaderr&r'rrrr1¢s  z_PlistWriter.__init__cCs"| d¡| |¡| d¡dS)Nzz)r¥Ú write_valuerŠrrrr«¬s  z_PlistWriter.writecCs4t|tƒr| d|¡n|dkr0| d¡n|dkrD| d¡nìt|tƒr‚d|krbdkrxnn| dd |¡nt|ƒ‚n®t|tƒrž| d t|ƒ¡n’t|tƒr´| |¡n|t|t ƒrÊ|  |¡nft|t t fƒrä|  |¡nLt|tjƒr| d t|ƒ¡n,t|ttfƒr | |¡ntd t|ƒƒ‚dS) NÚstringTÚtrueFZfalselûÿÿÿrGZintegerz%dÚrealÚdatezunsupported type: %s)rrr©rIÚ OverflowErrorr™rAÚdictÚ write_dictrÚ write_datar-Ú bytearrayÚ write_bytesrbriÚtupleÚlistÚ write_arrayr.rˆrŠrrrr²±s.           z_PlistWriter.write_valuecCs| |j¡dSr)r¼r*r/rrrrºÖsz_PlistWriter.write_datacCsz| d¡|jd8_tddt|j dd¡|jƒƒ}t||ƒ d¡D]}|rJ| |¡qJ|jd7_|  d¡dS)Nr*r¤ér5r®s rª) r§r¡ÚmaxrSr¢rqr6Úsplitr¥r¨)r0r*r7r¬rrrr¼Ùs þ z_PlistWriter.write_bytescCs‚|rt| d¡|jr"t| ¡ƒ}n| ¡}|D]8\}}t|tƒsP|jrHq.tdƒ‚| d|¡|  |¡q.|  d¡n | d¡dS)Nr¸úkeys must be stringsre) r§r°ÚsortedÚitemsrrr±r.r©r²r¨)r0rhrÅrer(rrrr¹æs      z_PlistWriter.write_dictcCs<|r.| d¡|D]}| |¡q| d¡n | d¡dS)NÚarray)r§r²r¨r©)r0rÆr(rrrr¿ús    z_PlistWriter.write_arrayN)rr®r¤TF) r@rDrEr1r«r²rºr¼r¹r¿rrrrr­¡sþ % r­cCsŽd}|D]}| |¡rdSqtjdftjdftjdffD]N\}}| |¡sNq:|D]4}|| d¡ |¡}|dt|ƒ…|krRdSqRq:dS)N)s6xBBQQQ)Ú_fpÚseekÚosÚSEEK_ENDÚreadrSrÚstructÚunpackÚ _ref_sizeÚ _read_intsÚ_object_offsetsÚ _undefinedÚ_objectsÚ _read_objectÚOSErrorÚ IndexErrorÚerrorr·ÚUnicodeDecodeError)r0rÚtrailerÚ offset_sizeÚ num_objectsÚ top_objectÚoffset_table_offsetrrrr‚:s*   ý    ÿ z_BinaryPlistParser.parsecCsL|dkrH|j d¡dd@}d|>}dt|}t ||j |¡¡dS|S)Nér¤rrPrn)rÝráÚ_BINARY_FORMATrârã)r0ÚtokenLrsrWr,rrrÚ _get_sizeSs  z_BinaryPlistParser._get_sizecsr|j ˆ|¡‰ˆtkr0t dtˆ|ˆ¡SˆrDtˆƒˆ|krJtƒ‚t‡‡fdd„tdˆ|ˆƒDƒƒSdS)Nrnc3s&|]}t ˆ||ˆ…d¡VqdS)ÚbigN)rIÚ from_bytes)Ú.0rY©r*ÚsizerrÚ dsÿz0_BinaryPlistParser._read_ints..r) rÝrárôrârãrSrr½rR)r0Únrûrrúrrå]sÿz_BinaryPlistParser._read_intscCs| ||j¡Sr)rårä)r0rýrrrÚ _read_refsgsz_BinaryPlistParser._read_refsc sÀˆj|}|tk r|Sˆj|}ˆj |¡ˆj d¡d}|d@|d@}}|dkr^d}nT|dkrnd}nD|dkr~d}n4|dkrŽd }n$|d krºtjˆj d|>¡d |d kd }nø|dkrÞt  dˆj d¡¡d}nÔ|dkrt  dˆj d¡¡d}n®|dkrDt  dˆj d¡¡d}t   ddd¡t j |d}nn|dkr‚ˆ  |¡}ˆj rnˆj |¡}ntˆj |¡ƒ}n0|dkr¬ˆ  |¡}ˆj |¡ d¡}n|dkr؈  |¡}ˆj |d¡ d¡}nÚ|dkrtt ˆj d|¡d ¡ƒ}n²|dkrFˆ  |¡}ˆ |¡} g}|ˆj|<| ‡fdd„| Dƒ¡nl|d kr¬ˆ  |¡}ˆ |¡} ˆ |¡} ˆ ¡}|ˆj|<t| | ƒD]\} } ˆ | ¡|ˆ | ¡<qŠntƒ‚|ˆj|<|S)!Nr¤réðrórÚFé TrQrÀr÷rP©Úsignedé"z>frOé#z>dé3éÑ)Zsecondsé@éPrÇé`rúutf-16beé€é c3s|]}ˆ |¡VqdSr)ré)rùÚxrBrrrü±sz2_BinaryPlistParser._read_object..éÐ)rèrçrærÝrÞrárIrørârãrbZ timedeltaröryrrÍr rþÚextendrzÚziprér) r0ÚrefÚresultÚoffsetÚtokenZtokenHrõr,rWZobj_refsZkey_refsÚkÚorrBrréjsv   ÿ     ÿ                 z_BinaryPlistParser._read_objectN) r@rDrEr1r‚rörårþrérrrrrÛ.s   rÛcCs0|dkr dS|dkrdS|d>d>r(dSdSdS)Nér¤érrÜrOrÚr)ÚcountrrrÚ_count_to_sizeÈs rc@s<eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd S)Ú_BinaryPlistWritercCs||_||_||_dSr)rÝr°r±)r0rr&r'rrrr1Øsz_BinaryPlistWriter.__init__c Csàg|_i|_i|_| |¡t|jƒ}dg||_t|ƒ|_t|j|_ |j   d¡|jD]}|  |¡qZ|  |¡}|j  ¡}t|ƒ}dt||}|j   tj|f|jžŽ¡d}|||j|||f} |j   tjd| žŽ¡dS)Nróbplist00rnú >5xBBBQQQ)r)Ú_objlistÚ _objtableÚ _objidtableÚ_flattenrSrærrärôÚ _ref_formatrÝr«Ú _write_objectÚ _getrefnumÚtellrâÚpack) r0r(rðÚobjrñròrïZ offset_formatZ sort_versionrîrrrr«Ýs2          þz_BinaryPlistWriter.writec Csrt|tƒr"t|ƒ|f|jkrZdSn8t|tƒrHt|jƒ|jf|jkrZdSnt|ƒ|jkrZdSt|j ƒ}|j   |¡t|tƒrŽ||jt|ƒ|f<n0t|tƒr°||jt|jƒ|jf<n||jt|ƒ<t|t ƒrHg}g}|  ¡}|j rèt|ƒ}|D]:\}}t|tƒs|jr qìtdƒ‚|  |¡|  |¡qìt ||¡D]}| |¡q4n&t|ttfƒrn|D]}| |¡q\dS)NrÃ)rÚ_scalarsrˆrrr*Úidr rSrrTr¸rÅr°rÄrr±r.Ú itertoolsÚchainr!r¾r½) r0r(ZrefnumÚkeysÚvaluesrÅrÚvrrrrr! sB           z_BinaryPlistWriter._flattencCsNt|tƒr|jt|ƒ|fSt|tƒr<|jt|jƒ|jfS|jt|ƒSdSr)rr(rrˆrr*r r)rŠrrrr$:s   z_BinaryPlistWriter._getrefnumcCs´|dkr"|j t d||B¡¡nŽ|dkrH|j t d|dBd|¡¡nh|dkrn|j t d|dBd|¡¡nB|d kr”|j t d |dBd |¡¡n|j t d |dBd |¡¡dS)Nróz>Brz>BBBrÀrz>BBHéìz>BBLéz>BBQé)rÝr«râr&)r0rrûrrrÚ _write_sizeBsz_BinaryPlistWriter._write_sizec s¢ˆ |¡}ˆj ¡ˆj|<|dkr2ˆj d¡nl|dkrJˆj d¡nT|dkrbˆj d¡nBqr2rz>BBrÀrz>BHr/r0z>BLr1lz>BQrGór÷rz>Bdrrr¤rrrÇrr r rrHr ééƒé‡csg|]}ˆ |¡‘qSr)r$)rùrrBrrÚ ™sz4_BinaryPlistWriter._write_object..r rnrÃr)$r$rÝr%rær«rrIrâr&rìr·Úto_bytesr™rbZ total_secondsrr3rSr*r-r»rr\ÚUnicodeEncodeErrorr rJr¾r½r"r¸r°rÄrÅr±r.rT) r0r(rr,ÚtZrefsrWZkeyRefsZvalRefsZ rootItemsrr.rrBrr#Rsœ                    $     "$z _BinaryPlistWriter._write_objectN) r@rDrEr1r«r!r$r3r#rrrrr×s -0rcCs|dd…dkS)NrÚrr)rÎrrrÚ_is_fmt_binary·sr>)Údetectr}ÚwriterT©r!r"r|cCsl|dkrJ| d¡}| d¡t ¡D]}|d|ƒr$|d}qVq$tƒ‚n t|d}|||d}| |¡S)NrÜrr?r})r"r|)rárÞÚ_FORMATSr-rr‚)rr!r"r|rÎÚinfoÚPÚprrrr Ís      cCst|ƒ}t||||dS)NrA)rr )r(r!r"r|rrrrr ãsÿFr%cCs:|tkrtd|fƒ‚t|d|||d}| |¡dS)NzUnsupported format: %rr@)r&r')rBrJr«)r(rr!r&r'r@rrrr ìs©r!r'r&cCs tƒ}t|||||d| ¡S)NrF)rr r+)r(r!r'r&rrrrr ÷s)r5)BÚ__all__rUrÉÚ contextlibrbÚenumÚiorr*rßÚrerâÚwarningsrZxml.parsers.expatrÚEnumr@rÚglobalsÚupdateÚ __members__Úcontextmanagerrrrrrrr r¯Úcompileror6r2ÚASCIIr_rgrirtruržr­rÓrJrrôÚobjectrçrÛrrrIr™r-r(rr>rr¸rrBr r r r rrrrÚ1s˜ý         '"ÿ    h&d! a ýýú