Your IP : 52.15.42.61


Current Path : /opt/alt/python36/lib64/python3.6/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/__pycache__/plistlib.cpython-36.opt-2.pyc

3

��2a��@s^dddddddddd	d
ddd
gZddlZddlZddlZddlZddlZddlmZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZejdded�Ze�jej�Gdd�de�ZGdd�de�Zejdd��ZGdd�de�Zdd�Zdd�Zdd�Zdd�ZGd d�d�Z d!Z!e
j"d"�Z#dOd$d%�Z$d&d'�Z%e
j"d(e
j&�Z'd)d*�Z(d+d,�Z)d-d.�Z*Gd/d0�d0�Z+Gd1d2�d2�Z,Gd3d4�d4e,�Z-d5d6�Z.Gd7d�de/�Z0d8d9d:d;d<�Z1e2�Z3Gd=d>�d>�Z4d?d@�Z5e6e7e8eje9fZ:GdAdB�dBe2�Z;dCdD�Z<e=ee.e+e-dE�e>ee<e4e;dE�iZ?ddFedG�dHd
�Z@ddFedG�dId�ZAe=dFdJdK�dLd�ZBe=dJdFdM�dNd
�ZCdS)P�	readPlist�
writePlist�readPlistFromBytes�writePlistToBytes�Plist�Data�Dict�InvalidFileException�FMT_XML�
FMT_BINARY�load�dump�loads�dumps�N)�BytesIO)�warn)�ParserCreate�PlistFormatzFMT_XML FMT_BINARY)�modulec@s(eZdZfZdd�Zdd�Zdd�ZdS)�
_InternalDictcCs:y||}Wntk
r(t|��YnXtdtd�|S)NzLAttribute access from plist dicts is deprecated, use d[key] notation instead�)�KeyError�AttributeErrorr�DeprecationWarning)�self�attr�value�r�-/opt/alt/python36/lib64/python3.6/plistlib.py�__getattr__Vsz_InternalDict.__getattr__cCstdtd�|||<dS)NzLAttribute access from plist dicts is deprecated, use d[key] notation insteadr)rr)rrrrrr�__setattr___sz_InternalDict.__setattr__cCs8y
||=Wntk
r&t|��YnXtdtd�dS)NzLAttribute access from plist dicts is deprecated, use d[key] notation insteadr)rrrr)rrrrr�__delattr__ds
z_InternalDict.__delattr__N)�__name__�
__module__�__qualname__�	__slots__rr r!rrrrrOs	rcseZdZ�fdd�Z�ZS)rcstdtd�t�jf|�dS)Nz?The plistlib.Dict class is deprecated, use builtin dict insteadr)rr�super�__init__)r�kwargs)�	__class__rrr'osz
Dict.__init__)r"r#r$r'�
__classcell__rr)r)rrmsc	cs2t|t�r(t||��}|VWdQRXn|VdS)N)�
isinstance�str�open)�
pathOrFile�mode�fprrr�_maybe_openus
r1cs0eZdZ�fdd�Zedd��Zdd�Z�ZS)rcstdtd�t�jf|�dS)NzJThe Plist class is deprecated, use the load() and dump() functions insteadr)rrr&r')rr()r)rrr'�szPlist.__init__c	Cs2t|d��}t|�}WdQRX|�}|j|�|S)N�rb)r1r�update)�clsr.r0rZplistrrr�fromFile�s

zPlist.fromFilec
Cs$t|d��}t||�WdQRXdS)N�wb)r1r)rr.r0rrr�write�szPlist.write)r"r#r$r'�classmethodr5r7r*rr)r)rrs	c
Cs2tdtd�t|d��}t|ddtd�SQRXdS)Nz8The readPlist function is deprecated, use load() insteadrr2F)�fmt�use_builtin_types�	dict_type)rrr1rr)r.r0rrrr�s
cCs8tdtd�t|d��}t||tddd�WdQRXdS)Nz9The writePlist function is deprecated, use dump() insteadrr6TF)r9�	sort_keys�skipkeys)rrr1rr	)rr.r0rrrr�scCs tdtd�tt|�ddtd�S)NzBThe readPlistFromBytes function is deprecated, use loads() insteadrF)r9r:r;)rrrrr)�datarrrr�scCs,tdtd�t�}t||tddd�|j�S)NzAThe writePlistToBytes function is deprecated, use dumps() insteadrTF)r9r<r=)rrrr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>)rr>rrrr'�s
z
Data.__init__cCs|t|��S)N)�_decode_base64)r4r>rrr�
fromBase64�szData.fromBase64�LcCst|j|�S)N)�_encode_base64r>)r�
maxlinelengthrrr�asBase64�sz
Data.asBase64cCs4t||j�r|j|jkSt|t�r,|j|kStSdS)N)r+r)r>rA�NotImplemented)r�otherrrr�__eq__�s


