Your IP : 3.145.69.185


Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/plistlib.cpython-35.opt-2.pyc



���]B|�
@s�dddddddddd	d
ddg
Zd
dlZd
dlZd
dlZd
dlZd
dlZd
dlmZd
dlZd
dl	Z	d
dl
Z
d
dlZd
dlm
Z
d
dlmZejddde�Ze�jej�Gdd�de�ZGdd�de�Zejdd��ZGdd�de�Zdd�Zdd�Zdd�Zdd�ZGdd�d�Z d Z!e
j"d!�Z#d"d#d$�Z$d%d&�Z%e
j"d'e
j&�Z'd(d)�Z(d*d+�Z)d,d-�Z*Gd.d/�d/�Z+Gd0d1�d1�Z,Gd2d3�d3e,�Z-d4d5�Z.Gd6d7�d7e/�Z0d8d9d:d;d<d=d>d?iZ1e2�Z3Gd@dA�dA�Z4dBdC�Z5e6e7e8eje9fZ:GdDdE�dEe2�Z;dFdG�Z<e=edHe.dIe+dJe-�e>edHe<dIe4dJe;�iZ?dKddLdMdNedOd	�Z@dKddLdMdNedPd�ZAdKe=dQdMdRdSdTd
�ZBdKe=dRdSdQdMdUd�ZCdS)V�	readPlist�
writePlist�readPlistFromBytes�writePlistToBytes�Plist�Data�Dict�FMT_XML�
FMT_BINARY�load�dump�loads�dumps�N)�BytesIO)�warn)�ParserCreate�PlistFormatzFMT_XML FMT_BINARY�modulec@s:eZdZfZdd�Zdd�Zdd�ZdS)�
_InternalDictcCsCy||}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/python35/lib64/python3.5/plistlib.py�__getattr__Vs

z_InternalDict.__getattr__cCstdtd�|||<dS)NzLAttribute access from plist dicts is deprecated, use d[key] notation insteadr)rr)rrrrrr�__setattr___s
z_InternalDict.__setattr__cCs@y||=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__rrr rrrrrOs	rcs"eZdZ�fdd�Z�S)rcs$tdtd�t�j|�dS)Nz?The plistlib.Dict class is deprecated, use builtin dict insteadr)rr�super�__init__)r�kwargs)�	__class__rrr&os
z
Dict.__init__)r!r"r#r&rr)r(rrmsc	cs9t|t�r0t||��}|VWdQRXn|VdS)N)�
isinstance�str�open)�
pathOrFile�mode�fprrr�_maybe_openusr/cs@eZdZ�fdd�Zedd��Zdd�Z�S)rcs$tdtd�t�j|�dS)NzJThe Plist class is deprecated, use the load() and dump() functions insteadr)rrr%r&)rr')r(rrr&�s
zPlist.__init__c	Cs?t|d��}t|�}WdQRX|�}|j|�|S)N�rb)r/r
�update)�clsr,r.rZplistrrr�fromFile�s
	
zPlist.fromFilec
Cs*t|d��}t||�WdQRXdS)N�wb)r/r)rr,r.rrr�write�szPlist.write)r!r"r#r&�classmethodr3r5rr)r(rrs	cCsItdtd�t|d��#}t|dddddt�SWdQRXdS)Nz8The readPlist function is deprecated, use load() insteadrr0�fmt�use_builtin_typesF�	dict_type)rrr/r
r)r,r.rrrr�s

cCsLtdtd�t|d��&}t||dtdddd�WdQRXdS)	Nz9The writePlist function is deprecated, use dump() insteadrr4r7�	sort_keysT�skipkeysF)rrr/rr)rr,r.rrrr�s
cCs2tdtd�tt|�dddddt�S)NzBThe readPlistFromBytes function is deprecated, use loads() insteadrr7r8Fr9)rrr
rr)�datarrrr�s
c	CsBtdtd�t�}t||dtdddd�|j�S)NzAThe writePlistToBytes function is deprecated, use dumps() insteadrr7r:Tr;F)rrrrr�getvalue)r�frrrr�s

	c@sUeZdZdd�Zedd��Zddd�Zdd	�Zd
