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__/misc.cpython-35.pyc



!e�K�@sxdZdZddlmZddlmZmZGdd�de�ZGdd�de�ZGd	d
�d
e�Z	dS)z
Miscellaneous transforms.
ZreStructuredText�)�nodes)�	Transform�TransformErrorc@s(eZdZdZdZdd�ZdS)�CallBacka�
    Inserts a callback into a document.  The callback is called when the
    transform is applied, which is determined by its priority.

    For use with `nodes.pending` elements.  Requires a ``details['callback']``
    entry, a bound method or function which takes one parameter: the pending
    node.  Other data can be stored in the ``details`` attribute or in the
    object hosting the callback method.
    i�cCs.|j}|jd|�|jj|�dS)N�callback)�	startnode�details�parent�remove)�self�pending�r
�I/opt/alt/python35/lib/python3.5/site-packages/docutils/transforms/misc.py�applys	zCallBack.applyN)�__name__�
__module__�__qualname__�__doc__�default_priorityrr
r
r
rrs
rc@s(eZdZdZdZdd�ZdS)�ClassAttributez|
    Move the "class" attribute specified in the "pending" node into the
    immediately following non-comment element.
    ��cCs|j}|j}|}x�|r�x�t|j|�dt|��D]]}||}t|tj�sDt|tj�r{qD|d|j	d7<|jj
|�dSW|}|j}qW|jjj
d|j	dtj|j|j�d|j�}|j|�dS)N��classes�classz,No suitable element following "%s" directiveZ	directive�line)rr	�range�index�len�
isinstancerZ	InvisibleZsystem_messagerr
�document�reporter�errorZ
literal_blockZ	rawsourcerZreplace_self)rrr	Zchildr�elementr!r
r
rr,s(			)

zClassAttribute.applyN)rrrrrrr
r
r
rr#src@s4eZdZdZdZdd�Zdd�ZdS)�Transitionsa�
    Move transitions at the end of sections up the tree.  Complain
    on transitions after a title, at the beginning or end of the
    document, and after another transition.

    For example, transform this::

        <section>
            ...
            <transition>
        <section>
            ...

    into this::

        <section>
            ...
        <transition>
        <section>
            ...
    i>cCs1x*|jjtj�D]}|j|�qWdS)N)rZtraverser�
transition�visit_transition)r�noder
r
rr`szTransitions.applycCs'|jj|�}d}|dksnt|jdtj�r�|dksnt|jdtj�r�|dkr�t|jtj�s�t|jtj�s�t�|jj	j
dd|jd|j�}nDt|j|dtj
�r|jj	j
dd|jd|j�}|r/|jj||�|d7}|t|j�ksJt�|t|j�dkrgdS|}x�|t|j�dkr�|j}|jdkr�|jj	j
dd|j�}|jj|jj|�d|�dS|jj|�}qpW|jj|�|jj|d|�dS)	Nrr�z4Document or section may not begin with a transition.�sourcerzZAt least one body element must separate transitions; adjacent transitions are not allowed.z'Document may not end with a transition.)r	rrr�titleZsubtitler�section�AssertionErrorr r!r(rr$�insertrr
)rr&rr!Zsiblingr
r
rr%dsD
	#zTransitions.visit_transitionN)rrrrrrr%r
r
r
rr#Fsr#N)
rZ
__docformat__�docutilsrZdocutils.transformsrrrrr#r
r
r
r�<module>s#