Your IP : 18.116.15.124


Current Path : /lib64/python3.8/__pycache__/
Upload File :
Current File : //lib64/python3.8/__pycache__/plistlib.cpython-38.opt-2.pyc

U

e5d�}�
@s:dddddddddd	d
ddg
Zd
dlZd
dlZd
dlZd
dlZd
dlZd
dlmZd
dlZd
dl	Z	d
dl
Z
d
dlZd
dlm
Z
d
dlmZejdded�Ze��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*dA�e<e;e9e1e8dA�iZ=ddBe;dC�dDd�Z>ddBe;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|ddd�W5QR�SQRXdS)Nz8The readPlist function is deprecated, use load() instead��rbF��fmt�use_builtin_types)r�DeprecationWarningrr	)rrrrrrYs�c	Cs8tdtd�t|d��}t||tddd�W5QRXdS)Nz9The writePlist function is deprecated, use dump() insteadr�wbTF�r!�	sort_keys�skipkeys)rr#rr
r)�valuerrrrrrfs�cCstdtd�tt|�ddd�S)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�asBase64�sz
Data.asBase64cCs4t||j�r|j|jkSt|t�r,|j|kStSdSr)r�	__class__r*r-�NotImplemented�r0�otherrrr�__eq__�s


zData.__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
�Zdd�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�<?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">
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<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}t�|���}g}|D]&}||}|dkr2qB|�t|��qtj|�S)N�ZyearZmonthZdayZhourZminute�second)�_dateParser�match�	groupdictrTrI�datetime)rW�orderZgdZlst�key�valrrr�_date_from_string�srfcCs d|j|j|j|j|j|jfS)Nz%04d-%02d-%02dT%02d:%02d:%02dZr])�drrr�_date_to_strings�rhcCsZt�|�}|dk	rtd��|�dd�}|�dd�}|�dd�}|�dd�}|�d	d
�}|S)Nz<strings can't contains control characters; use bytes insteadz
�
�
�&z&amp;�<z&lt;�>z&gt;)�_controlCharPat�searchrJ�replace)�text�mrrr�_escapes
rsc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�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__cCsBt�|_|j|j_|j|j_|j|j_|j|j_	|j�
|�|jSr)r�parser�handle_begin_elementZStartElementHandler�handle_end_elementZEndElementHandler�handle_dataZCharacterDataHandler�handle_entity_declZEntityDeclHandlerZ	ParseFilerw)r0Zfileobjrrr�parses



