Your IP : 3.145.161.199


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



���]�N�&@s#ddlmZddlmZddlmZddlmZGdd�d�ZGdd�d�ZGd	d
�d
e	�Z
dd�ZGd
d�d�ZGdd�de�Z
Gdd�d�ZGdd�de�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�ZGdd �d �ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&�Zd'e
d(ed)ed*ed+ed,ed-ed.ed/ed0ed1ed2ed3ed4ed5ed6ed7ed8ed9eiZGd:d;�d;�Zd<S)=�)�MappingProxyType)�utils)�errors)�_header_value_parserc@s�eZdZdddddd�Zedd��Zedd��Zed	d
��Zedd��Zd
d�Z	dd�Z
dd�ZdS)�Address�NcCs�|dk	r|s|r$td��tj|�\}}|rWtdj||���|jrm|jd�|j}|j}||_||_	||_
dS)Nz=addrspec specified when username and/or domain also specifiedz6Invalid addr_spec; only '{}' could be parsed from '{}'r)�	TypeError�parserZ
get_addr_spec�
ValueError�format�all_defects�
local_part�domain�
_display_name�	_username�_domain)�self�display_name�usernamer�	addr_specZa_s�rest�r�3/opt/alt/python35/lib64/python3.5/headerregistry.py�__init__s		
				zAddress.__init__cCs|jS)N)r)rrrrr7szAddress.display_namecCs|jS)N)r)rrrrr;szAddress.usernamecCs|jS)N)r)rrrrr?szAddress.domaincCsrt|j�}t|�t|tj�krCtj|j�}n	|j}|jrd|d|jS|sndS|S)N�@z<>)�setr�lenr	Z
DOT_ATOM_ENDS�quote_stringr)r�namesetZlprrrrCs		zAddress.addr_speccCs%dj|jj|j|j|j�S)Nz1{}(display_name={!r}, username={!r}, domain={!r}))r�	__class__�__name__rrr)rrrr�__repr__Ss	zAddress.__repr__cCs�t|j�}t|�t|tj�krCtj|j�}n	|j}|r�|jdkrgdn|j}dj||�S|jS)Nz<>rz{} <{}>)rrrr	�SPECIALSrrr)rr�disprrrr�__str__Xs	zAddress.__str__cCsPt|�t|�krdS|j|jkoO|j|jkoO|j|jkS)NF)�typerrr)r�otherrrr�__eq__cs
zAddress.__eq__)r �
__module__�__qualname__r�propertyrrrrr!r$r'rrrrrs%rc@sjeZdZdddd�Zedd��Zedd��Zdd	�Zd
d�Zdd
�Z	dS)�GroupNcCs+||_|rt|�nt�|_dS)N)r�tuple�
_addresses)rr�	addressesrrrrms	zGroup.__init__cCs|jS)N)r)rrrrrszGroup.display_namecCs|jS)N)r-)rrrrr.�szGroup.addressescCsdj|jj|j|j�S)Nz${}(display_name={!r}, addresses={!r})rrr rr.)rrrrr!�s	zGroup.__repr__cCs�|jdkr5t|j�dkr5t|jd�S|j}|dk	r�t|�}t|�t|tj�kr�tj|�}djdd�|jD��}|r�d|n|}dj	||�S)N�rz, css|]}t|�VqdS)N)�str)�.0�xrrr�	<genexpr>�sz Group.__str__.<locals>.<genexpr>� z{}:{};)
rrr.r0rr	r"r�joinr)rr#rZadrstrrrrr$�s$	z
Group.__str__cCs>t|�t|�krdS|j|jko=|j|jkS)NF)r%rr.)rr&rrrr'�szGroup.__eq__)
r r(r)rr*rr.r!r$r'rrrrr+ksr+c@sveZdZdd�Zdd�Zedd��Zedd��Zd	d
�Ze	dd��Z
d
d�ZdS)�
BaseHeadercCswdgi}|j||�tj|d�rFtj|d�|d<tj||d�}|d=|j||�|S)N�defects�decoded)�parserZ_has_surrogates�	_sanitizer0�__new__�init)�cls�name�value�kwdsrrrrr;�szBaseHeader.__new__cCs||_||_||_dS)N)�_name�_parse_tree�_defects)rr>�
parse_treer7rrrr<�s		zBaseHeader.initcCs|jS)N)rA)rrrrr>�szBaseHeader.namecCs
t|j�S)N)r,rC)rrrrr7�szBaseHeader.defectscCs+t|jj|jjt|�f|jfS)N)�_reconstruct_headerrr �	__bases__r0�__dict__)rrrr�
__reduce__�s
		zBaseHeader.__reduce__cCstj||�S)N)r0r;)r=r?rrr�_reconstruct�szBaseHeader._reconstructcCsmtjtjtj|jd�tjdd�g�tjtjdd�g�|jg�}|jd|�S)Nzheader-name�:z
