
    #
3j.                        S SK Jr  S SKrS SKJr  S SKJrJrJ	r	J
r
  Sr\(       a  S SKJr  Sr " S S\R                  5      r " S	 S
\5      r " S S\5      rg)    )annotationsN)_HIGHLIGHTS_fix_legacy_win_text	rich_fill	rich_wrapF)Literalz==GENERATE_USAGE==c                  X  ^  \ rS rSr% SrSSSSSSSS	.rS
\S'    \SS rS\S'              S#U 4S jjr	\
S$S j5       r\R                  S%S j5       rS&S jrS'S jrS(S jrS)S jrS*S jrS+S jrS,S jrS-S jrS.S jrS/S jrS0S jrS0S jrS1S jrS2S jrS0S  jrS3S! jrS"rU =r$ )4RichHelpFormatter   z8An optparse HelpFormatter class that renders using rich.cyandark_orangedefault	dark_cyanboldgrey50)optparse.argsoptparse.groupsoptparse.helpoptparse.metavarzoptparse.syntaxoptparse.textoptparse.progzdict[str, r.StyleType]stylesNz	list[str]
highlightsc                B   > [         TU ]  XX45        S U l        0 U l        g N)super__init___consolerich_option_stringsselfindent_incrementmax_help_positionwidthshort_first	__class__s        Q/home/wildlama/miniconda3/lib/python3.13/site-packages/rich_argparse/_optparse.pyr   RichHelpFormatter.__init__5   s$     	)eQ*.BD     c                    U R                   c7  [        R                  " [        R                  " U R                  5      S9U l         U R                   $ )N)theme)r   rConsoleThemer   )r!   s    r'   consoleRichHelpFormatter.console@   s3    == IIAGGDKK,@ADM}}r)   c                    Xl         g r   )r   )r!   r/   s     r'   r/   r0   F   s    r)   c                <   U R                   R                  5        nU R                   R                  USSSS9  S S S 5        WR                  5       nSR	                  S UR                  S5       5       5      n[        U R                   U5      $ ! , (       d  f       N[= f)NFT )	highlight	soft_wrapend
c              3  @   #    U  H  oR                  5       v   M     g 7fr   )rstrip).0lines     r'   	<genexpr>/RichHelpFormatter._stringify.<locals>.<genexpr>O   s     D3C43Cs   )r/   captureprintgetjoinsplitr   )r!   textr>   helps       r'   
_stringifyRichHelpFormatter._stringifyJ   sv    \\!!#wLLtu"M ${{}yyD4::d3CDD#DLL$77	 $#s   B
Bc                    [        S5      eNzsubclasses must implementNotImplementedError)r!   usages     r'   rich_format_usage#RichHelpFormatter.rich_format_usageR       !"=>>r)   c                    [        S5      erH   rI   r!   headings     r'   rich_format_heading%RichHelpFormatter.rich_format_headingU   rN   r)   c                D   [        U R                  SU R                  -  -
  S5      n[        R                  " SU R                  -  5      n[        R                  R                  USS9nU R                   H  nUR                  USS9  M     [        U R                  XBU5      $ )N       r   style	optparse.style_prefix)
maxr$   current_indentr,   Textfrom_markupr   highlight_regexr   r/   )r!   rC   
text_widthindent	rich_textr4   s         r'   _rich_format_text#RichHelpFormatter._rich_format_textX   s    a$*=*=&==rB
d1112FF&&t?&C	I%%ik%J )yfEEr)   c                    U(       d  [         R                  " 5       $ U R                  U5      [         R                  " S5      -   $ Nr7   r,   r_   re   r!   descriptions     r'   rich_format_description)RichHelpFormatter.rich_format_descriptiona   s.    668O%%k2QVVD\AAr)   c                    U(       d  [         R                  " 5       $ [         R                  " S5      U R                  U5      -   [         R                  " S5      -   $ rh   ri   r!   epilogs     r'   rich_format_epilog$RichHelpFormatter.rich_format_epilogf   s;    668Ovvd|d44V<<qvvd|KKr)   c                z    U[         L a  U R                  5       nOU R                  U5      nU R                  U5      $ r   )GENERATE_USAGE_generate_usagerL   rE   )r!   rK   
rich_usages      r'   format_usageRichHelpFormatter.format_usagek   s7    N"--/J//6Jz**r)   c                B    U R                  U R                  U5      5      $ r   )rE   rR   rP   s     r'   format_heading RichHelpFormatter.format_headingr   s    t77@AAr)   c                B    U R                  U R                  U5      5      $ r   )rE   rl   rj   s     r'   format_description$RichHelpFormatter.format_descriptionu   s    t;;KHIIr)   c                B    U R                  U R                  U5      5      $ r   )rE   rq   ro   s     r'   format_epilogRichHelpFormatter.format_epilogx       t66v>??r)   c                $   UR                   c   eU R                  b  U R                  (       d  UR                   nOU R                  R                  R	                  UR
                  5      nU[        R                  L d  Uc  U R                  nUR                   R                  U R                  [        R                  " [        U5      5      5      n[        R                  R                  USS9nU R                   H  nUR!                  USS9  M     U$ )Nr   rX   rZ   r[   )rD   parserdefault_tagdefaultsr@   destoptparse
NO_DEFAULTNO_DEFAULT_VALUEreplacer,   escapestrr_   r`   r   ra   )r!   optionrD   default_value	rich_helpr4   s         r'   rich_expand_default%RichHelpFormatter.rich_expand_default{   s    {{&&&;;d&6&6;;D KK0044V[[AM 3 33}7L $ 5 5;;&&t'7'7#mBT9UVDFF&&t?&C	I%%ik%J )r)   c                h   / nU R                   U   nU R                  U R                  -
  S-
  n[        U5      U:  a  UR	                  S5        U R                  nOUR                  US-   5        SnUR                  U R                  5        UR	                  U5        UR                  (       a  U R                  U5      n[        U R                  X`R                  5      nUR	                  [        R                  " SU-  5      US   -   S-   5        [        R                  " SU R                  -  5      nUSS   H  n	UR	                  X-   S-   5        M     O:UR                  S   S:w  a&  UR	                  [        R                  " S5      5        O [        R                  " 5       R                  U5      $ )NrU   r7   r   rW      )r   help_positionr^   lenappend
set_lengthpad_leftrD   r   r   r/   
help_widthr,   r_   plainrA   )
r!   r   resultopts	opt_widthindent_first	help_text
help_linesrc   r;   s
             r'   rich_format_option$RichHelpFormatter.rich_format_option   sS   !''/&&)<)<<q@	t9y KK--LOOIM*Ld))*d;;008I"4<<OOLJMM!&&|!34z!}DtKLVVC$"4"445F"12fmd23 'ZZ^t#MM!&&,'vvx}}V$$r)   c                B    U R                  U R                  U5      5      $ r   )rE   r   )r!   r   s     r'   format_optionRichHelpFormatter.format_option   r   r)   c                   U R                  5         SnUR                   H]  nU R                  U5      nUR                  U R                  U'   X@R
                  U'   [        U[        U5      U R                  -   5      nM_     U R                  5         UR                   Hp  nUR                   H]  nU R                  U5      nUR                  U R                  U'   X@R
                  U'   [        U[        U5      U R                  -   5      nM_     Mr     U R                  5         U R                  5         [        US-   U R                  5      U l        [        U R                  U R                  -
  S5      U l        g )Nr   rU   rV   )rc   option_listrich_format_option_stringsr   option_stringsr   r]   r   r^   option_groupsdedentminr#   r   r$   r   )r!   r   max_lenoptstringsgroups         r'   store_option_strings&RichHelpFormatter.store_option_strings   s/   %%C55c:G'.}}D$,3$$S)'3w<$2E2E#EFG	 &
 	))E((99#>+2==##C(07((-gs7|d6I6I'IJ	 ) * 	 1d.D.DEdjj4+=+==rBr)   c           
     <   UR                  5       (       GaV  UR                  (       a  UR                  nO)UR                  c   eUR                  R                  5       nU R                  R                  SS5      nUR                   Vs/ s HT  n[        R                  " U5      R                  [        R                  " US5      [        R                  " US5      /5      PMV     nnU R                  R                  SS5      nUR                   Vs/ s HT  n[        R                  " U5      R                  [        R                  " US5      [        R                  " US5      /5      PMV     nnO^UR                   Vs/ s H  n[        R                  " USS9PM     nnUR                   Vs/ s H  n[        R                  " USS9PM     nnU R                  (       a  XW-   nOXu-   n[        R                  " S5      R                  U5      $ s  snf s  snf s  snf s  snf )Nz%sr3   r   r   rX   z, )takes_valuemetavarr   upper_short_opt_fmtr   _short_optsr,   r_   rA   _long_opt_fmt
_long_optsr%   )	r!   r   r   s_delimo
short_optsl_delim	long_optsr   s	            r'   r   ,RichHelpFormatter.rich_format_option_strings   s   ~~ ..{{... ++++-))11$;G
  ++	 ,A w$$VVA/AS1TU ,	   ((00r:G
  **	 +A w$$VVA/AS1TU +	  I EKDVDVWDVq!&&/:DVJWCICTCTUCTa9CTIU)D)Dvvd|  &&- XUs   AH
AH;H*Hc                   U R                   c  [        S5      eSn/ nU R                  U5      R                  U5      S   nUR	                  UR                  S5      5        US   R                  U R                   R                  5       S5        [        US   5      S-   nU R                   R                   GHj  nUR                  [        R                  :X  a  M$  UR                  (       a  UR                  S   OUR                  5       n[        R                  " S5      R                  US	5      nUR!                  5       (       aN  UR"                  =(       d    UR$                  R'                  5       nUR                  S
5      R                  US5        UR                  S5        [        US   5      [        U5      -   S-   U R(                  :  a.  UR                  [        R                  " S
U-  5      U-   5        GMG  US   R                  S
5      R                  U5        GMm     UR                  [        R                  " 5       5        [        R                  " S5      R+                  U5      $ )z0Generate usage string from the parser's actions.z*Cannot generate usage if parser is not setz==GENERATED_USAGE_MARKER==r   r7   r   r   r   [r   rW   r   ])r   	TypeErrorrL   rB   extendr   get_prog_namer   r   rD   r   SUPPRESS_HELPr   get_opt_stringr,   r_   r   r   r   r   r$   rA   )	r!   markusage_linesprefixrc   r   opt_stroption_usager   s	            r'   ru   !RichHelpFormatter._generate_usage   s   ;;HII+$&''-33D9!<6<<-.Bt{{88:OL[_%)kk--F{{h444/5/A/Af((+vG\G\G^G66#;--gGL!!## ..?FKK,=,=,?##C(//9KL$;r?#c,&77!;djjH""166#,#7,#FGB&&s+22<@ . 	1668$vvd|  --r)   )r   r   r   r   
r"   intr#   r   r$   z
int | Noner%   zbool | Literal[0, 1]returnNone)r   	r.Console)r/   r   r   r   )rC   zr.RenderableTyper   r   rK   r   r   r.TextrQ   r   r   r   )rC   r   r   r   )rk   
str | Noner   r   )rp   r   r   r   )rK   r   r   r   )rQ   r   r   r   )rk   r   r   r   )rp   r   r   r   )r   optparse.Optionr   r   )r   r   r   r   )r   zoptparse.OptionParserr   r   )r   r   )__name__
__module____qualname____firstlineno____doc__r   __annotations__r   r   r   propertyr/   setterrE   rL   rR   re   rl   rq   rw   rz   r}   r   r   r   r   r   r   ru   __static_attributes____classcell__r&   s   @r'   r
   r
      s   B  ("'!"!&F"  (NJ	*	E	E 	E 		E
 *	E 
	E  
 ^^   8??FB
L
+BJ@%2@C('@. .r)   r
   c                  b   ^  \ rS rSrSr    S         SU 4S jjjrS	S jrS
S jrSrU =r	$ )IndentedRichHelpFormatter   z)Format help with indented section bodies.c                &   > [         TU ]  XX45        g r   r   r   r    s        r'   r   "IndentedRichHelpFormatter.__init__        	)eQr)   c                    [         R                  " S5      nX!-  nUS-  R                  5       n[        R                  " S[        U5      S5      /n[        R                  " XS9$ )Nz
Usage: %s
r3   r   r   )spans)r   _r9   r,   Spanr   r_   )r!   rK   usage_templater   r   s        r'   rL   +IndentedRichHelpFormatter.rich_format_usage   sT    !M2& 2%--/3v;(9:;vve))r)   c                    [         R                  " SU R                  -  5      R                  U S3S5      nU[         R                  " S5      -   $ )NrW   :r   r7   )r,   r_   r^   r   )r!   rQ   rC   s      r'   rR   -IndentedRichHelpFormatter.rich_format_heading  sB    vvcD///0777)1GXYaffTl""r)    )rU      Nr   r   r   r   
r   r   r   r   r   r   rL   rR   r   r   r   s   @r'   r   r      sd    3 !"!# ,-RR R 	R
 *R 
R R*# #r)   r   c                  b   ^  \ rS rSrSr    S         SU 4S jjjrS	S jrS
S jrSrU =r	$ )TitledRichHelpFormatteri  z,Format help with underlined section headers.c                &   > [         TU ]  XX45        g r   r   r    s        r'   r    TitledRichHelpFormatter.__init__  r   r)   c                    U R                  [        R                  " S5      5      n[        R                  R                  USUS5      $ )NUsagez  r7   )rR   r   r   r,   r_   assemble)r!   rK   rQ   s      r'   rL   )TitledRichHelpFormatter.rich_format_usage  s4    **8::g+>?vvweT::r)   c                    SU R                      [        U5      -  n[        R                  R	                  US4SUS4S5      $ )Nz=-r   r7   )levelr   r,   r_   r   )r!   rQ   	underlines      r'   rR   +TitledRichHelpFormatter.rich_format_heading  sD    $s7|3	vv'($<M0NPT
 	
r)   r   )r   r   Nr   r   r   r   r   r   s   @r'   r   r     sd    6 !"!# ,-RR R 	R
 *R 
R R;
 
r)   r   )
__future__r   r   rich_argparse._lazy_rich
_lazy_richr,   rich_argparse._commonr   r   r   r   TYPE_CHECKINGtypingr   rt   HelpFormatterr
   r   r   r   r)   r'   <module>r     sU   
 #  $ Y Y%^... ^.B# 1 #0
/ 
r)   