d�ZdS)
rcCs(t|t�std��||_dS)Nzdata must be as bytes)r)�bytes�	TypeErrorr<)rr<rrrr&�sz
Data.__init__cCs|t|��S)N)�_decode_base64)r2r<rrr�
fromBase64�szData.fromBase64�LcCst|j|�S)N)�_encode_base64r<)r�
maxlinelengthrrr�asBase64�sz
Data.asBase64cCsFt||j�r"|j|jkSt|t�r>|j|kStSdS)N)r)r(r<r?�NotImplemented)r�otherrrr�__eq__�s

zData.__eq__cCsd|jjt|j�fS)Nz%s(%s))r(r!�reprr<)rrrr�__repr__�sz
Data.__repr__N)	r!r"r#r&r6rBrFrIrKrrrrr�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]rCcCsn|dd}g}xJtdt|�|�D]0}||||�}|jtj|��q-Wdj|�S)N��r�)�range�len�append�binasciiZ
b2a_base64�join)�srEZ
maxbinsize�pieces�i�chunkrrrrDsrDcCs6t|t�r%tj|jd��Stj|�SdS)Nzutf-8)r)r*rRZ
a2b_base64�encode)rTrrrrA
srAz{(?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))?)?)?)?)?ZcCsid}tj|�j�}g}x8|D]0}||}|dkrEP|jt|��q(Wtj|�S)N�year�month�day�hour�minute�second)rYrZr[r\r]r^)�_dateParser�match�	groupdictrQ�int�datetime)rT�order�gdZlst�key�valrrr�_date_from_strings

rhcCs,d|j|j|j|j|j|jfS)Nz%04d-%02d-%02dT%02d:%02d:%02dZ)rYrZr[r\r]r^)�drrr�_date_to_string&srjcCs�tj|�}|dk	r'td��|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rvc@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'S)(�_PlistParsercCs1g|_d|_d|_||_||_dS)N)�stack�current_key�root�_use_builtin_types�
_dict_type)rr8r9rrrr&9s
				z_PlistParser.__init__cCsPt�|_|j|j_|j|j_|j|j_|jj|�|j	S)N)
r�parser�handle_begin_elementZStartElementHandler�handle_end_elementZEndElementHandler�handle_dataZCharacterDataHandlerZ	ParseFilerz)r�fileobjrrr�parse@sz_PlistParser.parsecCs9g|_t|d|d�}|dk	r5||�dS)NZbegin_)r<�getattr)r�element�attrs�handlerrrrr~Hs	z!_PlistParser.handle_begin_elementcCs-t|d|d�}|dk	r)|�dS)NZend_)r�)rr�r�rrrrNsz_PlistParser.handle_end_elementcCs|jj|�dS)N)r<rQ)rr<rrrr�Ssz_PlistParser.handle_datacCs�|jdk	rat|jdti��sAtd|jj��||jd|j<d|_n[|jsv||_nFt|jdtg��s�td|jj��|jdj|�dS)N�zunexpected element at line %d���r�r�r�)	ryr)rx�typerrr}�CurrentLineNumberrzrQ)rrrrr�
add_objectVs	z_PlistParser.add_objectcCsdj|j�}g|_|S)N�)rSr<)rr<rrr�get_datafs	z_PlistParser.get_datacCs-|j�}|j|�|jj|�dS)N)r|r�rxrQ)rr�rirrr�
begin_dictms
z_PlistParser.begin_dictcCs9|jr(td|j|jjf��|jj�dS)Nz%missing value for key '%s' at line %d)ryrrr}r�rx�pop)rrrr�end_dictrs	z_PlistParser.end_dictcCsO|js&t|jdti��r<td|jj��|j�|_dS)Nr�zunexpected key at line %dr�)ryr)rxr�rrr}r�r�)rrrr�end_keyxs&z_PlistParser.end_keycCs'g}|j|�|jj|�dS)N)r�rxrQ)rr��arrr�begin_array~s
z_PlistParser.begin_arraycCs|jj�dS)N)rxr�)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�rbr�)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_stringcCsE|jr%|jt|j���n|jtj|j���dS)N)r{r�rAr�rrB)rrrr�end_data�s	z_PlistParser.end_datacCs|jt|j���dS)N)r�rhr�)rrrr�end_date�sz_PlistParser.end_dateN)r!r"r#r&r�r~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrw8s&rwc@sUeZdZdddd�Zdd�Zdd�Zd	d
d�Zdd
�Zd	S)�_DumbXMLWriterr�	cCs(||_g|_||_||_dS)N)�filerx�
_indent_level�indent)rr��indent_levelr�rrrr&�s			z_DumbXMLWriter.__init__cCs4|jj|�|jd|�|jd7_dS)Nz<%s>r�)rxrQ�writelnr�)rr�rrr�
begin_element�sz_DumbXMLWriter.begin_elementcCs$|jd8_|jd|�dS)Nr�z</%s>)r�r�)rr�rrr�end_element�sz_DumbXMLWriter.end_elementNcCsJ|dk	r5t|�}|jd|||f�n|jd|�dS)Nz<%s>%s</%s>z<%s/>)rvr�)rr�rrrr�simple_element�sz_DumbXMLWriter.simple_elementcCsb|rNt|t�r$|jd�}|jj|j|j�|jj|�|jjd�dS)Nzutf-8s
)r)r*rXr�r5r�r�)r�linerrrr��sz_DumbXMLWriter.writeln)r!r"r#r&r�r�r�r�rrrrr��s
r�c@sseZdZddddddd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Z	dS)�_PlistWriterrs	r�TFcCs?|r|jt�tj||||�||_||_dS)N)r5�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)rrrrrr5�s