header-sepr4Zfws�policy)	r	ZHeaderZHeaderLabelZ
ValueTerminalr>ZCFWSListZWhiteSpaceTerminalrB�fold)rrK�headerrrrrL�szBaseHeader.foldN)r r(r)r;r<r*r>r7rH�classmethodrIrLrrrrr6�s"

r6cCst||i�j|�S)N)r%rI)Zcls_name�basesr?rrrrEsrEc@s7eZdZdZeej�Zedd��Z	dS)�UnstructuredHeaderNcCs+|j|�|d<t|d�|d<dS)NrDr8)�value_parserr0)r=r?r@rrrr9szUnstructuredHeader.parse)
r r(r)�	max_count�staticmethodr	�get_unstructuredrQrNr9rrrrrPsrPc@seZdZdZdS)�UniqueUnstructuredHeaderr/N)r r(r)rRrrrrrUsrUcs[eZdZdZeej�Zedd��Z	�fdd�Z
edd��Z�S)�
DateHeaderNcCs�|sE|djtj��d|d<d|d<tj�|d<dSt|t�rctj|�}||d<tj	|d�|d<|j
|d�|d<dS)Nr7�datetimerr8rD)�appendrZHeaderMissingRequiredValuer	Z	TokenList�
isinstancer0rZparsedate_to_datetimeZformat_datetimerQ)r=r?r@rrrr9&s


zDateHeader.parsecs)|jd�|_t�j||�dS)NrW)�pop�	_datetime�superr<)r�args�kw)rrrr<4szDateHeader.initcCs|jS)N)r[)rrrrrW8szDateHeader.datetime)
r r(r)rRrSr	rTrQrNr9r<r*rWrr)rrrVs
rVc@seZdZdZdS)�UniqueDateHeaderr/N)r r(r)rRrrrrr_=sr_cspeZdZdZedd��Zedd��Z�fdd�Ze	dd	��Z
e	d
d��Z�S)�
AddressHeaderNcCstj|�\}}|S)N)r	Zget_address_list)r?�address_listrrrrQFszAddressHeader.value_parsercCst|t�r{|j|�|d<}g}x:|jD]/}|jt|jdd�|jD���q6Wt|j	�}n1t
|d�s�|g}dd�|D�}g}||d<||d<djd	d�|D��|d
<d|kr|j|d
�|d<dS)NrDcSs=g|]3}t|jpd|jp'd|jp3d��qS)r)rrr
r)r1Zmbrrr�
<listcomp>Us	z'AddressHeader.parse.<locals>.<listcomp>�__iter__cSs7g|]-}t|d�s-td|g�n|�qS)r.N)�hasattrr+)r1�itemrrrrb^s	�groupsr7z, cSsg|]}t|��qSr)r0)r1rerrrrbds	r8)rYr0rQr.rXr+rZ
all_mailboxes�listrrdr5)r=r?r@rarf�addrr7rrrr9Ls$			


 zAddressHeader.parsecs8t|jd��|_d|_t�j||�dS)Nrf)r,rZ�_groupsr-r\r<)rr]r^)rrrr<hs	zAddressHeader.initcCs|jS)N)ri)rrrrrfmszAddressHeader.groupscCs5|jdkr.tdd�|jD��|_|jS)NcSs&g|]}|jD]}|�qqSr)r.)r1�group�addressrrrrbts	z+AddressHeader.addresses.<locals>.<listcomp>)r-r,ri)rrrrr.qszAddressHeader.addresses)r r(r)rRrSrQrNr9r<r*rfr.rr)rrr`Bsr`c@seZdZdZdS)�UniqueAddressHeaderr/N)r r(r)rRrrrrrlysrlc@s"eZdZedd��ZdS)�SingleAddressHeadercCs8t|j�dkr-tdj|j���|jdS)Nr/z9value of single address header {} is not a single addressr)rr.r
