jfӏhdZdZddlmZmZddlmZGddeZGddeZGd d eZ Gd d eZ Gd deZ GddeZ Gdde ZGddeZGddeZGddeZGddejZdS)z& Transforms for resolving references. reStructuredText)nodesutils) TransformceZdZdZdZdZdS)PropagateTargetsa} Propagate empty internal targets to the next element. Given the following nodes:: This is a test. PropagateTargets propagates the ids and names of the internal targets preceding the paragraph to the paragraph itself:: This is a test. ic|jtjD]T}t |jtjs?|ds*|ds|drbt|dks Jd| d}t |tj r1| dd }t |tj 1|@t |tj tj frt |tjs$|d  |d |d  |d t|d si|_t|d si|_|d D]}||jj|<||j|<|d D] }||j|< |jt%|d i|jt%|d i|d d|d<g|d <g|d <|j|VdS)Nrefidrefurirefnamerz&error: block-level target has childrenT)ascendF)r descendidsnamesexpect_referenced_by_nameexpect_referenced_by_id)documentfindallrtarget isinstanceparent TextElementhasattrlen next_nodesystem_message Invisible Targetableextendrrrupdategetattr note_refid)selfrridnames ~/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/docutils/transforms/references.pyapplyzPropagateTargets.apply(sm++EL99- -- -F6=%*;<< NN7++ /5~~h/G/G ~~i00 v;;!###%M###(((55IY(<== L%//tU/KK Y(<== L!i%/5;K)LMM""9el;;" e  # #F5M 2 2 2 g  % %fWo 6 6 69&ABB 968 39&?@@ 746 1Um ? ?(1 !"%9? 1"55w C C> @ @ @%UmA.F7OF5M F7O M $ $V , , , ,[- -- -N__name__ __module__ __qualname____doc__default_priorityr'r(r&rrs5*.-.-.-.-.-r(rceZdZdZdZdZdS)AnonymousHyperlinksa Link anonymous references to targets. Given:: internal external Corresponding references are linked via "refid" or resolved via "refuri":: text external icDg}g}|jtjD],}|dr||-|jtjD],}|dr||-t|t|kr|jj dt|dt|d}|j |}|D]g}tj |j |j |}|j |}| |||hdSt||D]\}} d| _ | dr| d|d<d|_nM| d s|jj| d } J| d d |d <|j| dS) N anonymouszAnonymous hyperlink mismatch: z references but z+ targets. See "backrefs" attribute for IDs.r Tr rr r)rrr referencegetappendrrreportererrorset_id problematic rawsource add_backref replace_selfzip referencedrresolvedrr") r#anonymous_refsanonymous_targetsnodemsgmsgidrefprbprbidrs r&r'zAnonymousHyperlinks.applyssCM))%/:: , ,Dxx $$ ,%%d+++M))%,77 / /Dxx $$ /!((... ~  #&7"8"8 8 8-(...((((#.?*@*@*@*@BCCCM((--E% & &'mS]%AAA ,,S11&&&  %%%% F~/@AA  KC !F  >>(++ $*8$4CM#$CL!%=!!%!26'?!C #)%=#3CLM,,S111  r(Nr)r/r(r&r1r1Ys5,$$$$$r(r1c:eZdZdZdZdZdZdZdZdZ dZ d S) IndirectHyperlinksaN a) Indirect external references:: indirect 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):: indirect external Once the attribute is migrated, the preexisting "refname" attribute is dropped. b) Indirect internal references:: indirect internal 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:: indirect internal ic|jjD]3}|js||||4dSN)rindirect_targetsrBresolve_indirect_targetresolve_indirect_referencesr#rs r&r'zIndirectHyperlinks.applysUm4 5 5F? 5,,V444  , ,V 4 4 4 4 5 5r(c|d}| |d}nY|jj|}|s8|jjjD]}||rn||dS|jj|}||t|tj ra|j sZ| drEt|dr| |dSd|_|||`| dr|d|d<d|vr|d=nz| dr&|d|d<|j|n?|dr ||d<|j|n||dS||d=d|_ dS)Nr r r$multiply_indirectr5r r)r7rnameids transformerunknown_reference_resolversnonexistent_indirect_targetrnote_referenced_byrrrrBrcircular_indirect_referencerUrPr")r#rr reftarget_idresolver_function reftargets r&rPz*IndirectHyperlinks.resolve_indirect_targets**Y'' ?!'?LL=044W==L  1M==%((0044V<<<M%l3 $$ $555 y%, / / )& )!!),, )v233 00888'(F $  ( ( 3 3 3(   X & & (2F8 &  7O   w ' ' '0F7O M $ $V , , , , ".w ((000000888  y!r(c|d|jjvr||ddS||ddS)Nr z>which is a duplicate, and cannot be used as a unique referencezwhich does not exist)rrVindirect_target_errorrRs r&rYz.IndirectHyperlinks.nonexistent_indirect_targetse )  5 5 5  & &v0N O O O O O  & &v/E F F F F Fr(c2||ddS)Nzforming a circular reference)r`rRs r&r[z.IndirectHyperlinks.circular_indirect_reference s ""6+IJJJJJr(c  d}g}|drd|ddz}|dD]5}||jj|g6|dD]5}||jj|g6|dr|d|ddzz }|jjd|d|d d |d | }|j|}tj |D]g} tj | j | j | } |j| } | | | | hd|_dS)Nrz"%s" rrz (id="%s")zIndirect hyperlink target z refers to target "r z", . base_noder4r5)rrrefnamesr7refidsr9r:r;runiqrr<r=r>r?rB) r#r explanationnamingreflistr%r$rFrGrHrIrJs r&r`z(IndirectHyperlinks.indirect_target_error s '? 2vgq11F7O A AD NN4=155dB?? @ @ @ @- = =B NN4=/33B;; < < < < %= 5 kF5M!$44 4Fm$*** ***KKK9DJ+LL $$S)):g&& " "C#-e===CM((--E OOE " " "   S ! ! ! !r(c|drd}|jj}n|drd}d}ndS||}|dD]}|jj|g}|r|||D]U}|jr |d=|||<|r ||d|_t|tj r| |V|dD]}|jj |g}|r|||D]U}|jr |d=|||<|r ||d|_t|tj r| |VdS) Nr r rr%r r5rrT) rrr"rgr7rZrBrrrrQrh) r#rattname call_methodattvalr%rlrHr$s r&rQz.IndirectHyperlinks.resolve_indirect_references#s >>' " " G-2KK ^^H % % GKK F7O : :Dm,00r::G 5))t)444 : :< N%G %K$$$  c5<00:44S999 :- : :Bm*..r266G 1))R)000 : :<L%G %K$$$  c5<00:44S999 : : :r(N) r*r+r,r-r.r'rPrYr[r`rQr/r(r&rLrLs00d555 ***XGGGKKK.%:%:%:%:%:r(rLceZdZdZdZdZdS)ExternalTargetsa Given:: direct external The "refname" attribute is replaced by the direct "refuri" attribute:: direct external icL|jtjD]~}|drg|d}|dD]V}|jj|g}|r|||D]}|jr |d=||d<d|_WdS)Nr rrnr r5) rrrrrrgr7rZrB)r#rr r%rlrHs r&r'zExternalTargets.apply_sm++EL99 ) )F~~h'' ))"7O ) )D"m488rBBG=11t1<<<&))<%$ N(.H '( ) ) )r(Nr)r/r(r&rsrsKs5  ) ) ) ) )r(rsceZdZdZdZdZdS)InternalTargetsic|jtjD]A}|ds*|ds||BdS)Nr r )rrrrrresolve_reference_idsrRs r&r'zInternalTargets.applyssim++EL99 3 3F>>(++ 3FNN74K4K 3**6222 3 3r(c|dD]w}|jj|}|jj|g}|r|||D]}|jr |r|d=||d<d|_xdS)a Given:: direct internal The "refname" attribute is replaced by "refid" linking to the target's "id":: direct internal rrnr r r5N)rrVr7rgrZrB)r#rr%r rlrHs r&rxz%InternalTargets.resolve_reference_idsxs"7O ! !DM)--d33Em,00r::G 5))t)444 ! !<)I#(CL   ! ! !r(N)r*r+r,r.r'rxr/r(r&rvrvos8333 !!!!!r(rvcHeZdZdZdZdZ gdZdZdZdZ dZ d Z d Z dS) Footnotesa Assign numbers to autonumbered footnotes, and resolve links to footnotes, citations, and their references. Given the following ``document`` as input:: A labeled autonumbered footnote reference: An unlabeled autonumbered footnote reference: Unlabeled autonumbered footnote. 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:: A labeled autonumbered footnote reference: 2 An unlabeled autonumbered footnote reference: 1