Your IP : 3.145.44.46


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/plistlib.cpython-39.opt-2.pyc

a

R�fXn�@s�gd�ZddlZddlZddlZddlZddlmZddlZddlZddl	Z	ddl
Z
ddlmZej
dded�Ze��ej�Gdd	�d	�Zd
Ze	�d�Zd=d
d�Zdd�Ze	�de	j�Zdd�Zdd�Zdd�ZGdd�d�ZGdd�d�ZGdd�de�Z dd�Z!Gd d!�d!e"�Z#d"d#d$d%d&�Z$e%�Z&Gd'd(�d(�Z'd)d*�Z(e)e*e+eje,fZ-Gd+d,�d,e%�Z.d-d.�Z/e0e1e!ee d/�e2e1e/e'e.d/�iZ3de1d0�d1d2�Z4de1d0�d3d4�Z5e0d5d6d7�d8d9�Z6e0d6d5d:�d;d<�Z7dS)>)�InvalidFileException�FMT_XML�
FMT_BINARY�load�dump�loads�dumps�UID�N)�BytesIO)�ParserCreate�PlistFormatzFMT_XML FMT_BINARY)�modulec@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rcCs<t|t�std��|dkr"td��|dkr2td��||_dS)Nzdata must be an int�zUIDs cannot be >= 2**64r	�UIDs must be positive)�
isinstance�int�	TypeError�
ValueError�data��selfr�r�-/opt/alt/python39/lib64/python3.9/plistlib.py�__init__Es
zUID.__init__cCs|jS�N)r�rrrr�	__index__Nsz
UID.__index__cCsd|jjt|j�fS)Nz%s(%s))�	__class__�__name__�reprrrrrr�__repr__QszUID.__repr__cCs|j|jffSr)rrrrrr�
__reduce__TszUID.__reduce__cCst|t�stS|j|jkSr)rr�NotImplementedr)r�otherrrr�__eq__Ws
z
UID.__eq__cCs
t|j�Sr)�hashrrrrr�__hash__\szUID.__hash__N)	r�
__module__�__qualname__rrr r!r$r&rrrrrDs	rs�<?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]�LcCsP|dd}g}tdt|�|�D]$}||||�}|�t�|��q d�|�S)N��r	�)�range�len�append�binasciiZ
b2a_base64�join)�s�
maxlinelengthZ
maxbinsize�pieces�i�chunkrrr�_encode_base64psr7cCs(t|t�rt�|�d��St�|�SdS)N�utf-8)r�strr0Z
a2b_base64�encode)r2rrr�_decode_base64ys
r;z{(?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]&}||}|dur2qB|�t|��qtj|�S)N�ZyearZmonthZdayZhourZminute�second)�_dateParser�match�	groupdictr/r�datetime)r2�orderZgdZlst�key�valrrr�_date_from_string�srEcCs d|j|j|j|j|j|jfS)Nz%04d-%02d-%02dT%02d:%02d:%02dZr<)�drrr�_date_to_string�s�rGcCsZt�|�}|durtd��|�dd�}|�dd�}|�dd�}|�dd�}|�d	d
�}|S)Nz<strings can't contains control characters; use bytes insteadz
�
�
�&z&amp;�<z&lt;�>z&gt;)�_controlCharPat�searchr�replace)�text�mrrr�_escape�s
rRc@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)*�_PlistParsercCsg|_d|_d|_||_dSr)�stack�current_key�root�
_dict_type�r�	dict_typerrrr�sz_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	ParseFilerV)rZfileobjrrr�parse�s