zData.__eq__cCsd|jjt|j�fS)Nz%s(%s))r)r"�reprr>)rrrr�__repr__�sz
Data.__repr__N)rE)	r"r#r$r'r8rDrHrKrMrrrrr�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]rEcCsT|dd}g}x8tdt|�|�D]$}||||�}|jtj|��q"Wdj|�S)N��r�)�range�len�append�binasciiZ
b2a_base64�join)�srGZ
maxbinsize�pieces�i�chunkrrrrFsrFcCs(t|t�rtj|jd��Stj|�SdS)Nzutf-8)r+r,rTZ
a2b_base64�encode)rVrrrrC
s
rCz{(?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))?)?)?)?)?ZcCsNd}tj|�j�}g}x,|D]$}||}|dkr2P|jt|��qWtj|�S)N�year�month�day�hour�minute�second)r[r\r]r^r_r`)�_dateParser�match�	groupdictrS�int�datetime)rV�order�gdZlst�key�valrrr�_date_from_strings
rjcCs d|j|j|j|j|j|jfS)Nz%04d-%02d-%02dT%02d:%02d:%02dZ)r[r\r]r^r_r`)�drrr�_date_to_string&srlcCsZtj|�}|dk	rtd��|jdd�}|jdd�}|jdd�}|jdd�}|jd	d
�}|S)Nz<strings can't contains control characters; use bytes insteadz
�
�
�&z&amp;�<z&lt;�>z&gt;)�_controlCharPat�search�
ValueError�replace)�text�mrrr�_escape,s
rxc@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|_||_||_dS)N)�stack�current_key�root�_use_builtin_types�
_dict_type)rr:r;rrrr'9s
z_PlistParser.__init__cCsBt�|_|j|j_|j|j_|j|j_|j|j_	|jj
|�|jS)N)r�parser�handle_begin_elementZStartElementHandler�handle_end_elementZEndElementHandler�handle_dataZCharacterDataHandler�handle_entity_declZEntityDeclHandlerZ	ParseFiler|)rZfileobjrrr�parse@s



z_PlistParser.parsecCstd��dS)Nz8XML entity declarations are not supported in plist files)r)rZentity_nameZis_parameter_entityr�baseZ	system_idZ	public_idZ
notation_namerrrr�Isz_PlistParser.handle_entity_declcCs*g|_t|d|d�}|dk	r&||�dS)NZbegin_)r>�getattr)r�element�attrs�handlerrrrr�Osz!_PlistParser.handle_begin_elementcCs"t|d|d�}|dk	r|�dS)NZend_)r�)rr�r�rrrr�Usz_PlistParser.handle_end_elementcCs|jj|�dS)N)r>rS)rr>rrrr�Zsz_PlistParser.handle_datacCs�|jdk	rFt|jdti��s.td|jj��||jd|j<d|_nB|jsT||_n4t|jdtg��sxtd|jj��|jdj|�dS)N�zunexpected element at line %d���r�r�r�)	r{r+rz�typertr�CurrentLineNumberr|rS)rrrrr�
add_object]s
z_PlistParser.add_objectcCsdj|j�}g|_|S)N�)rUr>)rr>rrr�get_datamsz_PlistParser.get_datacCs"|j�}|j|�|jj|�dS)N)r~r�rzrS)rr�rkrrr�
begin_dictts
z_PlistParser.begin_dictcCs*|jrtd|j|jjf��|jj�dS)Nz%missing value for key '%s' at line %d)r{rtrr�rz�pop)rrrr�end_dictysz_PlistParser.end_dictcCs:|jst|jdti��r,td|jj��|j�|_dS)Nr�zunexpected key at line %dr�)r{r+rzr�rtrr�r�)rrrr�end_keysz_PlistParser.end_keycCsg}|j|�|jj|�dS)N)r�rzrS)rr��arrr�begin_array�s
z_PlistParser.begin_arraycCs|jj�dS)N)rzr�)rrrr�	end_array�sz_PlistParser.end_arraycCs|jd�dS)NT)r�)rrrr�end_true�sz_PlistParser.end_truecCs|jd�dS)NF)r�)rrrr�	end_false�sz_PlistParser.end_falsecCs|jt|j���dS)N)r�rdr�)rrrr�end_integer�sz_PlistParser.end_integercCs|jt|j���dS)N)r��floatr�)rrrr�end_real�sz_PlistParser.end_realcCs|j|j��dS)N)r�r�)rrrr�
end_string�sz_PlistParser.end_stringcCs2|jr|jt|j���n|jtj|j���dS)N)r}r�rCr�rrD)rrrr�end_data�sz_PlistParser.end_datacCs|jt|j���dS)N)r�rjr�)rrrr�end_date�sz_PlistParser.end_dateN)r"r#r$r'r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrry8s(	ryc@s8eZdZddd�Zdd�Zdd�Zdd
d�Zdd
�Zd	S)�_DumbXMLWriterr�	cCs||_g|_||_||_dS)N)�filerz�
_indent_level�indent)rr��indent_levelr�rrrr'�sz_DumbXMLWriter.__init__cCs,|jj|�|jd|�|jd7_dS)Nz<%s>r�)rzrS�writelnr�)rr�rrr�
begin_element�sz_DumbXMLWriter.begin_elementcCs |jd8_|jd|�dS)Nr�z</%s>)r�r�)rr�rrr�end_element�sz_DumbXMLWriter.end_elementNcCs8|dk	r&t|�}|jd|||f�n|jd|�dS)Nz<%s>%s</%s>z<%s/>)rxr�)rr�rrrr�simple_element�sz_DumbXMLWriter.simple_elementcCsH|r8t|t�r|jd�}|jj|j|j�|jj|�|jjd�dS)Nzutf-8�
)r+r,rZr�r7r�r�)r�linerrrr��s