z_PlistWriter.writecCs�t|t�r"|jd|�nz|dkr>|jd�n^|dkrZ|jd�nBt|t�r�d|ko�dknr�|jd	d
|�q�t|��n�t|t�r�|jdt|��n�t|t�r�|j|�n�t|t	�r|j
|�n�t|ttf�r6|j
|�nft|tj�ra|jdt|��n;t|ttf�r�|j|�ntd
t|���dS)N�stringT�trueF�falser��?�@Zintegerz%d�realZdatezunsupported type: %sr�l����l)r)r*r�rb�
OverflowErrorr�rJ�dict�
write_dictr�
write_datar?�	bytearray�write_bytesrcrj�tuple�list�write_arrayr@r�)rrrrrr��s.z_PlistWriter.write_valuecCs|j|j�dS)N)r�r<)rr<rrrr��sz_PlistWriter.write_datacCs�|jd�|jd8_tddt|jjdd	�|j��}x3t||�jd�D]}|rd|j|�qdW|jd7_|j	d�dS)
Nr<r��rCs	� �s
s        )
r�r��maxrPr�rsrD�splitr�r�)rr<rEr�rrrr��s
)z_PlistWriter.write_bytescCs�|r�|jd�|jr1t|j��}n|j�}xX|D]P\}}t|t�sw|jrkqDtd��|jd|�|j	|�qDW|j
d�n
|jd�dS)Nr�zkeys must be stringsrf)r�r��sorted�itemsr)r*r�r@r�r�r�)rrir�rfrrrrr�s
		z_PlistWriter.write_dictcCsR|rA|jd�x|D]}|j|�qW|jd�n
|jd�dS)N�array)r�r�r�r�)rr�rrrrr�s

z_PlistWriter.write_arrayN)
r!r"r#r&r5r�r�r�r�r�rrrrr��s	%
r�cCs�d	}x!|D]}|j|�r
dSq
Wx�tjdftjdftjdffD]k\}}|j|�ssqUxJ|D]B}||jd�j|�}|dt|��|krzdSqzWqUWdS)
N�<?xml�<plistTzutf-8z	utf-16-bez	utf-16-le�asciiF)r�r�)�
startswith�codecs�BOM_UTF8�BOM_UTF16_BE�BOM_UTF16_LE�decoderXrP)�header�prefixesZpfxZbom�encoding�start�prefixrrr�_is_fmt_xml*s