z_PlistParser.parsecCstd��dS)Nz8XML entity declarations are not supported in plist files)r)rZentity_nameZis_parameter_entity�value�baseZ	system_idZ	public_idZ
notation_namerrrr^�sz_PlistParser.handle_entity_declcCs*g|_t|d|d�}|dur&||�dS)NZbegin_)r�getattr)r�element�attrs�handlerrrrr[�sz!_PlistParser.handle_begin_elementcCs"t|d|d�}|dur|�dS)NZend_)rb)rrcrerrrr\�sz_PlistParser.handle_end_elementcCs|j�|�dSr)rr/rrrrr]�sz_PlistParser.handle_datacCs�|jdurFt|jdti��s.td|jj��||jd|j<d|_nB|jsT||_n4t|jdtg��sxtd|jj��|jd�|�dS)N���zunexpected element at line %d)	rUrrT�typerrZ�CurrentLineNumberrVr/�rr`rrr�
add_object�s
��z_PlistParser.add_objectcCsd�|j�}g|_|S)N�)r1rrrrr�get_data�sz_PlistParser.get_datacCs"|��}|�|�|j�|�dSr)rWrjrTr/)rrdrFrrr�
begin_dict�s
z_PlistParser.begin_dictcCs*|jrtd|j|jjf��|j��dS)Nz%missing value for key '%s' at line %d)rUrrZrhrT�poprrrr�end_dict�s
�z_PlistParser.end_dictcCs8|jst|jdti��s*td|jj��|��|_dS)Nrfzunexpected key at line %d)rUrrTrgrrZrhrlrrrr�end_key�s
�z_PlistParser.end_keycCsg}|�|�|j�|�dSr)rjrTr/)rrd�arrr�begin_array�s
z_PlistParser.begin_arraycCs|j��dSr)rTrnrrrr�	end_array�sz_PlistParser.end_arraycCs|�d�dS)NT�rjrrrr�end_true�sz_PlistParser.end_truecCs|�d�dS)NFrtrrrr�	end_false�sz_PlistParser.end_falsecCs@|��}|�d�s|�d�r.|�t|d��n|�t|��dS)NZ0xZ0X�)rl�
startswithrjr)r�rawrrr�end_integer�sz_PlistParser.end_integercCs|�t|����dSr)rj�floatrlrrrr�end_realsz_PlistParser.end_realcCs|�|���dSr)rjrlrrrr�
end_stringsz_PlistParser.end_stringcCs|�t|����dSr)rjr;rlrrrr�end_datasz_PlistParser.end_datacCs|�t|����dSr)rjrErlrrrr�end_datesz_PlistParser.end_dateN)rr'r(rr_r^r[r\r]rjrlrmrorprrrsrurvrzr|r}r~rrrrrrS�s(	rSc@s8eZdZddd�Zdd�Zdd�Zdd
d�Zdd
�Zd	S)�_DumbXMLWriterr	�	cCs||_g|_||_||_dSr)�filerT�
_indent_level�indent)rr��indent_levelr�rrrrsz_DumbXMLWriter.__init__cCs,|j�|�|�d|�|jd7_dS)Nz<%s>�)rTr/�writelnr��rrcrrr�
begin_elementsz_DumbXMLWriter.begin_elementcCs |jd8_|�d|�dS)Nr�z</%s>)r�r�r�rrr�end_elementsz_DumbXMLWriter.end_elementNcCs8|dur&t|�}|�d|||f�n|�d|�dS)Nz<%s>%s</%s>z<%s/>)rRr�)rrcr`rrr�simple_element$sz_DumbXMLWriter.simple_elementcCsH|r8t|t�r|�d�}|j�|j|j�|j�|�|j�d�dS)Nr8�
)rr9r:r��writer�r�)r�linerrrr�,s

z_DumbXMLWriter.writeln)r	r�)N)rr'r(rr�r�r�r�rrrrr�s


r�c@s>eZdZddd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)�_PlistWriterr	�	r�TFcCs.|r|�t�t�||||�||_||_dSr)r��PLISTHEADERr�r�
_sort_keys�	_skipkeys)rr�r�r�ZwriteHeader�	sort_keys�skipkeysrrrr9s

z_PlistWriter.__init__cCs"|�d�|�|�|�d�dS)Nz<plist version="1.0">z</plist>)r��write_valuerirrrr�Cs

z_PlistWriter.writecCst|t�r|�d|�n�|dur,|�d�n�|dur@|�d�n�t|t�r~d|kr^dkrtnn|�dd	|�nt|��n�t|t�r�|�d
t|��nzt|t�r�|�|�ndt|t	t
f�r�|�|�nJt|tj�r�|�dt
|��n,t|ttf��r|�|�ntdt|���dS)
N�stringT�trueFZfalsel����rZintegerz%d�real�datezunsupported type: %s)rr9r�r�
OverflowErrorr{r�dict�
write_dict�bytes�	bytearray�write_bytesrArG�tuple�list�write_arrayrrgrirrrr�Hs*




z_PlistWriter.write_valuecCsz|�d�|jd8_tddt|j�dd�|j��}t||��d�D]}|rJ|�|�qJ|jd7_|�	d�dS)Nrr�rwr)r�s        r�)
r�r��maxr.r�rOr7�splitr�r�)rrr3r�rrrr�js
�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 stringsrC)r�r��sorted�itemsrr9r�rr�r�r�)rrFr�rCr`rrrr�ws