z_DumbXMLWriter.writeln)rr�)N)r"r#r$r'r�r�r�r�rrrrr��s


r�c@sFeZdZddd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Z	dS)�_PlistWriterr�	r�TFcCs.|r|jt�tj||||�||_||_dS)N)r7�PLISTHEADERr�r'�
_sort_keys�	_skipkeys)rr�r�r�ZwriteHeaderr<r=rrrr'�s

z_PlistWriter.__init__cCs"|jd�|j|�|jd�dS)Nz<plist version="1.0">z</plist>)r��write_value)rrrrrr7�s

z_PlistWriter.writecCs4t|t�r|jd|��n|dkr0|jd��n|dkrD|jd�n�t|t�r�d|ko`dknrx|jd	d
|�nt|��n�t|t�r�|jdt|��n�t|t�r�|j|�n|t|t	�r�|j
|�nft|ttf�r�|j
|�nLt|tj��r|jdt|��n,t|ttf��r |j|�ntd
t|���dS)N�stringT�trueFZfalser��?�@Zintegerz%d�realZdatezunsupported type: %sr�l����l)r+r,r�rd�
OverflowErrorr�rL�dict�
write_dictr�
write_datarA�	bytearray�write_bytesrerl�tuple�list�write_arrayrBr�)rrrrrr��s.





z_PlistWriter.write_valuecCs|j|j�dS)N)r�r>)rr>rrrr�sz_PlistWriter.write_datacCs~|jd�|jd8_tddt|jjdd	�|j��}x&t||�jd�D]}|rL|j|�qLW|jd7_|j	d�dS)
Nr>r��rEr�� �r�s        )
r�r��maxrRr�rurF�splitr�r�)rr>rGr�rrrr�s
z_PlistWriter.write_bytescCs�|rx|jd�|jr"t|j��}n|j�}x@|D]8\}}t|t�sR|jrJq0td��|jd|�|j	|�q0W|j
d�n
|jd�dS)Nr�zkeys must be stringsrh)r�r��sorted�itemsr+r,r�rBr�r�r�)rrkr�rhrrrrr�s

z_PlistWriter.write_dictcCs@|r2|jd�x|D]}|j|�qW|jd�n
|jd�dS)N�array)r�r�r�r�)rr�rrrrr�&s

z_PlistWriter.write_arrayN)rr�r�TF)
r"r#r$r'r7r�r�r�r�r�rrrrr��s
%
r�cCs�d	}x|D]}|j|�r
dSq
WxntjdftjdftjdffD]N\}}|j|�sRq>x8|D]0}||jd�j|�}|dt|��|krXdSqXWq>WdS)
N�<?xml�<plistTzutf-8z	utf-16-bez	utf-16-le�asciiF)r�r�)�
startswith�codecs�BOM_UTF8�BOM_UTF16_BE�BOM_UTF16_LE�decoderZrR)�header�prefixesZpfxZbom�encoding�start�prefixrrr�_is_fmt_xml1s



r�c@seZdZddd�ZdS)r�Invalid filecCstj||�dS)N)rtr')r�messagerrrr'SszInvalidFileException.__init__N)r�)r"r#r$r'rrrrrRs�B�H�L�Q)r�rrNr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_BinaryPlistParsercCs||_||_dS)N)r}r~)rr:r;rrrr'bsz_BinaryPlistParser.__init__cCs�y|||_|jjdtj�|jjd�}t|�dkr6t��tjd|�\}|_	}}}|jj|�|j
||�|_tg||_
|j|�Stttjttfk
r�t��YnXdS)N� z>6xBBQQQi��)�_fp�seek�os�SEEK_END�readrRr�struct�unpack�	_ref_size�
_read_ints�_object_offsets�
_undefined�_objects�_read_object�OSError�
IndexError�errorr�rt)rr0�trailer�offset_size�num_objects�
top_object�offset_table_offsetrrrr�fs
z_BinaryPlistParser.parsecCsL|dkrH|jjd�dd@}d|>}dt|}tj||jj|��dS|S)N�r�rrOrq)r�r��_BINARY_FORMATr�r�)r�tokenLrwrVr@rrr�	_get_sizesz_BinaryPlistParser._get_sizecsv|jj�|���tkr2tjd|�t�����S�sHt���|krNt��t��fdd�td�|��D��SdS)Nrqc3s&|]}tj�||��d�VqdS)�bigN)rd�
from_bytes)�.0rX)r>�sizerr�	<genexpr>�sz0_BinaryPlistParser._read_ints.<locals>.<genexpr>r)	r�r�r�r�r�rRrr�rQ)r�nr�r)r>r�rr��sz_BinaryPlistParser._read_intscCs|j||j�S)N)r�r�)rr�rrr�
_read_refs�sz_BinaryPlistParser._read_refscs��j|}|tk	r|S�j|}�jj|��jjd�d}|d@|d@}}|dkr^d}�n�|dkrnd}�n||dkr~d}�nl|dkr�d	}�n\|d
kr�tj�jjd|>�d|dkd
�}�n0|dkr�tj	d�jjd��d}�n|dk�rtj	d�jjd��d}�n�|dk�rDtj	d�jjd��d}t
j
ddd�t
j|d�}�n�|dk�r��j|�}�jj|�}t
|�|k�rxt���j�s�t|�}�n^|dk�rΈj|�}�jj|�}	t
|	�|k�r�t��|	jd�}�n|dk�r�j|�d}�jj|�}	t
|	�|k�rt��|	jd�}n�|dk�rX�j|�}�j|�}
g}|�j|<|j�fdd�|
D��n�|dk�r�j|�}�j|�}�j|�}
�j�}|�j|<y2x,t||
�D]\}}
�j|
�|�j|�<�q�WWntk
�r�t��YnXnt��|�j|<|S) Nr�r��r�r�F�	TrPr�r�rO)�signed�"z>frN�#z>d�3i�)Zsecondsr��Pr��`rzutf-16be�c3s|]}�j|�VqdS)N)r�)r��x)rrrr��sz2_BinaryPlistParser._read_object.<locals>.<genexpr>��)r�r�r�r�r�r�rdr�r�r�reZ	timedeltar�rRrr}rr�r��extendr~�zipr�rB)r�ref�result�offset�tokenZtokenHr�r@rVr>Zobj_refsZkey_refs�k�or)rrr��s�


















