HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/docutils/transforms/__pycache__/references.cpython-36.pyc
3

w2�e��@s�dZdZddlZddlZddlmZmZddlmZm	Z	Gdd�de	�Z
Gdd	�d	e	�ZGd
d�de	�ZGdd
�d
e	�Z
Gdd�de	�ZGdd�de	�ZGdd�de�ZGdd�de	�ZGdd�de	�ZGdd�de	�ZGdd�dej�ZdS)z&
Transforms for resolving references.
ZreStructuredText�N)�nodes�utils)�TransformError�	Transformc@seZdZdZdZdd�ZdS)�PropagateTargetsa}
    Propagate empty internal targets to the next element.

    Given the following nodes::

        <target ids="internal1" names="internal1">
        <target anonymous="1" ids="id1">
        <target ids="internal2" names="internal2">
        <paragraph>
            This is a test.

    PropagateTargets propagates the ids and names of the internal
    targets preceding the paragraph to the paragraph itself::

        <target refid="internal1">
        <target anonymous="1" refid="id1">
        <target refid="internal2">
        <paragraph ids="internal2 id1 internal1" names="internal2 internal1">
            This is a test.
    icCs|�xt|jjtj�D�]`}t|jtj�s|jd�s|jd�s|jd�rFqt|�dksZt	d��|j
dd�}|dk	o�t|tj�r�t|tj�s�t|tj�r|dj
|d�|d	j
|d	�t|d
�s�i|_t|d�s�i|_x&|dD]}||jj|<||j|<q�Wx|d	D]}||j|<�qW|jjt|d
i��|jjt|di��|dd|d<g|d<g|d	<|jj|�qWdS)N�refid�refuri�refnamerz&error: block-level target has childrenT)Zascend�ids�names�expect_referenced_by_name�expect_referenced_by_id)�document�traverser�target�
isinstance�parentZTextElement�hasattr�len�AssertionError�	next_nodeZ	InvisibleZ
Targetable�extendrr
r
�update�getattr�
note_refid)�selfrr�id�name�r� /usr/lib/python3.6/references.py�apply*s<


zPropagateTargets.applyN)�__name__�
__module__�__qualname__�__doc__�default_priorityr rrrrrsrc@seZdZdZdZdd�ZdS)�AnonymousHyperlinksa�
    Link anonymous references to targets.  Given::

        <paragraph>
            <reference anonymous="1">
                internal
            <reference anonymous="1">
                external
        <target anonymous="1" ids="id1">
        <target anonymous="1" ids="id2" refuri="http://external">

    Corresponding references are linked via "refid" or resolved via "refuri"::

        <paragraph>
            <reference anonymous="1" refid="id1">
                text
            <reference anonymous="1" refuri="http://external">
                external
        <target anonymous="1" ids="id1">
        <target anonymous="1" ids="id2" refuri="http://external">
    i�c
Csdg}g}x*|jjtj�D]}|jd�r|j|�qWx*|jjtj�D]}|jd�rD|j|�qDWt|�t|�kr�|jjj	dt|�t|�f�}|jj
|�}x@|D]8}tj|j|j|d�}|jj
|�}|j
|�|j|�q�WdSx~t||�D]p\}}	d|	_x`|	jd��r|	d|d<d|_Pq�|	d�s:|jj|	d}	q�|	dd|d<|jj|�Pq�Wq�WdS)	N�	anonymousz]Anonymous hyperlink mismatch: %s references but %s targets.
See "backrefs" attribute for IDs.)r�rr
rr)rrr�	reference�get�appendrr�reporter�error�set_id�problematic�	rawsource�add_backref�replace_self�zip�
referencedr�resolvedr
r)
rZanonymous_refsZanonymous_targets�node�msg�msgid�ref�prb�prbidrrrrr rsD