z_PlistWriter.write_dictcCs<|r.|�d�|D]}|�|�q|�d�n
|�d�dS)N�array)r�r�r�r�)rr�r`rrrr��s
z_PlistWriter.write_arrayN)r	r�r�TF)	rr'r(rr�r�r�r�r�rrrrr�8s�

"
r�cCs�d}|D]}|�|�rdSqtjdftjdftjdffD]N\}}|�|�sNq:|D]4}||�d��|�}|dt|��|krRdSqRq:dS)N)s<?xmls<plistTr8z	utf-16-bez	utf-16-le�asciiF)rx�codecs�BOM_UTF8�BOM_UTF16_BE�BOM_UTF16_LE�decoder:r.)�header�prefixesZpfxZbom�encoding�start�prefixrrr�_is_fmt_xml�s
�
r�c@seZdZddd�ZdS)r�Invalid filecCst�||�dSr)rr)r�messagerrrr�szInvalidFileException.__init__N)r�)rr'r(rrrrrr�sr�B�H�L�Q)r��r*�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_BinaryPlistParsercCs
||_dSr)rWrXrrrr�sz_BinaryPlistParser.__init__cCs�z~||_|j�dtj�|j�d�}t|�dkr6t��t�d|�\}|_	}}}|j�|�|�
||�|_tg||_
|�|�WStttjttfy�t��Yn0dS)Ni��� z>6xBBQQQ)�_fp�seek�os�SEEK_END�readr.r�struct�unpack�	_ref_size�
_read_ints�_object_offsets�
_undefined�_objects�_read_object�OSError�
IndexError�errorr�r)r�fp�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�r	r+rL)r�r��_BINARY_FORMATr�r�)r�tokenLrQr2�frrr�	_get_size�sz_BinaryPlistParser._get_sizecst|j��|���tvr2t�d|�t�����S�rFt���|krLt��t��fdd�td�|��D��SdS)NrLc3s&|]}t��||��d�VqdS)�bigN)r�
from_bytes)�.0r5�r�sizerr�	<genexpr>�s�z0_BinaryPlistParser._read_ints.<locals>.<genexpr>r	)	r�r�r�r�r�r.rr�r-)r�nr�rr�rr��s�z_BinaryPlistParser._read_intscCs|�||j�Sr)r�r�)rr�rrr�
_read_refs�sz_BinaryPlistParser._read_refscs
�j|}|tur|S�j|}�j�|��j�d�d}|d@|d@}}|dkr^d}�n�|dkrnd}�n�|dkr~d}�n~|dkr�d	}�nn|d
kr�tj�j�d|>�d|dkd
�}�nB|dkr�t�	d�j�d��d}�n|dk�rt�	d�j�d��d}�n�|dk�rDt�	d�j�d��d}t
�
ddd�t
j|d�}�n�|dk�r|��|�}�j�|�}t
|�|k�r�t���n�|dk�r���|�}�j�|�}	t
|	�|k�r�t��|	�d�}�n>|dk�r��|�d}�j�|�}	t
|	�|k�r�t��|	�d�}n�|dk�r*tt��j�d|�d��}n�|dk�rp��|�}��|�}
g}|�j|<|��fdd�|
D��n�|d k�r���|�}��|�}��|�}
���}|�j|<z.t||
�D]\}}
��|
�|��|�<�q�Wnt�y�t��Yn0nt��|�j|<|S)!Nr�r	��r�r�F�	Tr,rwr�r+�Zsigned�"z>fr*�#z>d�3��)Zseconds�@�Pr��`r��utf-16be��c3s|]}��|�VqdSr)r�)r��xrrrr�Fr,z2_BinaryPlistParser._read_object.<locals>.<genexpr>��)r�r�r�r�r�r�rr�r�r�rAZ	timedeltar�r.rr�rr��extendrW�zipr�r)r�ref�result�offset�tokenZtokenHr�r�r2rZobj_refsZkey_refs�k�orrrr��s�

�



�
















z_BinaryPlistParser._read_objectN)	rr'r(rr_r�r�r�r�rrrrr��s

