
    k7iP,                        S r SSKJr  SrSSKrSSKrSSKrSSKJrJ	r	J
r
  SSKJr  SSKJr  SSKJrJrJr   " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      r " S S\R*                  5      rSrSS jrg)z
Transforms for PEP processing.

- `Headers`: Used to transform a PEP's initial RFC-2822 header.  It remains a
  field list, but some entries get processed.
- `Contents`: Auto-inserts a table of contents.
- `PEPZero`: Special processing for PEP 0.
    )annotationsreStructuredTextN)nodesutils	languages)	DataError)	Transform)parts
referencesmiscc                      \ rS rSrSrSrSrSr\R                  " S\R                  5      S4\R                  " S5      S44rS	 rS
rg)Headers   z4
Process fields in a PEP's initial RFC-2822 header.
ih  zpep-%04dz3http://hg.python.org/peps/file/default/pep-%04d.txtz\$RCSfile: (.+),v \$$z\1z\$[a-zA-Z]+: (.+) \$$c                   [        U R                  5      (       d  [        S5      eU R                  S   n[        U[        R
                  5      (       a	  SUS   ;  a  [        S5      eS nU HX  nUS   R                  5       R                  5       S:X  d  M*  US   R                  5       n [        U5      nU R                  U-  n  O   Uc  [        S5      eUS:X  aQ  [        R"                  " [$        5      n
U R                  R'                  SU
5        U R                  R)                  U
5        [        U5      S:  d(  US   S   R                  5       R                  5       S:w  a  [        S5      eU GH  nUS   R                  5       R                  5       nUS   n[        U5      S:  a  [        SUR+                  SS9-  5      e[        U5      S:X  a>  [        US   [        R                   5      (       d  [        SUR+                  SS9-  5      eOUS:X  a   [,        R.                  " S[,        R0                  " [2        R4                  " U R                  S   5      S   5      5      nW(       a.  U[        R                   " SS[        R8                  " SXS95      -  nOGM0  US   nUS:X  aG  U H>  n[        U[        R8                  5      (       d  M$  UR;                  [=        U5      5        M@     GM  US:X  aG  U H>  n[        U[        R8                  5      (       d  M$  UR;                  [=        X5      5        M@     GM  US;   a  / n[        R>                  " S5      n[@        RB                  " SUR                  5       5       Hc  n[        U5      nURE                  [        R8                  " UUU R                  RF                  RH                  U RJ                  U-  -   S9U45        Me     US S US S & GM  US:X  aV  [L        RN                  " XRP                  5        W(       a,  UR                  5       n[        R8                  " SXS9/US S & GM  GM  US :X  a]  UR                  5       nU R                  RF                  RH                  U RJ                  S!-  -   n[        R8                  " SUUS9/US S & GMC  US":X  d  GML  [        U5      (       d  GM_  [L        RN                  " XRP                  5        GM     g ! [         a    UnS nU R                  R                  R                  SU-  US	9nU R                  R                  U5      n[        R                  " XD=(       d    S
US9nU R                  R                  U5      n	UR                  U	5        [        US   5      (       a  U/US   S   S S &  GNUS==   [        R                   " SSU5      -  ss'    GNf = f! [6         a    Sn GNf = f)#NzDocument tree is empty.r   rfc2822classeszADocument does not begin with an RFC-2822 header; it is not a PEP.pep   z?"PEP" header must contain an integer; "%s" is an invalid value.)	base_nodez(none))refid z3Document does not contain an RFC-2822 "PEP" header.   titlez	No title!z4PEP header field body contains multiple elements:
%s)levelz=PEP header field body may only contain a single paragraph:
%szlast-modifiedz%d-%b-%Ysource   unknownrefuriauthorzdiscussions-to)replaceszreplaced-byrequires z,?\s+zcontent-type   version))lendocumentr   
isinstancer   
field_listastextlowerintpep_cvs_url
ValueErrorreporterwarningset_idproblematicadd_backref	paragraphpendingPEPZeroinsertnote_pendingpformattimestrftime	localtimeosstatOSError	referencereplace_self
mask_emailTextresplitextendsettingspep_base_urlpep_urlr   clean_rcs_keywordsrcs_keyword_substitutions)selfheaderr   fieldvaluecvs_urlmsgmsgidprbprbidr6   namebodydateparanodenewbodyspacerefpeppepnopep_typeuris                         R/home/james-whalen/.local/lib/python3.13/site-packages/docutils/transforms/peps.pyapplyHeaders.apply,   s(   4==!!566q!65#3#344y 11 7 8 8EQx &&(E1a)Ae*C"..4G  + , ; & ' '!8mmG,GMM  G,MM&&w/v;?fQil11399;wFK((E8??$**,D8D4y1} !027--a-2H!I J JTa!$q'5??;;# %>&+mm!m&<%= > > < (%=="rwwt}}X/F'G'JKMD
 EOOBD IK KD 7Dx D!$88))*T*:; ! )) D!$88))*T*?@ ! @@

3 hhx?FKENN"F$(MM$:$:$G$G&*llU&:%;
 $  @ "#2,Q(((/M/MN;;=D$r4HIDG  ';;=mm,,99DLL2<MM ??2xDEQ"s4yy((/M/MNs 5 " AC"G--0088)+./:? 9 AC !MM005E++E3DH279C MM005EOOE*58}}*-aAaEOOBC$@@AT  %$D%s,   *S6AW6B9W2#WWW,+W, N)__name__
__module____qualname____firstlineno____doc__default_priorityrJ   r.   rE   compile
IGNORECASErL   rb   __static_attributes__rd       ra   r   r      s\     G5K 
0MM
#$)	+	,	-u5!cOrn   r   c                  &    \ rS rSrSrSrSS jrSrg)Contents   zr
Insert an empty table of contents topic and a transform placeholder into
the document after the RFC 2822 header.
i|  c                   [         R                  " U R                  R                  R                  U R                  R
                  5      nUR                  S   n[        R                  " SU5      n[        R                  " SUS/S9n[        R                  " U5      nU R                  R                  U5      (       d  US   R                  U5        U R                  R                  U5        [        R                  " [        R                   5      nXE-  nU R                  R#                  SU5        U R                  R%                  U5        g )Ncontentsr   )r   namesr   )r   get_languager(   rH   language_coder0   labelsr   r   topicfully_normalize_namehas_nameappendnote_implicit_targetr6   r
   rp   r8   r9   )rM   languagerV   r   rx   r6   s         ra   rb   Contents.apply   s    ))$--*@*@*N*N*.--*@*@Bz*B%B
|<))$/}}%%d++'N!!$'**51--/Q&""7+rn   rd   NreturnNonere   rf   rg   rh   ri   rj   rb   rm   rd   rn   ra   rp   rp      s    
 ,rn   rp   c                  0    \ rS rSrSrSrSS jrSS jrSrg)	TargetNotes   z
Locate the "References" section, insert a placeholder for an external
target footnote insertion transform at the end, and schedule the
transform to run immediately.
i  c                   U R                   n[        U5      S-
  nS =p4US:  a  [        X   [        R                  5      (       ar  X   S   R                  5       R                  5       R                  5       nSU;   a  X   nO6SU;   a  UnUS-  nUS:  a#  [        X   [        R                  5      (       a  Mr  U(       dj  [        R                  " 5       nU[        R                  " SS5      -  nUR                  U5        U(       a  UR                  XC5        OUR                  U5        [        R                  " [        R                  5      nUR                  U5        U R                   R                  US5        [        R                  " [         R"                  SU R$                  0S9nUR                  U5        U R                   R                  US5        g )	Nr   r   r   	copyrightr   
Referencescallback)details)r(   r'   r)   r   sectionr+   r,   rF   r   r2   r8   r{   r6   r   r   r9   r   CallBackcleanup_callback)rM   docirefsect
copyright_title_wordsr6   s          ra   rb   TargetNotes.apply   sg   mmHqL##1fCFEMM::&)**,224::<K{*&+
FA 1fCFEMM:: mmoGu{{2|44GJJw

:/ 

7#--
 6 67w""7A.--)3T5J5J(KMw""7A.rn   c                    [        UR                  5      S:X  a0  UR                  R                  R                  UR                  5        gg)zi
Remove an empty "References" section.

Called after the `references.TargetNotes` transform is complete.
r   N)r'   parentremove)rM   r6   s     ra   r   TargetNotes.cleanup_callback   s6     w~~!#NN!!((8 $rn   rd   Nr   )	re   rf   rg   rh   ri   rj   rb   r   rm   rd   rn   ra   r   r      s     /<9rn   r   c                  &    \ rS rSrSrSrSS jrSrg)r7      z
Special processing for PEP 0.
i  c                    [        U R                  5      nU R                  R                  U5        U R                  R                  R                  U R                  5        g N)PEPZeroSpecialr(   walk	startnoder   r   )rM   visitors     ra   rb   PEPZero.apply   s>     /7#$$T^^4rn   rd   Nr   r   rd   rn   ra   r7   r7      s     5rn   r7   c                  r    \ rS rSrSr\R                  rSS jrSS jrS r	SS jr
SS jrSS jrSS	 jrS
rg)r      z
Perform the special processing needed by PEP 0:

- Mask email addresses.

- Link PEP numbers in the second column of 4-column tables to the PEPs
  themselves.
c                    g r   rd   rM   rZ   s     ra   unknown_visitPEPZeroSpecial.unknown_visit   s    rn   c                8    UR                  [        U5      5        g r   )rB   rC   r   s     ra   visit_referencePEPZeroSpecial.visit_reference   s    *T*+rn   c                6    SUS   ;   a  [         R                  eg )Nr   r   )r   SkipNoder   s     ra   visit_field_listPEPZeroSpecial.visit_field_list   s    Y'..  (rn   c                ,    US   S:H  U l         SU l        g )Ncols   r   )	pep_tableentryr   s     ra   visit_tgroupPEPZeroSpecial.visit_tgroup  s    f*
rn   c                    U =R                   S-  sl         U R                  (       a&  U R                   S:X  a  US   R                  S5        g g g )Nr   r   r   num)r   r   r{   r   s     ra   visit_colspecPEPZeroSpecial.visit_colspec  s9    

a
>>djjAoO""5) .>rn   c                    SU l         g )Nr   )r   r   s     ra   	visit_rowPEPZeroSpecial.visit_row  s	    
rn   c                   U =R                   S-  sl         U R                  (       a  U R                   S:X  a  [        U5      S:X  a  US   R                  S5        US   n[	        U[
        R                  5      (       au  [        U5      S:X  ae  UR                  5       n [        U5      nU R                  R                  R                  U R                  U-  -   n[
        R                  " X3US9US'   g g g g g g ! [         a     g f = f)Nr   r   r   r   r   r   )r   r   r'   r{   r)   r   r5   r+   r-   r(   rH   rI   rJ   rA   r/   )rM   rZ   ptextr   refs         ra   visit_entryPEPZeroSpecial.visit_entry  s    

a
>>djjAo#d)q.O""5)QA!U__--#a&A+xxzd)C==11>>!\\C/0C ??4cBAaD 3>- 3Ao> " s   AC7 7
DD)r   r   Nr   )re   rf   rg   rh   ri   r   rJ   r   r   r   r   r   r   r   rm   rd   rn   ra   r   r      s5     ooG,!*
rn   r   )zpeps@python.orgzpython-list@python.orgzpython-dev@python.orgc                6   U R                  S5      (       a  U S   R                  S5      (       ai  U S   SS [        ;   a  U S   nO6U R                  5       R	                  SS5      n[
        R                  " SUS	S
9nUc  U$ U S==   SU-  -  ss'   U/U SS& U $ U $ )a  
Mask the email address in `ref` and return a replacement node.

`ref` is returned unchanged if it contains no email address.

For email addresses such as "user@host", mask the address as "user at
host" (text) to thwart simple email address harvesters (except for those
listed in `non_masked_addresses`).  If a PEP number (`pepno`) is given,
return a reference including a default email subject.
r   zmailto:r   Nr   @z&#32;&#97;t&#32;r   html)formatz?subject=PEP%%20%s)hasattr
startswithnon_masked_addressesr+   replacer   raw)r   r^   replacementreplacement_texts       ra   rC   rC   #  s     {{8X!9!9)!D!Dx= 44a&K"zz|33C9KL))B(8HK=M1E99M!]CFJ
rn   r   )ri   
__future__r   __docformat__r>   rE   r;   docutilsr   r   r   r   docutils.transformsr	   r
   r   r   r   rp   r   r7   SparseNodeVisitorr   r   rC   rd   rn   ra   <module>r      s   
 #" 	 	  , ,  ) 7 7tOi tOn,y ,2/9) /9d5i 50U,, 0f1 
rn   