+
     Ii'  c                   s    ^ RI Ht ^ RIHt RtRtRtRt ! R R]4      t ! R R4      t	 ! R R4      t
 ! R	 R
]
4      t ! R R]4      t ! R R]
4      tR# )    )
HTMLParser)zip_longestc                   sf   a a ] tR t^t oRtV 3R ltR tV 3R ltV 3R ltR t	R t
R tR	tVtV ;t# )
DocStringParserz
A simple HTML parser.  Focused on converting the subset of HTML
that appears in the documentation strings of the JSON models into
simple ReST format.
c                s>   < R V n         Wn        \        SV `  4        R # N)treedocsuper__init__)selfr   	__class__   &&H/usr/lib/python3.14/site-packages/botocore/docs/bcdoc/docstringparser.pyr   ZDocStringParser.__init__   s    	    c                sf    \         P                  ! V 4       \        V P                  4      V n        R # r   )r   resetHTMLTreer   r   r	      &r   r   ZDocStringParser.reset"   s     TXX&	r   c                s   < \         SV `  V4       V P                  P                  4        \	        V P
                  4      V n        R # r   )r   feedr   writer   r   )r	   datar
   r   r   r   ZDocStringParser.feed&   s-    T		TXX&	r   c                s   < \         SV `  4        V P                  P                  4        \	        V P
                  4      V n        R # r   )r   closer   r   r   r   )r	   r
   s   &r   r   ZDocStringParser.close+   s*    		TXX&	r   c                s>    V P                   P                  WR 7       R# ))attrsNr   add_tag)r	   tagr   s   &&&r   handle_starttagZDocStringParser.handle_starttag1   s    		#+r   c                s@    V P                   P                  VR R7       R# )F)is_startNr   )r	   r      &&r   handle_endtagZDocStringParser.handle_endtag4   s    		#.r   c                s<    V P                   P                  V4       R # r   )r   add_datar	   r   r   r   handle_dataZDocStringParser.handle_data7   s    		4 r   )r   r   )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r   r    __static_attributes____classdictcell____classcell__r
   __classdict__   @@r   r   r      s2     
''
',/! !r   r   c                   sF   a  ] tR t^;t o RtR tR	R ltR tR tR t	Rt
V tR# )
r   z
A tree which handles HTML nodes. Designed to work with a python HTML parser,
meaning that the current_node will be the most recently opened tag. When
a tag is closed, the current_node moves up to the parent node.
c                s`    Wn         \        4       V n        V P                  V n        . V n        R # r   )r   StemNodeheadcurrent_nodeunhandled_tagsr	   r   r   r   r   ZHTMLTree.__init__B   s$    J	 II r   Nc                s   V P                  W4      '       g   V P                  P                  V4       R # V'       d/   \        W4      pV P                  P                  V4       W@n        R # V P                  P                  V n        R # r   )_doc_has_handlerr/   appendTagNoder.   	add_childparent)r	   r   r   r   Znodes   &&&& r   r   ZHTMLTree.add_tagH   se    $$S33&&s+3&D''- $ $ 1 1 8 8Dr   c                sh    V'       d   R V 2pMRV 2p\        V P                  P                  V4      # )start_end_)hasattrr   style)r	   r   r   handler_name   &&& r   r1   ZHTMLTree._doc_has_handlerT   s0    #C5>L!#<Ltxx~~|44r   c                sN    V P                   P                  \        V4      4       R # r   )r.   r4   DataNoder   r   r   r   ZHTMLTree.add_data\   s    ##HTN3r   c                sP    V P                   P                  V P                  4       R # r   )r-   r   r   r   r   r   r   ZHTMLTree.write_   s    		!r   )r.   r   r-   r/   )NT)r!   r"   r#   r$   r%   r   r   r1   r   r   r&   r'   r*      @r   r   r   ;   s(     !
954" "r   r   c                   s0   a  ] tR t^ct o RR ltR tRtV tR# )NodeNc                s    Wn         R # r   r5   )r	   r5   r   r   r   ZNode.__init__d   s    r   c                s    \         hr   )ZNotImplementedErrorr0   r   r   r   Z
Node.writeg   s    !!r   r@   r   )r!   r"   r#   r$   r   r   r&   r'   r=   r>   r   r?   r?   c   s     " "r   r?   c                   sl   a a ] tR t^kt oRV 3R lltR tR tR tR tR t	R t
R tR	 tR
 tRtVtV ;t# )r,   c                s4   < \         SV `  V4       . V n        R # r   )r   r   children)r	   r5   r
   r   r   r   ZStemNode.__init__l   s     r   c                sH    Wn         V P                  P                  V4       R # r   )r5   rA   r2   r	   childr   r   r4   ZStemNode.add_childp   s    U#r   c                sH    V P                  4        V P                  V4       R # r   )collapse_whitespace_write_childrenr0   r   r   r   ZStemNode.writet   s      "S!r   c                s    \        V P                  V P                  R ,          4       FC  w  r#\        V\        4      '       d   Ve   VP	                  W4       K2  VP	                  V4       KE  	  R# )   NNN)r   rA   
