ok
Direktori : /lib64/python3.6/email/__pycache__/ |
Current File : //lib64/python3.6/email/__pycache__/header.cpython-36.opt-1.pyc |
3 \&^ � @ s� d Z dddgZddlZddlZddlZddlZddlmZ ddlm Z e jZdZd Z d ZdZdZd ZdZed�Zed�ZejdejejB ejB �Zejd�Zejd�ZejjZdd� Zddd�ZG dd� d�Z G dd� d�Z!G dd� de"�Z#dS )z+Header encoding and decoding functionality.�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.| dfgS g }x�| j� D ]�}tj|�}d}xp|r�|jd�}|rn|j� }d}|r�|j|ddf� |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 ]�\}}}|dk�rh| j||f� n�|d k�r�t jj|�}| j||f� n~|dk�r t|�d }|�r�|d dd| � 7 }yt jj|�}W n tjk �r� td��Y nX | j||f� ntd| ���qDW g }d }}x~| D ]v\}}t|t��rBt|d�}|dk�rV|}|}nB||k�rx|j||f� |}|}n |dk�r�|t| 7 }n||7 }�q$W |j||f� |S )a; Decode a message header value without converting charset. Returns a list of (string, charset) pairs containing each of the decoded parts of the header. Charset is None for non-encoded parts of the header, otherwise a lower-case string containing the name of the character set specified in the encoded string. header may be a string that may or may not contain RFC2047 encoded words, or it may be a Header object. An email.errors.HeaderParseError may be raised when certain decoding error occurs (e.g. a base64 decoding exception). �_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>NTr 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\}}|dk r8t|t� r8t|�}|j||� qW |S )a� Create a Header from a sequence of pairs as returned by decode_header() decode_header() takes a header value string and returns a sequence of pairs of the format (decoded_string, charset) where charset is the string name of the character set. This function takes one of those sequence of pairs and returns a Header instance. Optional maxlinelen, header_name, and continuation_ws are as in the Header constructor. )� maxlinelen�header_name�continuation_wsN)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| |dkrt }nt|t�s t|�}|| _|| _g | _|dk rH| j|||� |dkrTt}|| _|dkrjd| _ nt |�d | _ dS )aD Create a MIME-compliant header that can contain many character sets. Optional s is the initial header value. If None, the initial header value is not set. You can later append to the header with .append() method calls. s may be a byte string or a Unicode string, but see the .append() documentation for semantics. Optional charset serves two purposes: it has the same meaning as the charset argument to the .append() method. It also sets the default character set for all subsequent .append() calls that omit the charset argument. If charset is not provided in the constructor, the us-ascii charset is used both as s's initial charset and as the default for subsequent .append() calls. The maximum line length can be specified explicitly via maxlinelen. For splitting the first line to a shorter value (to account for the field header which isn't included in s, e.g. `Subject') pass in the name of the field in header_name. The default maxlinelen is 78 as recommended by RFC 2822. continuation_ws must be RFC 2822 compliant folding whitespace (usually either a space or a hard tab) which will be prepended to continuation lines. errors is passed through to the .append() call. Nr r )�USASCIIr- r<