z_BinaryPlistParser._read_objectN)	r"r#r$r'r�r�r�r�r�rrrrr�Zs

r�cCs0|dkrdS|dkrdS|d>d>r(dSdSdS)	Nr�r�r�rr�rN�ir)�countrrr�_count_to_size�src@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_BinaryPlistWritercCs||_||_||_dS)N)r�r�r�)rr0r<r=rrrr'sz_BinaryPlistWriter.__init__c
Cs�g|_i|_i|_|j|�t|j�}dg||_t|�|_t|j|_	|j
jd�x|jD]}|j|�q\W|j
|�}|j
j�}t|�}dt||}|j
jtj|f|j���d}|||j|||f}	|j
jtjd|	���dS)Nrsbplist00rq�	>5xBBBQQQ)r)�_objlist�	_objtable�_objidtable�_flattenrRr�rr�r��_ref_formatr�r7�
_write_object�
_getrefnum�tellr��pack)
rrr��objr�r�r�Z
offset_formatZsort_versionr�rrrr7s(





z_BinaryPlistWriter.writec	Cs~t|t�r"t|�|f|jkrZdSn8t|t�rHt|j�|jf|jkrZdSnt|�|jkrZdSt|j	�}|j	j
|�t|t�r�||jt|�|f<n0t|t�r�||jt|j�|jf<n||jt|�<t|t��rPg}g}|j�}|j
r�t|�}xB|D]:\}}t|t��s|j�rq�td��|j
|�|j
|�q�WxLtj||�D]}|j|��q:Wn*t|ttf��rzx|D]}|j|��qfWdS)Nzkeys must be strings)r+�_scalarsr�rrr>�idrrRrrSr�r�r�r�r,r�rB�	itertools�chainrr�r�)	rrZrefnum�keys�valuesr�r�vrrrrr>sB