isinstancer3   r   )r	   r   rC   
next_child   &&  r   rE   ZStemNode._write_childrenx   sN    !,T]]DMM"<M!NE%))j.DC,C 	 "Or   c                s    \         ;QJ d&    R  V P                   4       F  '       d   K   R# 	  R# ! R  V P                   4       4      # )c              3   s@   "   T F  qP                  4       x  K  	  R # 5ir   )is_whitespace.0rC      & r   	<genexpr>Z)StemNode.is_whitespace.<locals>.<genexpr>   s     DmU&&((ms   FT)ZallrA   r   r   r   rK   ZStemNode.is_whitespace   s3    sDdmmDssDsDsDdmmDDDr   c                sl    V P                   ;'       d"    V P                   ^ ,          P                  4       # )r    )rA   startswith_whitespacer   r   r   rP   ZStemNode.startswith_whitespace   s&    }}IIq!1!G!G!IIr   c                sl    V P                   ;'       d"    V P                   R,          P                  4       # )rG   )rA   endswith_whitespacer   r   r   rR   ZStemNode.endswith_whitespace   s&    }}HHr!2!F!F!HHr   c                s   V P                   '       dB   V P                   ^ ,          P                  4       '       d   V P                   R,          V n         KS  V P                   '       d$   V P                   ^ ,          P                  4        R# R# )r    rF   N)rA   rK   lstripr   r   r   rS   ZStemNode.lstrip   sU    mmma 0 > > @ @ MM"-DM===MM!##% r   c                s   V P                   '       d>   V P                   R,          P                  4       '       d   V P                   RR V n         KO  V P                   '       d$   V P                   R,          P                  4        R# R# )rG   NrQ   )rA   rK   rstripr   r   r   rT   ZStemNode.rstrip   sW    mmmb 1 ? ? A A MM#2.DM===MM"$$& r   c                s    V P                  4        V P                  4        V P                   F  pVP                  4        K  	  R# )aN  Remove collapsible white-space from HTML.

HTML in docstrings often contains extraneous white-space around tags,
for readability. Browsers would collapse this white-space before
rendering. If not removed before conversion to RST where white-space is
part of the syntax, for example for indentation, it can result in
incorrect output.
N)rS   rT   rA   rD   rB   rN   r   rD   ZStemNode.collapse_whitespace   s0     	]]E%%' #r   )rA   r   )r!   r"   r#   r$   r   r4   r   rE   rK   rP   rR   rS   rT   rD   r&   r'   r(   r)   r+   r   r,   r,   k   s?     $"!EJI&'( (r   r,   c                   s\   a a ] tR t^t oRtR	V 3R lltR tR
R ltR tR t	R t
RtVtV ;t# )r3   zH
A generic Tag node. It will verify that handlers exist before writing.
c                s>   < \         SV `  V4       W n        Wn        R # r   )r   r   r   r   )r	   r   r   r5   r
   s   &&&&r   r   ZTagNode.__init__   s     
r   c                s    \         ;QJ d&    R  V P                   4       F  '       g   K   R# 	  R# ! R  V P                   4       4      # )c              3   sB   "   T F  p\        V\        4      x  K  	  R # 5ir   )rH   r3   rL   rN   r   rO   Z+TagNode._has_nested_tags.<locals>.<genexpr>   s     I=%:eW--=s   TF)ZanyrA   r   r   r   _has_nested_tagsZTagNode._has_nested_tags   s3    sI4==IssIsIsI4==IIIr   c                s   V P                   \        9   ;'       d    V P                  4       p\        V P                  \
        4      ;'       d9    V P                  P                   \        9   ;'       d    V P                   \        9   pV'       g	   V'       d   V P                  V4       R # V P                  V4       V P                  V4       V P                  W4       R # r   )r   OMIT_SELF_TAGSrU   rH   r5   r3   PRIORITY_PARENT_TAGSOMIT_NESTED_TAGSrE   _write_start
_write_end)r	   r   rI   Zprioritize_nested_tagsZprioritize_parent_tags   &&&  r   r   ZTagNode.write   s    HH&BB4+@+@+B 	 t{{G, - -#77- -,, 	
 "%:  %#S!(r   c                s   V P                   \        9   d!   V P                  4        V P                  4        \	        V P
                  RR V P
                  R,          4       F]  w  r\        V\        4      '       g   K  VP                  4       '       g   K5  VP                  4       '       g   KM  VP                  4        K_  	  \	        V P
                  RR V P
                  R,          4       F]  w  r#\        V\        4      '       g   K  VP                  4       '       g   K5  VP                  4       '       g   KM  VP                  4        K_  	  V P
                   F  pVP                  4        K  	  R# )aQ  Remove collapsible white-space.

All tags collapse internal whitespace. Block-display HTML tags also
strip all leading and trailing whitespace.

Approximately follows the specification used in browsers:
https://www.w3.org/TR/css-text-3/#white-space-rules
https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace
NrF   rQ   )r   HTML_BLOCK_DISPLAY_TAGSrS   rT   ZziprA   rH   r<   rR   rP   rD   )r	   ZprevZcurZnxtrC   s   &    r   rD   ZTagNode.collapse_whitespace   s     88..KKMKKM T]]3B/r1BCID4**,,..--//

 D DMM#2.b0ABHC3))++----//

 C ]]E%%' #r   c                s    R V P                    2p\        VP                  V4      '       d)   \        VP                  V4      ! V P                  4       R# R# )r6   N)r   r8   r9   getattrr   )r	   r   r:   s   && r   rY   ZTagNode._write_start   s?    z*399l++CII|,TZZ8 ,r   c                s    R V P                    2p\        VP                  V4      '       dC   VR8X  d   \        VP                  V4      ! V4       R# \        VP                  V4      ! 4        R# R# )r7   Zend_aN)r   r8   r9   r\   )r	   r   rI   r:   r;   r   rZ   ZTagNode._write_end   sT    dhhZ(399l++w&		<0<		<02 ,r   )r   r   )NNr   )r!   r"   r#   r$   r%   r   rU   r   rD   rY   rZ   r&   r'   r(   r)   r+   r   r3   r3      s/     
J)" (D9
3 3r   r3   c                   st   a a ] tR t^t oRtRV 3R llt]R 4       tR tR t	R t
R tR tR	 tR
 tRtVtV ;t# )r<   z(
A Node that contains only string data.
c           	     s  < \         SV `  V4       \        V\        4      '       g   \	        R \        V4       R24      hRV n        RV n        RV n        VR8X  d   R# VP                  4       '       d	   Wn        R# \        R \        V4       4       4      p\        V4      \        R \        \        V4      4       4       4      ,
          pVRV V n        WR V n        WV V n        R# )zExpecting string type, z given. Nc              3   Z   "   T F!  w  rVP                  4       '       d   K  Vx  K#  	  R # 5ir   isspacerM   ZidxZch   &  r   rO   $DataNode.__init__.<locals>.<genexpr>  s      