zAnonymousHyperlinks.applyN)r!r"r#r$r%r rrrrr&Xsr&c@sDeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�IndirectHyperlinksaN
    a) Indirect external references::

           <paragraph>
               <reference refname="indirect external">
                   indirect external
           <target id="id1" name="direct external"
               refuri="http://indirect">
           <target id="id2" name="indirect external"
               refname="direct external">

       The "refuri" attribute is migrated back to all indirect targets
       from the final direct target (i.e. a target not referring to
       another indirect target)::

           <paragraph>
               <reference refname="indirect external">
                   indirect external
           <target id="id1" name="direct external"
               refuri="http://indirect">
           <target id="id2" name="indirect external"
               refuri="http://indirect">

       Once the attribute is migrated, the preexisting "refname" attribute
       is dropped.

    b) Indirect internal references::

           <target id="id1" name="final target">
           <paragraph>
               <reference refname="indirect internal">
                   indirect internal
           <target id="id2" name="indirect internal 2"
               refname="final target">
           <target id="id3" name="indirect internal"
               refname="indirect internal 2">

       Targets which indirectly refer to an internal target become one-hop
       indirect (their "refid" attributes are directly set to the internal
       target's "id"). References which indirectly refer to an internal
       target become direct internal references::

           <target id="id1" name="final target">
           <paragraph>
               <reference refid="id1">
                   indirect internal
           <target id="id2" name="indirect internal 2" refid="id1">
           <target id="id3" name="indirect internal" refid="id1">
    i�cCs0x*|jjD]}|js|j|�|j|�q
WdS)N)rZindirect_targetsr5�resolve_indirect_target�resolve_indirect_references)rrrrrr �s
zIndirectHyperlinks.applycCsP|jd�}|dkr|d}n>|jjj|�}|sZx&|jjjD]}||�r:Pq:W|j|�dS|jj|}|j|d�t|t	j
�r�|jr�|jd�r�t|d�r�|j
|�dSd|_|j|�|`|jd�r�|d|d<d|kr�|d=nT|jd��r|d|d<|jj|�n.|d�r(||d<|jj|�n|j|�dS|dk	�rF|d=d|_dS)Nr	r)r�multiply_indirectr(rr
)r*r�nameids�transformer�unknown_reference_resolvers�nonexistent_indirect_targetr
�note_referenced_byrrrr5r�circular_indirect_referencer?r=r)rrr	Zreftarget_id�resolver_functionZ	reftargetrrrr=�sH









z*IndirectHyperlinks.resolve_indirect_targetcCs.|d|jjkr|j|d�n|j|d�dS)Nr	z>which is a duplicate, and cannot be used as a unique referencezwhich does not exist)rr@�indirect_target_error)rrrrrrCsz.IndirectHyperlinks.nonexistent_indirect_targetcCs|j|d�dS)Nzforming a circular reference)rG)rrrrrrE
sz.IndirectHyperlinks.circular_indirect_referencecCs
d}g}|dr d|dd}x&|dD]}|j|jjj|g��q*Wx&|dD]}|j|jjj|g��qRW|dr�|d|dd7}|jjjd||d|f|d	�}|jj|�}xFtj	|�D]8}	t
j|	j|	j|d
�}
|jj|
�}|j
|�|	j|
�q�Wd|_dS)N�rz"%s" rr
z	(id="%s")z7Indirect hyperlink target %s refers to target "%s", %s.r	)�	base_node)rr()rr�refnamesr*�refidsr,r-r.rZuniqrr/r0r1r2r5)rrZexplanation�naming�reflistrrr7r8r9r:r;rrrrG
s*
z(IndirectHyperlinks.indirect_target_errorc	Cs:|jd�rd}|jj}n|jd�r,d}d}ndS||}x||dD]p}|jjj|g�}|rf|j|d�xJ|D]B}|jrxql|d=|||<|r�||�d|_t|tj	�rl|j
|�qlWqBWx~|dD]r}|jjj|g�}|r�|j|d�xL|D]D}|jr�q�|d=|||<|�r||�d|_t|tj	�r�|j
|�q�Wq�WdS)	Nrrr)rr	r(r
)r)rrrrJr*rDr5rrrr>rK)	rrZattnameZcall_methodZattvalrrMr9rrrrr>$sH




z.IndirectHyperlinks.resolve_indirect_referencesN)r!r"r#r$r%r r=rCrErGr>rrrrr<�s2-r<c@seZdZdZdZdd�ZdS)�ExternalTargetsa�
    Given::

        <paragraph>
            <reference refname="direct external">
                direct external
        <target id="id1" name="direct external" refuri="http://direct">

    The "refname" attribute is replaced by the direct "refuri" attribute::

        <paragraph>
            <reference refuri="http://direct">
                direct external
        <target id="id1" name="direct external" refuri="http://direct">
    i�cCs�x�|jjtj�D]r}|jd�r|d}xZ|dD]N}|jjj|g�}|rT|j|d�x(|D] }|jrfqZ|d=||d<d|_qZWq0WqWdS)Nrr)rr	r()	rrrrrrJr*rDr5)rrrrrMr9rrrr `s