z_BinaryPlistWriter._flattencCsNt|t�r|jt|�|fSt|t�r<|jt|j�|jfS|jt|�SdS)N)r+r!rr�rr>rr")rrrrrrns


z_BinaryPlistWriter._getrefnumcCs�|dkr"|jjtjd||B��n�|dkrH|jjtjd|dBd|��nh|dkrn|jjtjd|dBd|��nB|dkr�|jjtjd
|dBd|��n|jjtjd|dBd
|��dS)Nr�z>Br�r�z>BBBr�z>BBH�r�z>BBL�z>BBQ�ril)r�r7r�r)rrr�rrr�_write_sizevsz_BinaryPlistWriter._write_sizecs��j|�}�jj��j|<|dkr2�jjd��n�|dkrJ�jjd��n�|dkrb�jjd��n�t|t��rl|dkr�y�jjtjdd|��Wn tj	k
r�t
|�d�YnXn�|d'krԈjjtjdd|��n�|d(kr�jjtjd
d|��nt|d)k�r�jjtjdd|��nR|d*k�r8�jjtjdd|��n0|d+k�r`�jjd|jdddd��nt
|���nxt|t��r��jjtjdd|���nRt|t
j
��r�|t
j
dd	d	�j�}�jjtjdd|���nt|t��r�jdt|j���jj|j��n�t|ttf��r0�jdt|���jj|��n�t|t��r�y|jd�}�jdt|��Wn4tk
�r�|jd�}�jdt|�d �YnX�jj|��nDt|ttf��r��fd!d"�|D�}t|�}�jd#|��jjtjd$�j|f|���n�t|t��r�gg}}�j�r&t|j��}	n|j�}	xR|	D]J\}
}t|
t��s\�j�rT�q4t d%��|j!�j|
��|j!�j|���q4Wt|�}�jd&|��jjtjd$�j|f|����jjtjd$�j|f|���nt |��dS),N�F�Tr�rz>Bqr*r�r�z>BBr�z>BHr(r�z>BLr)r�z>BQr��r�)rz>Bdri�rr�rzutf-16berrcsg|]}�j|��qSr)r)r�r)rrr�
<listcomp>�sz4_BinaryPlistWriter._write_object.<locals>.<listcomp>rrqzkeys must be stringsr	rilll)"rr�rr�r7r+rdr�rr�r��to_bytesr�reZ
total_secondsrr+rRr>rAr�r,rZ�UnicodeEncodeErrorr�r�rr�r�r�r�r�rBrS)rrrr@�tZrefsrVZkeyRefsZvalRefsZ	rootItemsrr'r)rrr�s�





$
"$z _BinaryPlistWriter._write_objectN)	r"r#r$r'r7rrr+rrrrrrs-0rcCs|dd�dkS)Nr�sbplist00r)r�rrr�_is_fmt_binary�sr3)�detectr�writerT)r9r:r;cCsn|dkrL|jd�}|jd�x:tj�D]}|d|�r&|d}Pq&Wt��nt|d}|||d�}|j|�S)Nr�rr4r)r:r;)r�r��_FORMATSr&rr�)r0r9r:r;r��info�P�prrrr�s

cCst|�}t||||d�S)N)r9r:r;)rr)rr9r:r;r0rrrr
	sF)r9r<r=cCs:|tkrtd|f��t|d|||d�}|j|�dS)NzUnsupported format: %rr5)r<r=)r6rtr7)rr0r9r<r=r5rrrrs)r9r=r<cCs t�}t|||||d�|j�S)N)r9r=r<)rrr?)rr9r=r<r0rrrrs)rE)D�__all__rTr��
contextlibre�enum�iorr#r��rer��warningsrZxml.parsers.expatr�Enumr"r�globalsr3�__members__r�rr�contextmanagerr1rrrrrrr��compilerrrFrC�ASCIIrarjrlrxryr�r�r�rtrr��objectr�r�rr,rdr�rAr!rr3r	r
r6rr
rrrrrr�<module>1sx



0
	
o&d!#
S	
	

?>