r�cCs,|dkrdS|dkrdS|dkr$dSdSdS)N�r��r��r*r�r)�countrrr�_count_to_size_sr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_BinaryPlistWritercCs||_||_||_dSr)r�r�r�)rr�r�r�rrrrosz_BinaryPlistWriter.__init__c
Cs�g|_i|_i|_|�|�t|j�}dg||_t|�|_t|j|_	|j
�d�|jD]}|�|�qZ|�
|�}|j
��}t|�}dt||}|j
�tj|g|j�R��d}|||j|||f}	|j
�tjdg|	�R��dS)Nr	�bplist00rLz	>5xBBBQQQ)�_objlist�	_objtable�_objidtable�_flattenr.r�r�r�r��_ref_formatr�r��
_write_object�
_getrefnum�tellr��pack)
rr`r��objr�r�r�Z
offset_formatZsort_versionr�rrrr�ts*






�z_BinaryPlistWriter.writec	Cs"t|t�r"t|�|f|jvr4dSnt|�|jvr4dSt|j�}|j�|�t|t�rh||jt|�|f<n||jt|�<t|t	�r�g}g}|�
�}|jr�t|�}|D]6\}}t|t
�s�|jr�q�td��|�|�|�|�q�t�||�D]}|�|�q�n&t|ttf��r|D]}|�|��qdS)Nr�)r�_scalarsrgr�idrr.rr/r�r�r�r�r9r�r�	itertools�chainrr�r�)	rr`Zrefnum�keys�valuesr�r��vr�rrrr�s8





z_BinaryPlistWriter._flattencCs.t|t�r|jt|�|fS|jt|�SdSr)rrrrgrrrirrrr�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>Br�z>BBBrwr�z>BBH�r�z>BBL�z>BBQ�)r�r�r�r	)rr�r�rrr�_write_size�sz_BinaryPlistWriter._write_sizecst��|�}�j���j|<|dur2�j�d��n>|durJ�j�d��n&|durb�j�d��nt|t��rj|dkr�z�j�t�dd|��Wntj	y�t
|�d�Yn0n�|d	kr҈j�t�d
d|��n�|dkr�j�t�d
d|��nt|dk�r�j�t�dd|��nR|dk�r6�j�t�dd|��n0|dk�r^�j�d|jdddd��nt
|���nt|t��r��j�t�dd|���n�t|t
j
��r�|t
�
ddd���}�j�t�dd|���n�t|ttf��r���dt|���j�|��nrt|t��rlz|�d�}��dt|��Wn2t�yZ|�d �}��d!t|�d"�Yn0�j�|��nt|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�r�j�t�dd'|��nt
|���nFt|ttf��r��fd(d)�|D�}t|�}��d*|��j�tjd+�j|g|�R��n�t|t��rhgg}}�j�r�t|���}	n|��}	|	D]J\}
}t|
t��s�j �rސq�t!d,��|�"��|
��|�"��|���q�t|�}��d-|��j�tjd+�j|g|�R���j�tjd+�j|g|�R��nt!|��dS).N�F�Tr�r	z>Bqrr�z>BBrwr�z>BHrr�z>BLrlz>BQr�r�r�z>Bdr�r�r�r�r�r�r�r�r�r�rr����csg|]}��|��qSr)r)r�r�rrr�
<listcomp>$r,z4_BinaryPlistWriter._write_object.<locals>.<listcomp>r�rLr�r�)#rr�rr�r�rrr�r	r�r��to_bytesr{rAZ
total_secondsr�r�rr.r9r:�UnicodeEncodeErrorrrrr�r�rr�r�r�r�r�rr/)rr`r�r��tZrefsr2ZkeyRefsZvalRefsZ	rootItemsr�rrrrr�s�






&
$&z _BinaryPlistWriter._write_objectN)	rr'r(rr�rrrrrrrrr�ns-*r�cCs|dd�dkS)Nr�rr)r�rrr�_is_fmt_binaryBsr )�detectrZ�writer��fmtrYcCsj|durJ|�d�}|�d�t��D]}|d|�r$|d}qVq$t��nt|d}||d�}|�|�S)Nr�r	r!rZ)rY)r�r��_FORMATSrrr_)r�r$rYr��info�P�prrrrXs


rcCst|�}t|||d�S)Nr#)r
r)r`r$rYr�rrrrnsrTF)r$r�r�cCs:|tvrtd|f��t|d|||d�}|�|�dS)NzUnsupported format: %rr")r�r�)r%rr�)r`r�r$r�r�r"rrrrvsr�r$r�r�cCs t�}t|||||d�|��S)Nr))r
r�getvalue)r`r$r�r�r�rrrr�sr)r))8�__all__r0r�rA�enum�ior
r
r��rer�Zxml.parsers.expatr�Enumrr�globals�update�__members__rr��compilerMr7r;�ASCIIr>rErGrRrSr�r�r�rrr��objectr�r�r�r9rr{r�rr�r rr�rr%rrrrrrrr�<module>0sh!�
	
n&^!!
U	���

?>