zExternalTargets.applyN)r!r"r#r$r%r rrrrrNLsrNc@s eZdZdZdd�Zdd�ZdS)�InternalTargetsi�cCs>x8|jjtj�D]&}|jd�r|jd�r|j|�qWdS)Nrr)rrrrr�resolve_reference_ids)rrrrrr tszInternalTargets.applycCsrxl|dD]`}|jjj|�}|jjj|g�}|r<|j|d�x,|D]$}|jrNqB|r`|d=||d<d|_qBWq
WdS)a�
        Given::

            <paragraph>
                <reference refname="direct internal">
                    direct internal
            <target id="id1" name="direct internal">

        The "refname" attribute is replaced by "refid" linking to the target's
        "id"::

            <paragraph>
                <reference refid="id1">
                    direct internal
            <target id="id1" name="direct internal">
        r)rr	rr(N)rr@r*rJrDr5)rrrrrMr9rrrrPys
z%InternalTargets.resolve_reference_idsN)r!r"r#r%r rPrrrrrOpsrOc
@s`eZdZdZdZdZdddddd	d
ddd
g
Zdd�Zdd�Zdd�Z	dd�Z
dd�Zdd�ZdS)�	Footnotesa�
    Assign numbers to autonumbered footnotes, and resolve links to footnotes,
    citations, and their references.

    Given the following ``document`` as input::

        <document>
            <paragraph>
                A labeled autonumbered footnote referece:
                <footnote_reference auto="1" id="id1" refname="footnote">
            <paragraph>
                An unlabeled autonumbered footnote referece:
                <footnote_reference auto="1" id="id2">
            <footnote auto="1" id="id3">
                <paragraph>
                    Unlabeled autonumbered footnote.
            <footnote auto="1" id="footnote" name="footnote">
                <paragraph>
                    Labeled autonumbered footnote.

    Auto-numbered footnotes have attribute ``auto="1"`` and no label.
    Auto-numbered footnote_references have no reference text (they're
    empty elements). When resolving the numbering, a ``label`` element
    is added to the beginning of the ``footnote``, and reference text
    to the ``footnote_reference``.

    The transformed result will be::

        <document>
            <paragraph>
                A labeled autonumbered footnote referece:
                <footnote_reference auto="1" id="id1" refid="footnote">
                    2
            <paragraph>
                An unlabeled autonumbered footnote referece:
                <footnote_reference auto="1" id="id2" refid="id3">
                    1
            <footnote auto="1" id="id3" backrefs="id2">
                <label>
                    1
                <paragraph>
                    Unlabeled autonumbered footnote.
            <footnote auto="1" id="footnote" name="footnote" backrefs="id1">
                <label>
                    2
                <paragraph>
                    Labeled autonumbered footnote.

    Note that the footnotes are not in the same order as the references.

    The labels and reference text are added to the auto-numbered ``footnote``
    and ``footnote_reference`` elements.  Footnote elements are backlinked to
    their references via "refids" attributes.  References are assigned "id"
    and "refid" attributes.

    After adding labels and reference text, the "auto" attributes can be
    ignored.
    ilN�*u†u‡�§�¶�#u♠u♥u♦u♣cCs:g|_|jj}|j|�|j_|j|�|j�|j�dS)N)�autofootnote_labelsrZautofootnote_start�number_footnotes�number_footnote_references�symbolize_footnotes�resolve_footnotes_and_citations)r�startnumrrrr �s
zFootnotes.applycCs2�x*|jjD�]}x"t|�}|d7}||jjkrPqW|jdtjd|��x�|dD]�}x�|jjj|g�D]|}|tj	|�7}|j
d�t|d�t|d�ko�dkns�t�|dd|d<|j
|dd�|jj|�d|_qjWqTW|dr|dr|dj|�|jj||�|jj|�qW|S)	z�
        Assign numbers to autonumbered footnotes.

        For labeled autonumbered footnotes, copy the number over to
        corresponding footnote references.
        r(rrHrr	r
rZdupnames)rZ
autofootnotes�strr@�insertr�label�
footnote_refsr*�Text�delattrrrr1rr5r+�note_explicit_targetrV)rr[�footnoter^rr9rrrrW�s*
,zFootnotes.number_footnotesc
CsNd}�xB|jjD�]4}|js|jd�r(qy|j|}Wn�tk
r�|jjjdt|j�|d�}|jj	|�}x^|jj|d�D]J}|js�|jd�r�q�t
j|j|j|d�}|jj	|�}|j
|�|j|�q�WPYnX|t
j|�7}|jj|}	|jj|	}
|	|d<|jj|�t|d�d	k�s&t�|
j
|dd�d	|_|d	7}qWdS)
z3Assign numbers to autonumbered footnote references.rrzUToo many autonumbered footnote references: only %s corresponding footnotes available.)rINr	)rr
r()rZautofootnote_refsr5rrV�
IndexErrorr,r-rr.rr/r0r1r2r`r@r
rr)rr[�ir9r^r7r8r:r;rrcrrrrXs:
z$Footnotes.number_footnote_referencesc
Cs�g}xt|jjD]h}t|jjt|j��\}}|j||d}|j|�|jdtj	d|��|jjd7_|jj
|�qWd}�x"|jjD�]}y|tj||�7}Wn�t
k
�rF|jjjdt|�|d�}|jj
|�}	x`|jj|d�D]L}|js�|jd��rq�tj|j|j|	d�}
|jj
|
�}|j|�|j|
�q�WPYnX|jj|}t|d	�dk�sjt�|d	d|d<|jj|�|j|d	d�|d7}q�WdS)
z<Add symbols indexes to "[*]"-style footnotes and references.r(rrHzOToo many symbol footnote references: only %s corresponding footnotes available.)rINr)rr
)rZsymbol_footnotes�divmodZsymbol_footnote_startr�symbolsr+r]rr^r.Zsymbol_footnote_refsr`rdr,r-r5rr/r0r1r2rr)rZlabelsrcZreps�indexZ	labeltextrer9r7r8r:r;rrrrY1sD