rr>)rrrrrk�s	zSingleAddressHeader.addressN)r r(r)r*rkrrrrrm~srmc@seZdZdZdS)�UniqueSingleAddressHeaderr/N)r r(r)rRrrrrrn�srncseZdZdZeej�Zedd��Z	�fdd�Z
edd��Zedd	��Z
ed
d��Z�S)�MIMEVersionHeaderr/cCs�|j|�|d<}t|�|d<|dj|j�|jdkrPdn|j|d<|j|d<|jdk	r�dj|d|d�|d<n
d|d<dS)NrDr8r7�major�minorz{}.{}�version)rQr0�extendrrqrpr)r=r?r@rDrrrr9�s"
!zMIMEVersionHeader.parsecsM|jd�|_|jd�|_|jd�|_t�j||�dS)Nrrrprq)rZ�_version�_major�_minorr\r<)rr]r^)rrrr<�szMIMEVersionHeader.initcCs|jS)N)ru)rrrrrp�szMIMEVersionHeader.majorcCs|jS)N)rv)rrrrrq�szMIMEVersionHeader.minorcCs|jS)N)rt)rrrrrr�szMIMEVersionHeader.version)r r(r)rRrSr	Zparse_mime_versionrQrNr9r<r*rprqrrrr)rrro�srocsLeZdZdZedd��Z�fdd�Zedd��Z�S)�ParameterizedMIMEHeaderr/cCsu|j|�|d<}t|�|d<|dj|j�|jdkrWi|d<ndd�|jD�|d<dS)NrDr8r7�paramscSs7i|]-\}}tj|�tj|�j��qSr)rr:�lower)r1r>r?rrr�
<dictcomp>�s	z1ParameterizedMIMEHeader.parse.<locals>.<dictcomp>)rQr0rsrrx)r=r?r@rDrrrr9�s
	zParameterizedMIMEHeader.parsecs)|jd�|_t�j||�dS)Nrx)rZ�_paramsr\r<)rr]r^)rrrr<�szParameterizedMIMEHeader.initcCs
t|j�S)N)rr{)rrrrrx�szParameterizedMIMEHeader.params)	r r(r)rRrNr9r<r*rxrr)rrrw�s
rwcsgeZdZeej�Z�fdd�Zedd��Z	edd��Z
edd��Z�S)	�ContentTypeHeadercsGt�j||�tj|jj�|_tj|jj�|_dS)N)	r\r<rr:rB�maintype�	_maintype�subtype�_subtype)rr]r^)rrrr<�szContentTypeHeader.initcCs|jS)N)r~)rrrrr}�szContentTypeHeader.maintypecCs|jS)N)r�)rrrrr�szContentTypeHeader.subtypecCs|jd|jS)N�/)r}r)rrrr�content_type�szContentTypeHeader.content_type)r r(r)rSr	Zparse_content_type_headerrQr<r*r}rr�rr)rrr|�s
r|csCeZdZeej�Z�fdd�Zedd��Z	�S)�ContentDispositionHeadercsGt�j||�|jj}|dkr1|ntj|�|_dS)N)r\r<rB�content_dispositionrr:�_content_disposition)rr]r^Zcd)rrrr<�szContentDispositionHeader.initcCs|jS)N)r�)rrrrr��sz,ContentDispositionHeader.content_disposition)
r r(r)rSr	Z parse_content_disposition_headerrQr<r*r�rr)rrr��sr�cs[eZdZdZeej�Zedd��Z	�fdd�Z
edd��Z�S)�ContentTransferEncodingHeaderr/cCs?|j|�|d<}t|�|d<|dj|j�dS)NrDr8r7)rQr0rsr)r=r?r@rDrrrr9�sz#ContentTransferEncodingHeader.parsecs/t�j||�tj|jj�|_dS)N)r\r<rr:rB�cte�_cte)rr]r^)rrrr<�sz"ContentTransferEncodingHeader.initcCs|jS)N)r�)rrrrr�sz!ContentTransferEncodingHeader.cte)
r r(r)rRrSr	Z&parse_content_transfer_encoding_headerrQrNr9r<r*r�rr)rrr��s
r�ZsubjectZdatezresent-datez	orig-dateZsenderz
resent-senderZtoz	resent-toZccz	resent-ccZbccz
resent-bcc�fromzresent-fromzreply-tozmime-versionzcontent-typezcontent-dispositionzcontent-transfer-encodingc@sIeZdZeeddd�Zdd�Zdd�Zdd	�Zd
S)�HeaderRegistryTcCs5i|_||_||_|r1|jjt�dS)N)�registry�
base_class�
default_class�update�_default_header_map)rr�r�Zuse_default_maprrrr$s
			zHeaderRegistry.__init__cCs||j|j�<dS)N)r�ry)rr>r=rrr�map_to_type6szHeaderRegistry.map_to_typecCs>|jj|j�|j�}td|j||jfi�S)N�_)r��getryr�r%r r�)rr>r=rrr�__getitem__<szHeaderRegistry.__getitem__cCs||||�S)Nr)rr>r?rrr�__call__@s
zHeaderRegistry.__call__N)	r r(r)r6rPrr�r�r�rrrrr� s
r�N)�typesrZemailrrrr	rr+r0r6rErPrUrVr_r`rlrmrnrorwr|r�r�r�r�rrrr�<module>
sP[6a'7
%

?>