File: //lib64/python3.6/email/__pycache__/header.cpython-36.opt-2.pyc
3
  \&^  �               @   s�   d ddgZ ddlZddlZddlZddlZddlmZ ddlmZ	 e	j
Z
dZdZd	Z
dZdZdZd
Ze
d�Ze
d�ZejdejejB ejB �Zejd�Zejd�ZejjZdd� Zddd�ZG dd � d �ZG dd� d�Z G dd� de!�Z"dS )�Header�
decode_header�make_header�    N)�HeaderParseError)�charset�
� �    �   � �N   z 	zus-asciizutf-8ai  
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qb])    # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<encoded>.*?)      # non-greedy up to the next ?= is the encoded string
  \?=                   # literal ?=
  z[\041-\176]+:$z
\n[^ \t]+:c             C   s�  t | d�rdd� | jD �S tj| �s.| d fgS g }x�| j� D ]�}tj|�}d}xp|r�|jd�}|rn|j� }d}|r�|j|d d f� |rP|jd�j	� }|jd�j	� }|jd�}|j|||f� qPW q<W g }	xVt
|�D ]J\}
}|
dkr�|d r�||
d  d r�||
d  d j� r�|	j|
d � q�W xt|	�D ]}||= �q*W g }
x�|D ]�\}}}|d k�rh|
j||f� n�|d	k�r�t
jj|�}|
j||f� n~|d
k�r t|�d }|�r�|dd d| � 7 }yt
jj|�}W n  tjk
�r�   td
��Y nX |
j||f� ntd| ���qDW g }d  }}x~|
D ]v\}}t|t��rBt|d�}|d k�rV|}|}nB||k�rx|j||f� |}|}n |d k�r�|t| 7 }n||7 }�q$W |j||f� |S )N�_chunksc             S   s(   g | ] \}}t j|t|��t|�f�qS � )�_charsetZ_encode�str)�.0�stringr   r   r   �$/usr/lib64/python3.6/email/header.py�
<listcomp>M   s   z!decode_header.<locals>.<listcomp>Tr   F�   �   �q�b�   z===zBase64 decoding errorzUnexpected encoding: zraw-unicode-escape)�hasattrr
   �ecre�search�
splitlines�split�pop�lstrip�append�lower�	enumerate�isspace�reversed�email�
quoprimimeZ
header_decode�lenZ
base64mime�decode�binascii�Errorr   �AssertionError�
isinstancer   �bytes�BSPACE)�headerZwords�line�parts�firstZ	unencodedr   �encodingZencodedZdroplist�n�w�dZ
decoded_wordsZencoded_stringZwordZpaderrZ	collapsedZ	last_word�last_charsetr   r   r   r   =   sz    
4
c             C   sL   t |||d�}x8| D ]0\}}|d k	r8t|t� r8t|�}|j||� qW |S )N)�
maxlinelen�header_name�continuation_ws)r   r-   �Charsetr!   )Zdecoded_seqr9   r:   r;   �h�sr   r   r   r   r   �   s    c               @   sJ   e Zd Zddd�Zdd� Zdd	� Zdd
d�Zdd
� Zddd�Zdd� Z	dS )r   Nr   �strictc             C   s|   |d krt }nt|t�s t|�}|| _|| _g | _|d k	rH| j|||� |d krTt}|| _|d krjd| _	nt
|�d | _	d S )Nr   r   )�USASCIIr-   r<