zFootnotes.symbolize_footnotescCs�xF|jjD]:}x4|dD](}||jjkr|jj|}|j||�qWq
WxF|jjD]:}x4|dD](}||jjkr`|jj|}|j||�q`WqRWdS)za
        Link manually-labeled footnotes and citations to/from their
        references.
        rN)rZ	footnotesr_�resolve_referencesZ	citationsZ
citation_refs)rrcr^rMZcitationrrrrZVsz)Footnotes.resolve_footnotes_and_citationscCs~t|d�dkst�|dd}xR|D]J}|jr2q&|jd�||d<t|d�dksXt�|j|dd�d|_q&Wd|_dS)Nr
r(rr	r)rrr5rar1)rZnoterMrr9rrrrifs


zFootnotes.resolve_references)
r!r"r#r$r%rVrgr rWrXrYrZrirrrrrQ�s&;!%rQc@seZdZdS)�#CircularSubstitutionDefinitionErrorN)r!r"r#rrrrrjtsrjc@seZdZdZdZdd�ZdS)�
SubstitutionsaD
    Given the following ``document`` as input::

        <document>
            <paragraph>
                The
                <substitution_reference refname="biohazard">
                    biohazard
                 symbol is deservedly scary-looking.
            <substitution_definition name="biohazard">
                <image alt="biohazard" uri="biohazard.png">

    The ``substitution_reference`` will simply be replaced by the
    contents of the corresponding ``substitution_definition``.

    The transformed result will be::

        <document>
            <paragraph>
                The
                <image alt="biohazard" uri="biohazard.png">
                 symbol is deservedly scary-looking.
            <substitution_definition name="biohazard">
                <image alt="biohazard" uri="biohazard.png">
    ��c
