
    n&phE              	         S r SSKJr  SSKrSSKrSSKrSSKrSSKJr  SSK	J
r
  SSKJrJr  Sr\R                  " S	\ S
35      r\R                  " S\ S\ S35      r\R'                  SS5      r " S S5      rSS jr\R.                   V s0 s H  n \" U 5      S_M     sn rS rS r " S S5      r\S:X  a<  SrS H3  r\ " S\ 35        \ " SRC                  \" \\5      5      5        \ " 5         M5     ggs  sn f )a6  distutils.fancy_getopt

Wrapper around the standard getopt module that provides the following
additional features:
  * short and long options are tied together
  * options have help strings, so fancy_getopt could potentially
    create a complete usage summary
  * options set attributes of a passed-in object
    )annotationsN)Sequence)Any   )DistutilsArgErrorDistutilsGetoptErrorz[a-zA-Z](?:[a-zA-Z0-9-]*)^$z^(z)=!(z)$-_c                      \ rS rSrSrSS jrS rS rSS jrS r	S	 r
S
 rS rS rS rSSS jjrS rSS jrSS jrSrg)FancyGetopt%   a  Wrapper around the standard 'getopt()' module that provides some
handy extra functionality:
  * short and long options are tied together
  * options have help strings, and help text can be assembled
    from them
  * options set attributes of a passed-in object
  * boolean options can have "negative aliases" -- eg. if
    --quiet is the "negative alias" of --verbose, then "--quiet"
    on the command line sets 'verbose' to false
Nc                    Xl         0 U l        U R                   (       a  U R                  5         0 U l        0 U l        / U l        / U l        0 U l        0 U l        0 U l	        / U l
        g N)option_tableoption_index_build_indexaliasnegative_alias
short_opts	long_opts
short2long	attr_name	takes_argoption_orderselfr   s     U/var/www/html/venv/lib/python3.13/site-packages/setuptools/_distutils/fancy_getopt.py__init__FancyGetopt.__init__1   sk     )  
 ! 
     c                    U R                   R                  5         U R                   H  nXR                   US   '   M     g )Nr   )r   clearr   )r   options     r   r   FancyGetopt._build_indexY   s6    !''F+1fQi( (r"   c                0    Xl         U R                  5         g r   )r   r   r   s     r   set_option_tableFancyGetopt.set_option_table^   s    (r"   c                    XR                   ;   a  [        SU S35      eXU4nU R                  R                  U5        X@R                   U'   g )Nz$option conflict: already an option '')r   r   r   append)r   long_optionshort_optionhelp_stringr%   s        r   
