Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/docutils/transforms/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/docutils/transforms/__pycache__/peps.cpython-37.pyc

B

�@LX0+�@s�dZdZddlZddlZddlZddlZddlmZmZm	Z	ddlm
Z
mZddlm
Z
mZddlmZmZmZGdd	�d	e
�ZGd
d�de
�ZGdd
�d
e
�ZGdd�de
�ZGdd�dej�ZdZddd�ZdS)z�
Transforms for PEP processing.

- `Headers`: Used to transform a PEP's initial RFC-2822 header.  It remains a
  field list, but some entries get processed.
- `Contents`: Auto-inserts a table of contents.
- `PEPZero`: Special processing for PEP 0.
ZreStructuredText�N)�nodes�utils�	languages)�ApplicationError�	DataError)�	Transform�TransformError)�parts�
references�miscc@sDeZdZdZdZdZdZe�dej	�dfe�d�dffZ
dd	�Zd
S)�Headersz<
    Process fields in a PEP's initial RFC-2822 header.
    ihzpep-%04dz3http://hg.python.org/peps/file/default/pep-%04d.txtz\$RCSfile: (.+),v \$$z\1z\$[a-zA-Z]+: (.+) \$$cCs(t|j�std��|jd}t|tj�r4d|dkr<td��d}x�|D]�}|d����dkrF|d��}yt|�}|j	|}Wn�t
k
�r*|}d}|jjjd||d	�}|j�
|�}tj||p�d
|d�}|j�
|�}	|�|	�t|d��r|g|dddd�<n|dt�dd|�7<YnXPqFW|dk�rDtd
��|dk�rrt�t�}
|j�d|
�|j�|
�t|�dk�s�|dd����dk�r�td���x~|D�]t}|d����}|d}t|�dk�r�td|jdd���n�t|�dk�r"t|dtj��sxtd|jdd���nV|dk�r�t�dt�t�|jd�d��}
|�rx|t�ddtjd|
|d��7}n�q�|d}|dk�r�x*|D]"}t|tj��r�|�t|���q�W�q�|dk�r�x,|D]$}t|tj��r�|�t||���q�W�q�|dk�rxg}t�d�}xRt� d|���D]>}t|�}|�!tj|||jj"j#|j$|d��|�!|��q W|dd�|dd�<n�|dk�r�t%�&||j'�|�r|��}
tjd|
|d�g|dd�<nd|dk�r�|��}|jj"j#|j$d }tjd||d�g|dd�<n"|d!k�r�t|��r�t%�&||j'��q�WdS)"NzDocument tree is empty.r�rfc2822�classeszADocument does not begin with an RFC-2822 header; it is not a PEP.�pep�z?"PEP" header must contain an integer; "%s" is an invalid value.)Z	base_nodez(none))Zrefid�z3Document does not contain an RFC-2822 "PEP" header.��titlez	No title!z4PEP header field body contains multiple elements:
%s)�levelz=PEP header field body may only contain a single paragraph:
%sz
last-modifiedz%d-%b-%Y�source�)�refuri�authorzdiscussions-to)Zreplaceszreplaced-by�requires� z,?\s+���zcontent-type��version)(�len�documentr�
isinstancerZ
field_list�astext�lower�int�pep_cvs_url�
ValueError�reporterZwarning�set_idZproblematicZadd_backref�	paragraph�pending�PEPZero�insert�note_pending�pformat�time�strftime�	localtime�os�stat�	reference�replace_self�
mask_emailZText�re�split�append�settings�pep_base_url�pep_urlrZclean_rcs_keywords�rcs_keyword_substitutions)�self�headerrZfield�valueZcvs_url�msgZmsgidZprbZprbidr)�nameZbody�dateZpara�nodeZnewbodyZspaceZrefpep�pepnoZpep_typeZuri�rE�I/opt/alt/python37/lib/python3.7/site-packages/docutils/transforms/peps.py�apply)s�



 


(








z
Headers.applyN)�__name__�
__module__�__qualname__�__doc__�default_priorityr;r$r6�compile�
IGNORECASEr<rGrErErErFrsrc@seZdZdZdZdd�ZdS)�Contentsz~
    Insert an empty table of contents topic and a transform placeholder into
    the document after the RFC 2822 header.
    i|cCs�t�|jjj|jj�}|jd}t�d|�}tj	d|dgd�}t�
|�}|j�|�sb|d�|�|j�
|�t�tj�}||7}|j�d|�|j�|�dS)N�contentsr)r�namesr)rZget_languagerr9Z
language_coder&�labelsrr�topicZfully_normalize_nameZhas_namer8Znote_implicit_targetr)r	rOr+r,)r=�languagerArrSr)rErErFrG�s


zContents.applyN)rHrIrJrKrLrGrErErErFrO�srOc@s$eZdZdZdZdd�Zdd�ZdS)�TargetNotesz�
    Locate the "References" section, insert a placeholder for an external
    target footnote insertion transform at the end, and schedule the
    transform to run immediately.
    icCs|j}t|�d}d}}x\|dkrvt||tj�rv||d������}d|kr`||}Pnd|krl|}|d8}qW|s�t��}|t�dd�7}|�	|�|r�|�
||�n
|�|�t�t
j�}|�|�|j�|d�tjtjd|jid�}|�|�|j�|d�dS)	Nrrr
�	copyrightrZ
References�callback)Zdetails)rrr r�sectionr!r"r7rr'r+r8r)r
rUr,rZCallBack�cleanup_callback)r=�doc�iZrefsectrVZtitle_wordsr)rErErFrG�s2



zTargetNotes.applycCs"t|j�dkr|jj�|j�dS)z�
        Remove an empty "References" section.

        Called after the `references.TargetNotes` transform is complete.
        rN)r�parent�remove)r=r)rErErFrY�szTargetNotes.cleanup_callbackN)rHrIrJrKrLrGrYrErErErFrU�srUc@seZdZdZdZdd�ZdS)r*z'
    Special processing for PEP 0.
    i�cCs*t|j�}|j�|�|jj�|j�dS)N)�PEPZeroSpecialr�walkZ	startnoder\r])r=ZvisitorrErErFrG�s
z
PEPZero.applyN)rHrIrJrKrLrGrErErErFr*�sr*c@sNeZdZdZejZdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�ZdS)r^z�
    Perform the special processing needed by PEP 0:

    - Mask email addresses.

    - Link PEP numbers in the second column of 4-column tables to the PEPs
      themselves.
    cCsdS)NrE)r=rCrErErF�
unknown_visit�szPEPZeroSpecial.unknown_visitcCs|�t|��dS)N)r4r5)r=rCrErErF�visit_reference�szPEPZeroSpecial.visit_referencecCsd|dkrtj�dS)Nr
r)rZSkipNode)r=rCrErErF�visit_field_list�szPEPZeroSpecial.visit_field_listcCs|ddk|_d|_dS)NZcols�r)�	pep_table�entry)r=rCrErErF�visit_tgroup�szPEPZeroSpecial.visit_tgroupcCs0|jd7_|jr,|jdkr,|d�d�dS)Nrrr�num)rerdr8)r=rCrErErF�
visit_colspec�szPEPZeroSpecial.visit_colspeccCs
d|_dS)Nr)re)r=rCrErErF�	visit_rowszPEPZeroSpecial.visit_rowcCs�|jd7_|jr�|jdkr�t|�dkr�|d�d�|d}t|tj�r�t|�dkr�|��}y4t|�}|j	j
j|j|}tj
|||d�|d<Wntk
r�YnXdS)Nrrrrgr)r)rerdrr8r rr(r!r#rr9r:r;r3r%)r=rC�p�textr�refrErErF�visit_entryszPEPZeroSpecial.visit_entryN)
rHrIrJrKrr;r`rarbrfrhrirmrErErErFr^�s	r^)zpeps@python.orgzpython-list@python.orgzpython-dev@python.orgcCs�|�d�r�|d�d�r�|ddd�tkr6|d}n |���dd�}tjd|d	d
�}|dkrb|S|dd|7<|g|dd�<|Sn|SdS)a�
    Mask the email address in `ref` and return a replacement node.

    `ref` is returned unchanged if it contains no email address.

    For email addresses such as "user@host", mask the address as "user at
    host" (text) to thwart simple email address harvesters (except for those
    listed in `non_masked_addresses`).  If a PEP number (`pepno`) is given,
    return a reference including a default email subject.
    rzmailto:rNr�@z&#32;&#97;t&#32;rZhtml)�formatz?subject=PEP%%20%s)�hasattr�
startswith�non_masked_addressesr!�replacer�raw)rlrDZreplacementZreplacement_textrErErFr5s
r5)N)rKZ
__docformat__�sysr1r6r.�docutilsrrrrrZdocutils.transformsrrr	r
rrrOrUr*ZSparseNodeVisitorr^rrr5rErErErF�<module>s o23