Cs|jj}|jj}|jjtj�}i}�x�|D�]�}|d}d}||krJ|}n|j�}||krb||}|dkr�|jjjd||d�}	|jj	|	�}
tj
|j|j|
d�}|jj	|�}|	j|�|j
|�q*||}
|j}|j|�}d|
jks�d|
jk�r0|dk�r0t||dtj��r0|j||d||dj��d	|
jk�sHd|
jk�r�t|�|dk�r�t||dtj��r�|j||d||dj��|
j�}ydx^|jtj�D]N}||dj�}||j|g�k�r�t�n ||j|�||d
<|j|��q�WWn�tk
�r�|j}t|tj��rR|jjjdtj|j|j�|j|d�}	|j
|	�nv|}x|jd
��rp|d
}�qXW|jjjd
||d�}	|jj	|	�}
tj
|j|j|
d�}|jj	|�}|	j|�|j
|�Yq*X|j
|j�x4|jD]*}t|tj ��r�d|k�r�|jj!|��q�Wq*WdS)Nr	z(Undefined substitution referenced: "%s".)rI)rZltrimZtrimrr(Zrtrimz
ref-originz*Circular substitution definition detected:)�linerIz2Circular substitution definition referenced: "%s".)"rZsubstitution_defsZsubstitution_namesrrZsubstitution_reference�lowerr,r-r.r/r0r1r2rrhZ
attributesrr`�replace�rstripr�lstrip�deepcopy�
setdefaultrjr+Zsubstitution_definitionZ
literal_blockrmrZchildrenZReferentialZnote_refname)rZdefsZnormedZ
subreflist�nestedr9r	�keyZnormed_namer7r8r:r;ZsubdefrrhZsubdef_copyZ
nested_refZnested_nameZ
ref_originr6rrrr �s�





zSubstitutions.applyN)r!r"r#r$r%r rrrrrkwsrkc@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�TargetNotesz�
    Creates a footnote for each external target in the text, and corresponding
    footnote references after each reference.
    icCs$tj|||d�|jjdg�|_dS)N)�	startnode�class)r�__init__Zdetailsr*�classes)rrrwrrrry�szTargetNotes.__init__c	Cs
i}g}x�|jjtj�D]z}|jd�s(q|d}g}x"|D]}|j|jjj|g��q:W|s^q|j|d||�}|d|kr|||d<|j	|�qWxb|jjtj
�D]P}|jd�s�q�|jd�r�|j|d|g|�}|d|kr�|||d<|j	|�q�W|jj|�dS)Nrrr')
rrrrrrrJr*�make_target_footnoter+r)rwr2)	r�notesZnodelistrr�refsrrcr9rrrr �s4



zTargetNotes.applycCs^||kr2||}t|d�dks$t�|dd}nltj�}|jj|�}d|}d|d<|g|d<tj�}|tjd||d�7}||7}|jj|�|jj	||�x�|D]�}t
|tj�r�q�tj|dd�}	|	d	|j
7<|jj|	�|jj|	�|jj|�d}
|	g}tj|jj��sH|j
�r6|jdtjd
|j
d��n|jdtjd
��|jj|
|�q�W|S)Nrr(rz
TARGET_NOTE: �autorH)r)r	r~rz� )�textZClasses)rrrrcrr.Z	paragraphr)Znote_autofootnoterbrrZfootnote_referencerzZnote_autofootnote_refZnote_footnote_refrrhrZget_trim_footnote_ref_spaceZsettingsr]Zinliner`)rrr}r|rcZ
footnote_nameZfootnote_idZfootnote_paragraphr9ZrefnoderhrMrrrr{s:

z TargetNotes.make_target_footnoteN)r!r"r#r$r%ryr r{rrrrrv�s
rvc@seZdZdZdZdd�ZdS)�DanglingReferencesze
    Check for dangling references (incl. footnote & citation) and for
    unreferenced targets.
    iRcCs�t|j|jjj�}|jj|�xr|jjtj�D]`}|js.|j	d�rDq.|drZ|dd}n|drp|dd}n|d}|jj
jd||d�q.WdS)Nr'rrr
rz(Hyperlink target "%s" is not referenced.)rI)�DanglingReferencesVisitorrrArB�walkrrrr4r*r,�info)rZvisitorrrLrrrr Js 
zDanglingReferences.applyN)r!r"r#r$r%r rrrrr�Asr�c@s,eZdZdd�Zdd�Zdd�ZeZZdS)r�cCstjj||�||_||_dS)N)r�SparseNodeVisitorryrrB)rrrBrrrryhsz"DanglingReferencesVisitor.__init__cCsdS)Nr)rr6rrr�
unknown_visitmsz'DanglingReferencesVisitor.unknown_visitc	Cs$|js|jd�rdS|d}|jjj|�}|dkr�x�|jD]}||�r<Pq<W||jjkrv|jjjd|d|d�}n|jjjd|d|d�}|jj|�}t	j
|j|j|d�}y|dd}Wn tk
r�|jj|�}YnX|j
|�|j|�n(|d=||d<|jj|j|d	�d
|_dS)Nr	zBDuplicate target name, cannot be used as a unique reference: "%s".)rIzUnknown target name: "%s".)rr
rr)rr()r5rrr@r*rBr,r-r.rr/r0rdr1r2r
rD)	rr6r	rrFr7r8r:r;rrr�visit_referenceps8

z)DanglingReferencesVisitor.visit_referenceN)r!r"r#ryr�r�Zvisit_footnote_referenceZvisit_citation_referencerrrrr�fs!r�)r$Z
__docformat__�sys�reZdocutilsrrZdocutils.transformsrrrr&r<rNrOrQ�	Exceptionrjrkrvr�r�r�rrrr�<module>s$GB3$(]wS%