z_PlistParser.parsecCstd��dS)Nz8XML entity declarations are not supported in plist files)r)r0Zentity_nameZis_parameter_entityr(�baseZ	system_idZ	public_idZ
notation_namerrrr�$sz_PlistParser.handle_entity_declcCs*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~0sz_PlistParser.handle_end_elementcCs|j�|�dSr)r*rTr/rrrr5sz_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)	rvrru�typerJr|�CurrentLineNumberrwrT�r0r(rrr�
add_object8s
��z_PlistParser.add_objectcCsd�|j�}g|_|S)N�)rVr*r/rrr�get_dataHsz_PlistParser.get_datacCs"|��}|�|�|j�|�dSr)ryr�rurT)r0r�rgrrr�
begin_dictOs
z_PlistParser.begin_dictcCs*|jrtd|j|jjf��|j��dS)Nz%missing value for key '%s' at line %d)rvrJr|r�ru�poprBrrr�end_dictTs
�z_PlistParser.end_dictcCs8|jst|jdti��s*td|jj��|��|_dS)Nr�zunexpected key at line %d)rvrrur�rJr|r�r�rBrrr�end_keyZs
�z_PlistParser.end_keycCsg}|�|�|j�|�dSr)r�rurT)r0r��arrr�begin_array`s
z_PlistParser.begin_arraycCs|j��dSr)rur�rBrrr�	end_arrayesz_PlistParser.end_arraycCs|�d�dS)NT�r�rBrrr�end_truehsz_PlistParser.end_truecCs|�d�dS)NFr�rBrrr�	end_falseksz_PlistParser.end_falsecCs@|��}|�d�s|�d�r.|�t|d��n|�t|��dS)NZ0xZ0X�)r��
startswithr�rI)r0�rawrrr�end_integernsz_PlistParser.end_integercCs|�t|����dSr)r��floatr�rBrrr�end_realusz_PlistParser.end_realcCs|�|���dSr)r�r�rBrrr�
end_stringxsz_PlistParser.end_stringcCs2|jr|�t|����n|�t�|����dSr)rxr�r2r�rr4rBrrr�end_data{sz_PlistParser.end_datacCs|�t|����dSr)r�rfr�rBrrr�end_date�sz_PlistParser.end_dateN)r@rDrEr1r�r�r}r~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrts(	rtc@s8eZdZddd�Zdd�Zdd�Zdd
d�Zdd
�Zd	S)�_DumbXMLWriterr�	cCs||_g|_||_||_dSr)�fileru�
_indent_level�indent)r0r��indent_levelr�rrrr1�sz_DumbXMLWriter.__init__cCs,|j�|�|�d|�|jd7_dS)Nz<%s>�)rurT�writelnr��r0r�rrr�
begin_element�sz_DumbXMLWriter.begin_elementcCs |jd8_|�d|�dS)Nr�z</%s>)r�r�r�rrr�end_element�sz_DumbXMLWriter.end_elementNcCs8|dk	r&t|�}|�d|||f�n|�d|�dS)Nz<%s>%s</%s>z<%s/>)rsr�)r0r�r(rrr�simple_element�sz_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�ZwriteHeaderr&r'rrrr1�s

z_PlistWriter.__init__cCs"|�d�|�|�|�d�dS)Nz<plist version="1.0">z</plist>)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|ttf�r�|�
|�nLt|tj��r|�dt|��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_bytesrbrh�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�r�r5r�s        r�)
r�r��maxrSr�rpr6�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 stringsrd)r�r��sorted�itemsrrr�r.r�r�r�)r0rgr�rdr(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)s<?xmls<plistTr[z	utf-16-bez	utf-16-le�asciiF)r��codecs�BOM_UTF8�BOM_UTF16_BE�BOM_UTF16_LE�decoder\rS)�header�prefixesZpfxZbom�encoding�start�prefixrrr�_is_fmt_xmls
�
r�c@seZdZddd�ZdS)r�Invalid filecCst�||�dSr)rJr1)r0�messagerrrr12szInvalidFileException.__init__N)r�)r@rDrEr1rrrrr1s�B�H�L�Q)r�rrO�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_BinaryPlistParsercCs||_||_dSr)rxryrzrrrr1Asz_BinaryPlistParser.__init__cCs�z~||_|j�dtj�|j�d�}t|�dkr6t��t�d|�\}|_	}}}|j�|�|�
||�|_tg||_
|�|�WStttjttfk
r�t��YnXdS)Ni��� z>6xBBQQQ)�_fp�seek�os�SEEK_END�readrSr�struct�unpack�	_ref_size�
_read_ints�_object_offsets�
_undefined�_objects�_read_object�OSError�
IndexError�errorr�rJ)r0r�trailer�offset_size�num_objects�
top_object�offset_table_offsetrrrr�Es*
��z_BinaryPlistParser.parsecCsL|dkrH|j�d�dd@}d|>}dt|}t�||j�|��dS|S)N�r�rrPrm)r�r��_BINARY_FORMATr�r�)r0�tokenLrrrWr,rrr�	_get_size^sz_BinaryPlistParser._get_sizecst|j��|���tkr2t�d|�t�����S�rFt���|krLt��t��fdd�td�|��D��SdS)Nrmc3s&|]}t��||��d�VqdS)�bigN)rI�
from_bytes)�.0rY�r*�sizerr�	<genexpr>os�z0_BinaryPlistParser._read_ints.<locals>.<genexpr>r)	r�r�r�r�r�rSrr�rR)r0�nr�rr�rr�hs�z_BinaryPlistParser._read_intscCs|�||j�Sr)r�r�)r0r�rrr�
_read_refsrsz_BinaryPlistParser._read_refscs�j|}|tk	r|S�j|}�j�|��j�d�d}|d@|d@}}|dkr^d}�n�|dkrnd}�n�|dkr~d}�n�|dkr�d	}�n�|d
kr�tj�j�d|>�d|dkd
�}�nT|dkr�t�	d�j�d��d}�n0|dk�rt�	d�j�d��d}�n
|dk�rDt�	d�j�d��d}t
�
ddd�t
j|d�}�n�|dk�r���|�}�j�|�}t
|�|k�rxt���j�st|�}�n�|dk�rΈ�|�}�j�|�}	t
|	�|k�r�t��|	�d�}�n@|dk�r��|�d}�j�|�}	t
|	�|k�rt��|	�d�}n�|dk�r:tt��j�d|�d��}n�|dk�r���|�}��|�}
g}|�j|<|��fdd�|
D��n�|d k�r��|�}��|�}��|�}
���}|�j|<z.t||
�D]\}}
��|
�|��|�<�q�Wntk
�rt��YnXnt��|�j|<|S)!Nr�r��r�r�F�	TrQr�r�rP�Zsigned�"z>frO�#z>d�3��)Zseconds�@�Pr��`r�utf-16be��c3s|]}��|�VqdSr)r�)r��xrBrrr��sz2_BinaryPlistParser._read_object.<locals>.<genexpr>��)r�r�r�r�r�r�rIr�r�r�rbZ	timedeltar�rSrrxrr�r
r��extendry�zipr�r.)r0�ref�result�offset�tokenZtokenHr�r,rWr*Zobj_refsZkey_refs�k�orrBrr�us�

�



�















z_BinaryPlistParser._read_objectN)	r@rDrEr1r�r�r�r�r�rrrrr�9s

r�cCs,|dkrdS|dkrdS|dkr$dSdSdS)N�r��r�rOr�r)�countrrr�_count_to_size�src@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�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�bplist00rm�	>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|j�r
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$Ns


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�rz>BBL�z>BBQ�)r�r�r�r&)r0rr�rrr�_write_sizeVsz_BinaryPlistWriter._write_sizecs���|�}�j���j|<|dkr2�j�d��nl|dkrJ�j�d��nT|dkrb�j�d��n<t|t��rl|dkr�z�j�t�dd|��Wn tj	k
r�t
|�d�YnXn�|d	krԈj�t�d
d|��n�|dkr�j�t�d
d|��nt|dk�r�j�t�dd|��nR|dk�r8�j�t�dd|��n0|dk�r`�j�d|jdddd��nt
|���n2t|t��r��j�t�dd|���nt|t
j
��r�|t
�
ddd���}�j�t�dd|���n�t|t��r��dt|j���j�|j��n�t|ttf��r0��dt|���j�|��nnt|t��r�z|�d�}��dt|��Wn4tk
�r�|�d �}��d!t|�d"�YnX�j�|��n�t|t��r^|jdk�r�td#��n�|jd	k�r�j�t�d
d$|��nt|jdk�r
�j�t�d
d%|��nP|jdk�r.�j�t�dd&|��n,|jdk�rR�j�t�dd'|��nt
|���n@t|ttf��r��fd(d)�|D�}t|�}��d*|��j�tjd+�j|f|���n�t|t��r�gg}}�j�r�t|� ��}	n|� �}	|	D]J\}
}t|
t��s�j!�r�q�t"d,��|�#��|
��|�#��|���q�t|�}��d-|��j�tjd+�j|f|����j�tjd+�j|f|���nt"|��dS).N�F�Tr�rz>Bqr1rz>BBr�rz>BHr/rz>BLr0lz>BQrG�r�rz>Bdrrr�rrr�rr	rrrHr
���csg|]}��|��qSr)r$)r�rrBrr�
<listcomp>�sz4_BinaryPlistWriter._write_object.<locals>.<listcomp>rrmr�r
)$r$r�r%r�r�rrIr�r&r�r��to_bytesr�rbZ
total_secondsrr2rSr*r-r�rr\�UnicodeEncodeErrorr
rJr�r�r"r�r�r�r�r�r.rT)r0r(rr,�tZrefsrWZkeyRefsZvalRefsZ	rootItemsrr.rrBrr#fs�






$
"$z _BinaryPlistWriter._write_objectN)	r@rDrEr1r�r!r$r2r#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||||d�S)Nr@)rr	)r(r!r"r{rrrrr�s�Fr%cCs:|tkrtd|f��t|d|||d�}|�|�dS)NzUnsupported format: %rr?)r&r')rArJr�)r(rr!r&r'r?rrrr
s�r!r'r&cCs t�}t|||||d�|��S)NrE)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��compilernr6r2�ASCIIr_rfrhrsrtr�r�r�rJrr��objectr�r�rrrIr�r-r(rr=rr�rrAr	rr
rrrrr�<module>1s��

	


'"�
	
s&d!$
a	���	

?>