HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //usr/lib/python3.6/site-packages/docutils/transforms/__pycache__/references.cpython-36.opt-1.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.
    icCsf�x^|jjtj�D�]J}t|jtj�s|jd�s|jd�s|jd�rFq|jdd�}|dk	o�t|tj	�rvt|tj
�s�t|tj�r|dj|d�|dj|d�t|d�s�i|_t|d	�s�i|_
x&|dD]}||jj|<||j
|<q�Wx|dD]}||j|<q�W|jjt|di��|j
jt|d	i��|dd
|d<g|d<g|d<|jj|�qWdS)N�refid�refuri�refnameT)Zascend�ids�names�expect_referenced_by_name�expect_referenced_by_idr)�document�traverser�target�
isinstance�parentZTextElement�hasattr�	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_priorityrrrrrrsrc@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�appendr�len�reporter�error�set_id�problematic�	rawsource�add_backref�replace_self�zip�
referencedr�resolvedr
r)
rZanonymous_refsZanonymous_targets�node�msg�msgid�ref�prb�prbidrrrrrrsD





zAnonymousHyperlinks.applyN)rr r!r"r#rrrrrr$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_targetsr4�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_byrrrr4r�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)rrrrrrBsz.IndirectHyperlinks.nonexistent_indirect_targetcCs|j|d�dS)Nzforming a circular reference)rF)rrrrrrD
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.r/r0r1r4)rrZexplanation�naming�reflistrrr6r7r8r9r:rrrrF
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)rrrrIr(rCr4rrrr=rJ)	rrZattnameZcall_methodZattvalrrLr8rrrrr=$sH




z.IndirectHyperlinks.resolve_indirect_referencesN)rr r!r"r#rr<rBrDrFr=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&)	rrrrrrIr(rCr4)rrrrrLr8rrrr`s

zExternalTargets.applyN)rr r!r"r#rrrrrrMLsrMc@s eZdZdZdd�Zdd�ZdS)�InternalTargetsi�cCs>x8|jjtj�D]&}|jd�r|jd�r|j|�qWdS)Nrr)rrrrr�resolve_reference_ids)rrrrrrtszInternalTargets.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(rIrCr4)rrrrrLr8rrrrOys
z%InternalTargets.resolve_reference_idsN)rr r!r#rrOrrrrrNpsrNc
@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.applycCsx�|jjD]�}x"t|�}|d7}||jjkrPqW|jdtjd|��xv|dD]j}xd|jjj|g�D]P}|tj	|�7}|j
d�|dd|d<|j|dd�|jj|�d|_
qfWqPW|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&rrGrr	r
rZdupnames)rZ
autofootnotes�strr?�insertr�label�
footnote_refsr(�Text�delattrr0rr4r)�note_explicit_targetrU)rrZ�footnoter]rr8rrrrV�s(
zFootnotes.number_footnotesc
Cs8d}�x,|jjD�]}|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|�|
j
|dd�d	|_|d	7}qWdS)
z3Assign numbers to autonumbered footnote references.rrzUToo many autonumbered footnote references: only %s corresponding footnotes available.)rHNr	)rr
r&)rZautofootnote_refsr4rrU�
IndexErrorr+r,r*r-rr.r/r0r1r_r?r
r)rrZ�ir8r]r6r7r9r:rrbrrrrWs8
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|}|d	d|d<|jj|�|j|d	d�|d7}q�WdS)
z<Add symbols indexes to "[*]"-style footnotes and references.r&rrGzOToo many symbol footnote references: only %s corresponding footnotes available.)rHNr)rr
)rZsymbol_footnotes�divmodZsymbol_footnote_startr*�symbolsr)r\rr]r-Zsymbol_footnote_refsr_rcr+r,r4rr.r/r0r1r)rZlabelsrbZreps�indexZ	labeltextrdr8r6r7r9r:rrrrX1sB

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)rrbr]rLZcitationrrrrYVsz)Footnotes.resolve_footnotes_and_citationscCsV|dd}x>|D]6}|jrq|jd�||d<|j|dd�d|_qWd|_dS)Nr
rr	rr&)r4r`r0)rZnoterLrr8rrrrhfs


zFootnotes.resolve_references)
rr r!r"r#rUrfrrVrWrXrYrhrrrrrP�s&;!%rPc@seZdZdS)�#CircularSubstitutionDefinitionErrorN)rr r!rrrrritsric@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".)rH)rZltrimZtrimrr&Zrtrimz
ref-originz*Circular substitution definition detected:)�linerHz2Circular substitution definition referenced: "%s".)"rZsubstitution_defsZsubstitution_namesrrZsubstitution_reference�lowerr+r,r-r.r/r0r1rrgZ
attributesrr_�replace�rstripr*�lstrip�deepcopy�
setdefaultrir)Zsubstitution_definitionZ
literal_blockrlrZchildrenZReferentialZnote_refname)rZdefsZnormedZ
subreflist�nestedr8r	�keyZnormed_namer6r7r9r:ZsubdefrrgZsubdef_copyZ
nested_refZnested_nameZ
ref_originr5rrrr�s�





zSubstitutions.applyN)rr r!r"r#rrrrrrjwsrjc@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)rrrvrrrrx�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%)
rrrrrrrIr(�make_target_footnoter)r'rvr1)	r�notesZnodelistrr�refsrrbr8rrrr�s4



zTargetNotes.applycCsJ||kr||}|dd}nltj�}|jj|�}d|}d|d<|g|d<tj�}|tjd||d�7}||7}|jj|�|jj||�x�|D]�}t|tj	�r�q�tj
|dd�}	|	d	|j7<|jj|	�|jj
|	�|jj|�d}
|	g}tj|jj��s4|j�r"|jdtjd
|jd��n|jdtjd
��|jj|
|�q�W|S)Nrrz
TARGET_NOTE: r&�autorG)r)r	r}ry� )�textZClasses)rrbrr-Z	paragraphr'Znote_autofootnoterarrZfootnote_referenceryZnote_autofootnote_refZnote_footnote_refrrgrZget_trim_footnote_ref_spaceZsettingsr\Zinliner_)rrr|r{rbZ
footnote_nameZfootnote_idZfootnote_paragraphr8ZrefnodergrLrrrrzs8

z TargetNotes.make_target_footnoteN)rr r!r"r#rxrrzrrrrru�s
ruc@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.)rH)�DanglingReferencesVisitorrr@rA�walkrrrr3r(r+�info)rZvisitorrrKrrrrJs 
zDanglingReferences.applyN)rr r!r"r#rrrrrr�Asr�c@s,eZdZdd�Zdd�Zdd�ZeZZdS)r�cCstjj||�||_||_dS)N)r�SparseNodeVisitorrxrrA)rrrArrrrxhsz"DanglingReferencesVisitor.__init__cCsdS)Nr)rr5rrr�
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".)rHzUnknown target name: "%s".)rr
rr)rr&)r4rrr?r(rAr+r,r-rr.r/rcr0r1r
rC)	rr5r	rrEr6r7r9r:rrr�visit_referenceps8

z)DanglingReferencesVisitor.visit_referenceN)rr r!rxr�r�Zvisit_footnote_referenceZvisit_citation_referencerrrrr�fs!r�)r"Z
__docformat__�sys�reZdocutilsrrZdocutils.transformsrrrr$r;rMrNrP�	Exceptionrirjrur�r�r�rrrr�<module>s$GB3$(]wS%