.GCbjjlCC   +
+c              3   r^   r   r_   ra   rb   r   rO   rc     s       *
8GC

CC8rd   )r   r   rH   ZstrZ
ValueErrorZtype_leading_whitespace_trailing_whitespace_stripped_datar`   ZnextZ	enumerateZlenZreversed)r	   r   r5   Zfirst_non_spaceZlast_non_spacer
   s   &&&  r   r   ZDataNode.__init__   s     $$$6tDzl'JKK#% $&! 2:<<>>(,% 
(
 
 TT *
($8*
 &
 
 $((8#9 $($9!">Br   c                sN    V P                    V P                   V P                   2# r   re   rg   rf   r   r   r   r   ZDataNode.data  s1     ''()<)<(=(()+	
r   c                s|    V P                   R 8H  ;'       d'    V P                  R 8g  ;'       g    V P                  R 8g  # r]   )rg   re   rf   r   r   r   rK   ZDataNode.is_whitespace  s@    ""b( 
 
$$*MMd.G.G2.M	
r   c                |    V P                   R 8g  ;'       g'    V P                  R 8H  ;'       d    V P                  R 8g  # ri   rh   r   r   r   rP   ZDataNode.startswith_whitespace  s@    ''2- 
 
2%II$*C*Cr*I	
r   c                rj   ri   )rf   rg   re   r   r   r   rR   ZDataNode.endswith_whitespace  s@    ((B. 
 
2%HH$*B*Bb*H	
r   c                    V P                   R 8w  d
   R V n         R# V P                  R 8X  d   V P                  4        R# R# r]   N)re   rg   rT   r   r   r   rS   ZDataNode.lstrip$  s4    ##r)')D$  B&KKM 'r   c                rk   rl   )rf   rg   rS   r   r   r   rT   ZDataNode.rstrip*  s4    $$*(*D%  B&KKM 'r   c                s    R# )z4Noop, ``DataNode.write`` always collapses whitespaceN r   r   r   rD   ZDataNode.collapse_whitespace0  s    r   c                s    VP                  V P                  P                  4       4      pV P                   R P	                  V4       V P
                   2pVR8w  d   VP                  V4       R# R# )Z r]   N)Ztranslate_wordsrg   Zsplitre   Zjoinrf   r    )r	   r   ZwordsZstr_datarJ   r   r   ZDataNode.write4  sj    ##D$7$7$=$=$?@''(%(9(()+ 	 r>OOH% r   rh   r   )r!   r"   r#   r$   r%   r   Zpropertyr   rK   rP   rR   rS   rT   rD   r   r&   r'   r(   r)   r+   r   r<   r<      sL     C, 
 






& &r   r<   N)codea)Zspanirn   ro   )rp   Zb)ZpZnoteZulZli)Zhtml.parserr   Z	itertoolsr   rW   rX   rV   r[   r   r   r?   r,   r3   r<   rm   r   r   <module>rq      sp    # !$ - 3 "!j "!J%" %"P" "5(t 5(pM3h M3`H&t H&r   