Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/docutils/transforms/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/docutils/transforms/__pycache__/peps.cpython-35.pyc



�@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@sdeZdZdZdZdZdZejdej	�dfejd�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]+: (.+) \$$cCsgt|j�std��|jd}t|tj�sKd|dkrWtd��d}x2|D]*}|dj�j�dkrd|dj�}yt|�}|j	|}Wn�t
k
r�|}d}|jjjd|d	|�}|jj
|�}tj||pd
d|�}|jj
|�}	|j|	�t|d�rk|g|dddd�<n|dtjdd|�7<YnXPqdW|dkr�td
��|dkr�tjt�}
|jjd|
�|jj|
�t|�dks|ddj�j�dkr&td��x:|D]2}|dj�j�}|d}t|�dkr�td|jdd���n�t|�dkr�t|dtj�s=td|jdd���nr|dkr-tjdtjtj|jd�d��}
|r=|tjddtjd|
d|��7}nq-|d}|dkr�x	|D]+}t|tj�rZ|jt|��qZWq-|dkr�x�|D].}t|tj�r�|jt||��q�Wq-|d#kr�g}tjd�}xltj d|j��D]R}t|�}|j!tj||d|jj"j#|j$|��|j!|�qW|dd$�|dd�<q-|dkr�t%j&||j'�|r_|j�}
tjd|
d|�g|dd�<q-|d kr4|j�}|jj"j#|j$d!}tjd|d|�g|dd�<q-|d"kr-t|�r-t%j&||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�replaces�replaced-by�requires� z,?\s+zcontent-type��version)rrr���)(�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�rG�I/opt/alt/python35/lib/python3.5/site-packages/docutils/transforms/peps.py�apply)s�


	
"2

&	%


	((z
Headers.applyN)�__name__�
__module__�__qualname__�__doc__�default_priorityr=r&r8�compile�
IGNORECASEr>rIrGrGrGrHrsrc@s(eZdZdZdZdd�ZdS)�Contentsz~
    Insert an empty table of contents topic and a transform placeholder into
    the document after the RFC 2822 header.
    i|cCs�tj|jjj|jj�}|jd}tjd|�}tj	d|ddg�}tj
|�}|jj|�s�|dj|�|jj
|�tjtj�}||7}|jjd|�|jj|�dS)N�contentsrr�namesr)rZget_languager!r;Z
language_coder(Zlabelsrr�topicZfully_normalize_nameZhas_namer:Znote_implicit_targetr+r	rQr-r.)r?�languagerCrrTr+rGrGrHrI�s

zContents.applyN)rJrKrLrMrNrIrGrGrGrHrQ�srQc@s4eZdZdZdZdd�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.
    icCst|j}t|�d}d}}x||dkr�t||tj�r�||dj�j�j�}d|kr�||}Pnd|kr�|}|d8}q&W|s�tj�}|tjdd�7}|j	|�|r�|j
||�n
|j|�tjt
j�}|j|�|jj|d�tjtjdd|ji�}|j|�|jj|d�dS)	Nrrr
�	copyrightrZ
ReferencesZdetails�callback)r!r r"r�sectionr#r$r9rr)r-r:r+r
rVr.rZCallBack�cleanup_callback)r?�doc�iZrefsectrWZtitle_wordsr+rGrGrHrI�s2	
% 




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

        Called after the `references.TargetNotes` transform is complete.
        rN)r �parent�remove)r?r+rGrGrHrZ�szTargetNotes.cleanup_callbackN)rJrKrLrMrNrIrZrGrGrGrHrV�srVc@s(eZdZdZdZdd�ZdS)r,z'
    Special processing for PEP 0.
    i�cCs9t|j�}|jj|�|jjj|j�dS)N)�PEPZeroSpecialr!�walkZ	startnoder]r^)r?ZvisitorrGrGrHrI�sz
PEPZero.applyN)rJrKrLrMrNrIrGrGrGrHr,�sr,c@sseZdZdZejZdd�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)NrG)r?rErGrGrH�
unknown_visit�szPEPZeroSpecial.unknown_visitcCs|jt|��dS)N)r6r7)r?rErGrGrH�visit_reference�szPEPZeroSpecial.visit_referencecCsd|dkrtj�dS)Nr
r)rZSkipNode)r?rErGrGrH�visit_field_list�szPEPZeroSpecial.visit_field_listcCs |ddk|_d|_dS)NZcols�r)�	pep_table�entry)r?rErGrGrH�visit_tgroup�szPEPZeroSpecial.visit_tgroupcCs<|jd7_|jr8|jdkr8|djd�dS)Nrrr�num)rfrer:)r?rErGrGrH�
visit_colspec�szPEPZeroSpecial.visit_colspeccCs
d|_dS)Nr)rf)r?rErGrGrH�	visit_rowszPEPZeroSpecial.visit_rowcCs�|jd7_|jr�|jdkr�t|�dkr�|djd�|d}t|tj�r�t|�dkr�|j�}yFt|�}|j	j
j|j|}tj
||d|�|d<Wntk
r�YnXdS)Nrrrrhrr)rfrer r:r"rr*r#r%r!r;r<r=r5r')r?rE�p�textr�refrGrGrH�visit_entrys*
$ 
zPEPZeroSpecial.visit_entryN)
rJrKrLrMrr=rarbrcrgrirjrnrGrGrGrHr_�s		r_�peps@python.org�python-list@python.org�python-dev@python.orgcCs�|jd�r�|djd�r�|ddd�tkrI|d}n0|j�jdd�}tjd|d	d
�}|dkr�|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;r�formatZhtmlz?subject=PEP%%20%s)�hasattr�
startswith�non_masked_addressesr#�replacer�raw)rmrFZreplacementZreplacement_textrGrGrHr7s"
r7)rorprq)rMZ
__docformat__�sysr3r8r0�docutilsrrrrrZdocutils.transformsrrr	r
rrrQrVr,ZSparseNodeVisitorr_rvr7rGrGrGrH�<module>s$o23