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

B

!e�K�@sXdZdZddlmZddlmZmZGdd�de�ZGdd�de�ZGd	d
�d
e�Z	dS)z
Miscellaneous transforms.
ZreStructuredText�)�nodes)�	Transform�TransformErrorc@seZdZdZdZdd�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|�|j�|�dS)N�callback)�	startnode�details�parent�remove)�self�pending�r
�I/opt/alt/python37/lib/python3.7/site-packages/docutils/transforms/misc.py�applyszCallBack.applyN)�__name__�
__module__�__qualname__�__doc__�default_priorityrr
r
r
rrs
rc@seZdZdZdZdd�ZdS)�ClassAttributez|
    Move the "class" attribute specified in the "pending" node into the
    immediately following non-comment element.
    ��cCs�|j}|j}|}xz|r�xpt|�|�dt|��D]J}||}t|tj�s0t|tj�rVq0|d|j	d7<|j�
|�dSW|}|j}qW|jjj
d|j	dt�|j|j�|jd�}|�|�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#src@s$eZdZdZdZdd�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>cCs&x |j�tj�D]}|�|�qWdS)N)rZtraverser�
transition�visit_transition)r�noder
r
rr`szTransitions.applycCs�|j�|�}d}|dksLt|jdtj�r�|dksLt|jdtj�r�|dkr�t|jtj�slt|jtj�slt�|jj	j
d|j|jd�}n.t|j|dtj
�r�|jj	j
d|j|jd�}|r�|j�||�|d7}|t|j�ks�t�|t|j�dkr�dS|}xh|t|j�dk�rb|j}|jdk�rT|jj	j
d|jd�}|j�|j�|�d|�dS|j�|�}q�W|j�|�|j�|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)r	rrr�titleZsubtitler�section�AssertionErrorr r!r(rr$�insertrr
)rr&rr!Zsiblingr
r
rr%dsD
zTransitions.visit_transitionN)rrrrrrr%r
r
r
rr#Fsr#N)
rZ
__docformat__�docutilsrZdocutils.transformsrrrrr#r
r
r
r�<module>s#