r�c@seZdZddd�ZdS)�InvalidFileExceptionzInvalid filecCstj||�dS)N)rrr&)r�messagerrrr&LszInvalidFileException.__init__N)r!r"r#r&rrrrr�Ksr�r��Br�HrL�Lr��Qc@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_BinaryPlistParsercCs||_||_dS)N)r{r|)rr8r9rrrr&[s	z_BinaryPlistParser.__init__c
Cs�y�||_|jjdtj�|jjd�}t|�dkrOt��tjd|�\}|_	}}}|jj|�|j
||�|_tg||_
|j|�SWn'tttjfk
r�t��YnXdS)N� z>6xBBQQQi��)�_fp�seek�os�SEEK_END�readrPr��struct�unpack�	_ref_size�
_read_ints�_object_offsets�
_undefined�_objects�_read_object�OSError�
IndexError�error)rr.�trailer�offset_size�num_objects�
top_object�offset_table_offsetrrrr�_s		$z_BinaryPlistParser.parsecCsb|dkr^|jjd�dd@}d|>}dt|}tj||jj|��dS|S)N�r�rrMro)r�r��_BINARY_FORMATr�r�)r�tokenLrurTr>rrr�	_get_sizews
 z_BinaryPlistParser._get_sizecsr|jj�|���tkr>tjdt�|��St��fdd�td�|��D��SdS)Nroc3s/|]%}tj�||��d�VqdS)�bigN)rb�
from_bytes)�.0rV)r<�sizerr�	<genexpr>�sz0_BinaryPlistParser._read_ints.<locals>.<genexpr>r)r�r�r�r�r�r�rO)r�nr�r)r<r�rr��s
z_BinaryPlistParser._read_intscCs|j||j�S)N)r�r�)rr�rrr�
_read_refs�sz_BinaryPlistParser._read_refsc
s��j|}|tk	r|S�j|}�jj|��jjd�d}|d@|d@}}|dkrzd}n�|dkr�d}n�|dkr�d}n�|dkr�d	}n�|d
kr�tj�jjd|>�dd|d
k�}n�|dkr'tj	d�jjd��d}nQ|dkrXtj	d�jjd��d}n |dkr�tj	d�jjd��d}t
j
ddd�t
jd|�}n�|dkr�j|�}�j
r��jj|�}qxt�jj|��}nv|dkrA�j|�}�jj|�jd�}|}n7|dkr~�j|�}�jj|d�jd�}n�|dkr��j|�}�j|�}	g}|�j|<|j�fdd�|	D��n�|dkro�j|�}�j|�}
�j|�}	�j�}|�j|<xEt|
|	�D](\}}�j|�|�j|�<q@Wn	t��|�j|<|S) Nr�r��r�r�F�	TrNr�r��signedrM�"z>frL�#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�rbr�r�r�rcZ	timedeltar�r{rr�r��extendr|�zipr�r�)
r�ref�result�offset�tokenZtokenHr�r>rTZobj_refsZkey_refs�k�or)rrr��sn

				%%"		"
#
#	
z_BinaryPlistParser._read_objectN)	r!r"r#r&r�r�r�r�r�rrrrr�Ss
r�cCs:|dkrdS|dkr dS|d>d>r2dSdSdS)	Nr�r�r�rr�rL�ir)�countrrr�_count_to_size�src@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_BinaryPlistWritercCs||_||_||_dS)N)r�r�r�)rr.r:r;rrrr&�s		z_BinaryPlistWriter.__init__c
Cs3g|_i|_i|_|j|�t|j�}dg||_t|�|_t|j|_	|j
jd�x|jD]}|j|�q�W|j
|�}|j
j�}t|�}dt||}|j
jtj||j��d}|||j|||f}	|j
jtjd|	��dS)Nrsbplist00roz	>5xBBBQQQ)�_objlist�	_objtable�_objidtable�_flattenrPr�rr�r��_ref_formatr�r5�
_write_object�
_getrefnum�tellr��pack)
rrr��objr�r�r�Z
offset_formatZsort_versionr�rrrr5�s(			
z_BinaryPlistWriter.writec	Cst|t�r1t|�|f|jkr�dSnPt|t�rht|j�|jf|jkr�dSnt|�|jkr�dSt|j	�}|j	j
|�t|t�r�||jt|�|f<nDt|t�r�||jt|j�|jf<n||jt|�<t|t�r�g}g}|j�}|j
rKt|�}xU|D]M\}}t|t�s�|jryqRtd��|j
|�|j
|�qRWx]tj||�D]}|j|�q�Wn3t|ttf�rx|D]}|j|�q�WdS)Nzkeys must be strings)r)�_scalarsr�rrr<�idrrPrrQr�r�r�r�r*r�r@�	itertools�chainrr�r�)	rrZrefnum�keys�valuesr�r�vr
rrrr,sB!"		