add_optionFancyGetopt.add_optionb   sU    +++&6{m1E  "=F$$V,-3k*r"   c                    XR                   ;   $ )z[Return true if the option table for this parser has an
option with long name 'long_option'.)r   r   r-   s     r   
has_optionFancyGetopt.has_optionl   s     ////r"   c                ,    UR                  [        5      $ )zTranslate long option name 'long_option' to the form it
has as an attribute of some object: ie., translate hyphens
to underscores.	translatelongopt_xlater3   s     r   get_attr_nameFancyGetopt.get_attr_nameq   s     $$]33r"   c           
         [        U[        5      (       d   eUR                  5        HM  u  p4X0R                  ;  a  [	        SU SU SU S35      eX@R                  ;  d  M:  [	        SU SU SU S35      e   g )Nzinvalid z 'z': option 'z' not defined': aliased option ')
isinstancedictitemsr   r   )r   aliaseswhatr   opts        r   _check_alias_dictFancyGetopt._check_alias_dictw   s    '4((((!--/JE---*tfBug[}M  +++*tfBug-@]S  *r"   c                4    U R                  US5        Xl        g)z'Set the aliases for this option parser.r   N)rD   r   )r   r   s     r   set_aliasesFancyGetopt.set_aliases   s    ug.
r"   c                4    U R                  US5        Xl        g)zSet the negative aliases for this option parser.
'negative_alias' should be a dictionary mapping option names to
option names, both the key and value must already be defined
in the option table.znegative aliasN)rD   r   )r   r   s     r   set_negative_aliases FancyGetopt.set_negative_aliases   s    
 	~/?@,r"   c                   / U l         / U l        U R                  R                  5         0 U l        U R
                   GH)  n[        U5      S:X  a  Uu  p#nSnO$[        U5      S:X  a  Uu  p#pEO[        SU< 35      e[        U[        5      (       a  [        U5      S:  a  [        SU S35      eUb3  [        U[        5      (       a  [        U5      S	:X  d  [        S
U S35      eXPR                  U'   U R                   R                  U5        US   S:X  a!  U(       a  US-   nUSS nSU R                  U'   OaU R                  R                  U5      nUb4  U R                  U   (       a  [        SU SU S35      eX R                   S'   SU R                  U'   U R                  R                  U5      nUb2  U R                  U   U R                  U   :w  a  [        SU SU S35      e[         R#                  U5      (       d  [        SU S35      eU R%                  U5      U R&                  U'   U(       d  GM  U R                  R                  U5        X R                  US   '   GM,     g)zPopulate the various data structures that keep tabs on the
option table.  Called by 'getopt()' before it can do anything
worthwhile.
   r      zinvalid option tuple:    zinvalid long option 'z"': must be a string of length >= 2Nr   zinvalid short option 'z"': must a single character or None=:Tzinvalid negative alias 'r=   z' takes a valueFzinvalid alias 'z%': inconsistent with aliased option 'z/' (one of them takes a value, the other doesn'tzinvalid long option name 'z)' (must be letters, numbers, hyphens only)r   r   r   r$   repeatr   len
ValueErrorr>   strr   r,   r   r   getr   
longopt_rematchr:   r   )r   r%   longshorthelprS   alias_tos          r   _grok_option_tableFancyGetopt._grok_option_table   sx   
 ''F6{a$*!TV!,2)T6 !#9&!DEE dC((CIM*+D61ST  ]
5#(>(>3u:QR?*,UG3UV  !'KKNN!!$'Bx3!CKEAbz'+t$  ..2248'~~h/26tf =//7jI 
 *.NN2&',t$ zz~~d+H#>>$'4>>(+CC.)$ 0++3* 5,,  ##D))*0 7> > 
 $(#5#5d#;DNN4 u&&u-,0a)I (r"   c                   Uc  [         R                  SS nUc  [        5       nSnOSnU R                  5         SR	                  U R
                  5      n [        R                  " XU R                  5      u  pQU GH'  u  px[        U5      S:X  a  US   S:X  a  U R                  US      nO[        U5      S:  a	  USS S	:X  d   eUSS nU R                  R                  U5      n	U	(       a  U	nU R                  U   (       d6  US
:X  d   S5       eU R                  R                  U5      n	U	(       a  U	nSnOSnU R                   U   n
U(       a+  U R"                  R                  U
5      b  [%        X*S5      S-   n['        X*U5        U R(                  R+                  Xx45        GM*     U(       a  X4$ U$ ! [        R                   a  n[        U5      eSnAff = f)a  Parse command-line options in args. Store as attributes on object.

If 'args' is None or not supplied, uses 'sys.argv[1:]'.  If
'object' is None or not supplied, creates a new OptionDummy
object, stores option values there, and returns a tuple (args,
object).  If 'object' is supplied, it is modified in place and
'getopt()' just returns 'args'; in both cases, the returned
'args' is a modified copy of the passed-in 'args' list, which
is left untouched.
Nr   TF rO   r   r   z-- zboolean option can't have value)sysargvOptionDummyr^   joinr   getoptr   errorr   rT   r   r   rW   r   r   r   rS   getattrsetattrr   r,   )r   argsobjectcreated_objectr   optsmsgrC   valr   attrs              r   rg   FancyGetopt.getopt   s    <88AB<D> ]F!N"N!XXdoo.
	)tHJD HC3x1}Q3ooc!f-3x!|BQ477!"gJJNN3'E>>#&byC"CCy++//4CCC>>#&D t{{t,8fA.2F#&$$cZ05 : <KG || 	)#C((	)s   #F2 2GGGc                J    U R                   c  [        S5      eU R                   $ )zReturns the list of (option, value) tuples processed by the
previous run of 'getopt()'.  Raises RuntimeError if
'getopt()' hasn't been called yet.
z!'getopt()' hasn't been called yet)r   RuntimeError)r   s    r   get_option_orderFancyGetopt.get_option_order  s(    
 $BCC$$$r"   c                   SnU R                    H7  nUS   nUS   n[        U5      nUS   S:X  a  US-
  nUb  US-   nXb:  d  M5  UnM9     US-   S-   S-   nSnX-
  n	S	U-  n
U(       a  U/nOS
/nU R                    H  nUSS u  pEn[        X5      nUS   S:X  a  USS nUc?  U(       a  UR                  SUSU 3 SUS    35        O_UR                  SUSU 3 35        OFU SU S3nU(       a  UR                  SUSU 3 SUS    35        OUR                  SUSU 3 35        USS  H  nUR                  X-   5        M     M     U$ )z|Generate help text (a list of strings, one per suggested line of
output) from the option table for this FancyGetopt object.
r   r   rP   rQ   N   rO   N   ra   zOption summary:rM   z  --<z  z (-))r   rT   	wrap_textr,   )r   headermax_optr%   rZ   r[   ell	opt_width
line_width
text_width
big_indentlinesr\   text	opt_namess                  r   generate_helpFancyGetopt.generate_help'  s    ''F!9D1IEd)CBx3Ag Ag} ( aK!Oa'	0 
+
9_
HE&'E''F &r
DT.DBx3Abz }LL4QwiK'847)!DELL4QwiK'8!9:
  $fCwa0	LL4	!G9'=RQy!IJLL4	!G9'=!>?ABxZ-.  - (0 r"   c                    Uc  [         R                  nU R                  U5       H  nUR                  US-   5        M     g )N
)rc   stdoutr   write)r   r}   filelines       r   
print_helpFancyGetopt.print_helpu  s5    <::D&&v.DJJtd{# /r"   )r   r   r   r   r   r   r   rS   r   r   r   r   )NNrk   zSequence[str] | None)__name__
__module____qualname____firstlineno____doc__r    r   r(   r0   r4   r:   rD   rG   rJ   r^   rg   ru   r   r   __static_attributes__ r"   r   r   r   %   sS    	&P2
40
4

-N1`;z%L\$r"   r   c                \    [        U 5      nUR                  U5        UR                  X25      $ r   )r   rJ   rg   )optionsnegative_optrl   rk   parsers        r   fancy_getoptr   |  s)    !F
-==&&r"   ra   c                   U c  / $ [        U 5      U::  a  U /$ U R                  5       n U R                  [        5      n [        R
                  " SU 5      nU Vs/ s H  o3(       d  M  UPM     nn/ nU(       a  / nSnU(       aR  [        US   5      nXg-   U::  a  UR                  US   5        US	 Xg-   nOU(       a  US   S   S:X  a  US	 O	U(       a  MR  U(       a7  US:X  a"  UR                  US   SU 5        US   US US'   US   S   S:X  a  US	 UR                  SR                  U5      5        U(       a  M  U$ s  snf )zwrap_text(text : string, width : int) -> [string]

Split 'text' into multiple lines of no more than 'width' characters
each, and return the list of strings that results.
Nz( +|-+)r   rP   ra   rb   )rT   
expandtabsr8   WS_TRANSresplitr,   rf   )r   widthchunkschr   cur_linecur_lenr   s           r   r|   r|     sO    |	
4yEv??D>>(#DXXj$'F!(6RRb6F(E
fQi.C}%q	*1I!- Q3 6  f  !|q	!E 23"1Ief-q	
 ay|s"1I 	RWWX&'A &D LK )s   
D=&D=c                ,    U R                  [        5      $ )zPConvert a long option name to a valid Python identifier by
changing "-" to "_".
r7   )rC   s    r   translate_longoptr     s     ==''r"   c                  (    \ rS rSrSr/ 4SS jjrSrg)re   i  z[Dummy class just used as a place to hold command-line option
values as instance attributes.c                .    U H  n[        XS5        M     g)zcCreate a new OptionDummy instance.  The attributes listed in
'options' will be initialized to None.N)rj   )r   r   rC   s      r   r    OptionDummy.__init__  s     CDt$ r"   r   N)r   zSequence[Any])r   r   r   r   r   r    r   r   r"   r   re   re     s    & 13 % %r"   re   __main__zTra-la-la, supercalifragilisticexpialidocious.
How *do* you spell that odd word, anyways?
(Someone ask Mary -- she'll know [or she'll
say, "How should I know?"].))
         (   zwidth: r   r   )"r   
__future__r   rg   r   stringrc   collections.abcr   typingr   errorsr   r   longopt_patcompilerX   neg_alias_rerV   	maketransr9   r   r   
whitespaceordr   r|   r   re   r   r   wprintrf   )_wschars   0r   <module>r      s   #  	  
 $  ; +ZZ1[M+,
 zzB{m4}B?@ c3'T$ T$n
' .4->->?->'CL#->?3l(% % z D smdii	$*+,  W @s   C6