z_BinaryPlistWriter._flattencCsgt|t�r&|jt|�|fSt|t�rR|jt|j�|jfS|jt|�SdS)N)r)rrr�rr<rr)rrrrrr\s
z_BinaryPlistWriter._getrefnumcCs�|dkr/|jjtjd||B��n�|dkrd|jjtjd|dBd|��n�|dkr�|jjtjd|dBd|��n[|dkr�|jjtjd
|dBd|��n&|jjtjd|dBd
|��dS)Nr�z>Br�r�z>BBBr�z>BBH�r�z>BBL�z>BBQ�ril)r�r5r�r)rrr�rrr�_write_sizeds#)))z_BinaryPlistWriter._write_sizecs�j|�}�jj��j|<|dkrD�jjd�n�|dkrc�jjd�n�|dkr��jjd�n�t|t�r�|dkr�y#�jjtjdd|��Wq�tj	k
r�t
|�d�Yq�Xq|d'kr�jjtjdd|��q|d(krF�jjtjd
d|��q|d)krt�jjtjdd|��q|d*kr��jjtjdd|��q|d+kr��jjd|jdddd��qt
|��n&t|t�r�jjtjdd|��n�t|t
j
�rj|t
j
dd	d	�j�}�jjtjdd|��n�t|t�r��jdt|j���jj|j�ndt|ttf�r��jdt|���jj|�n&t|t�roy)|jd�}�jdt|��Wn;tk
r[|jd�}�jdt|�d �YnX�jj|�n�t|ttf�r��fd!d"�|D�}t|�}�jd#|��jjtjd$�j||��n)t|t�rgg}}�jrt|j��}	n|j�}	xg|	D]_\}
}t|
t�sc�jrWq0t d%��|j!�j|
��|j!�j|��q0Wt|�}�jd&|��jjtjd$�j||���jjtjd$�j||��nt |��dS),NsFsTs	rz>Bqr%r�r�z>BBr�z>BHr#r�z>BLr$r�z>BQr�sr�r�z>Bdr�i�rr�rzutf-16berrcsg|]}�j|��qSr)r)r�r
)rrr�
<listcomp>�s	z4_BinaryPlistWriter._write_object.<locals>.<listcomp>rrozkeys must be stringsrrilll)"rr�rr�r5r)rbr�rr�r��to_bytesr�rcZ
total_secondsrr&rPr<r?r�r*rX�UnicodeEncodeErrorr�r�rr�r�r�r�r�r@rQ)rrrr>�tZrefsrTZkeyRefsZvalRefsZ	rootItemsrr"r)rrrts�#"""")""
*
		'*z _BinaryPlistWriter._write_objectN)	r!r"r#r&r5rrr&rrrrrr�s-0rcCs|dd�dkS)Nr�sbplist00r)r�rrr�_is_fmt_binary�sr+�detectr}�writerr7r8Tr9cCs�|dkrf|jd�}|jd�xItj�D]!}|d|�r5|d}Pq5Wt��nt|d}|d|d|�}|j|�S)Nr�rr,r}r8r9)r�r��_FORMATSr!r�r�)r.r7r8r9r��info�P�prrrr
�s

cCs(t|�}t|d|d|d|�S)Nr7r8r9)rr
)rr7r8r9r.rrrr�sr:r;FcCsP|tkrtd|f��t|d|d|d|�}|j|�dS)NzUnsupported format: %rr-r:r;)r.rrr5)rr.r7r:r;r-rrrrs c	Cs2t�}t||d|d|d|�|j�S)Nr7r;r:)rrr=)rr7r;r:r.rrrr
s	)D�__all__rRr��
contextlibrc�enum�iorrr��rer��warningsrZxml.parsers.expatr�Enumr!r�globalsr1�__members__r�rr�contextmanagerr/rrrrrrr��compilerprDrA�ASCIIr_rhrjrvrwr�r�r�rrr�r��objectr�r�rr*rbr�r?rrr+rr	r.r
rrr
rrrr�<module>1st



0		
h&d!	�
�				

?>