
    dxE              	          d Z ddlZddlZddlZddlZddlT dZ ej        dez            Z ej        deded          Z	e
                    d	d
          Z G d d          Zd Zd ej        D             Zd Zd Z G d d          Zedk    rGdZdD ]DZ edez              ed                     eee                                e             CdS dS )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
    N)*z[a-zA-Z](?:[a-zA-Z0-9-]*)z^%s$z^(z)=!(z)$-_c                   p    e Zd ZdZddZd Zd ZddZd Zd Z	d	 Z
d
 Zd Zd ZddZd ZddZddZdS )FancyGetopta  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                     || _         i | _        | j         r|                                  i | _        i | _        g | _        g | _        i | _        i | _        i | _	        g | _
        d S N)option_tableoption_index_build_indexaliasnegative_alias
short_opts	long_opts
short2long	attr_name	takes_argoption_orderselfr
   s     (  /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/distutils/fancy_getopt.py__init__zFancyGetopt.__init__)   s{     )  	  
 ! 
     c                 l    | j                                          | j        D ]}|| j         |d         <   d S )Nr   )r   clearr
   )r   options     r   r   zFancyGetopt._build_indexQ   sG    !!!' 	2 	2F+1DfQi((	2 	2r   c                 <    || _         |                                  d S r	   )r
   r   r   s     r   set_option_tablezFancyGetopt.set_option_tableV   s"    (r   c                     || j         v rt          d|z            |||f}| j                            |           || j         |<   d S )Nz'option conflict: already an option '%s')r   DistutilsGetoptErrorr
   append)r   long_optionshort_optionhelp_stringr   s        r   
add_optionzFancyGetopt.add_optionZ   se    $+++&;kIK K K "<=F$$V,,,-3Dk***r   c                     || j         v S )zcReturn true if the option table for this parser has an
        option with long name 'long_option'.)r   r   r"   s     r   
has_optionzFancyGetopt.has_optionc   s     d///r   c                 6    |                     t                    S )zTranslate long option name 'long_option' to the form it
        has as an attribute of some object: ie., translate hyphens
        to underscores.	translatelongopt_xlater'   s     r   get_attr_namezFancyGetopt.get_attr_nameh   s     $$]333r   c           
          t          |t                    sJ |                                D ]I\  }}|| j        vrt	          d|d|d|d          || j        vrt	          d|d|d|d          Jd S )Nzinvalid z 'z': option 'z' not defined': aliased option ')
isinstancedictitemsr   r    )r   aliaseswhatr   opts        r   _check_alias_dictzFancyGetopt._check_alias_dictn   s    '4(((((#MMOO 	P 	PLUCD---**59TT555%%%,I J J J$+++**=ATT555###,O P P P ,		P 	Pr   c                 @    |                      |d           || _        dS )z'Set the aliases for this option parser.r   N)r6   r   )r   r   s     r   set_aliaseszFancyGetopt.set_aliasesx   s#    ug...


r   c                 @    |                      |d           || _        dS )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)r6   r   )r   r   s     r   set_negative_aliasesz FancyGetopt.set_negative_aliases}   s)    
 	~/?@@@,r   c                    g | _         g | _        | j                                         i | _        | j        D ]$}t          |          dk    r	|\  }}}d}n-t          |          dk    r|\  }}}}nt          d|          t          |t                    rt          |          dk     rt          d|z            |:t          |t                    rt          |          dk    st          d	|z            || j        |<   | j                             |           |d
         dk    r|r|dz   }|dd
         }d| j        |<   nS| j                            |          }|-| j        |         rt          d|d|d          || j         d
<   d| j        |<   | j                            |          }|2| j        |         | j        |         k    rt          d|d|d          t                               |          st          d|z            |                     |          | j        |<   |r*| j                            |           || j        |d         <   &dS )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:    z9invalid long option '%s': must be a string of length >= 2N   z:invalid short option '%s': must a single character or None=:zinvalid negative alias 'r/   z' takes a valuezinvalid alias 'z%': inconsistent with aliased option 'z/' (one of them takes a value, the other doesn'tzEinvalid long option name '%s' (must be letters, numbers, hyphens only)r   r   r   r   repeatr
   len
ValueErrorr0   strr    r!   r   r   getr   
longopt_rematchr-   r   )r   r   longshorthelprC   alias_tos          r   _grok_option_tablezFancyGetopt._grok_option_table   s   
 ' A	1 A	1F6{{a$*!eTV!!,2)eT66 !jvv!GHHH dC(( BCIIMM* -9<@,A B B B m ,, $14Uq* ,9;@,A B B B !'DKN!!$'''Bx3-%#+%AbDz'(t$$  .22488'~h/ 222 "&xxx12 2 2
 *.DN2&'(t$ z~~d++H#>$'4>(+CCC.. "TT888-. . . ##D)) I*ACGHI I I $(#5#5d#;#;DN4  1&&u---,0a)CA	1 A	1r   c                    |t           j        dd         }|t                      }d}nd}|                                  d                    | j                  }	 t          j        ||| j                  \  }}n&# t          j        $ r}t          |          d}~ww xY w|D ].\  }}t          |          dk    r |d         dk    r| j        |d                  }n-t          |          dk    r|dd         d	k    sJ |dd         }| j                            |          }	|	r|	}| j        |         s3|d
k    s
J d            | j                            |          }	|	r|	}d}nd}| j        |         }
|r.| j                            |
          t%          ||
d          dz   }t'          ||
|           | j                            ||f           0|r||fS |S )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 r>   r   r   z-- zboolean option can't have value)sysargvOptionDummyrN   joinr   getoptr   errorDistutilsArgErrorrD   r   r   rG   r   r   r   rC   getattrsetattrr   r!   )r   argsobjectcreated_objectr   optsmsgr5   valr   attrs              r   rV   zFancyGetopt.getopt   s    <8ABB<D> ]]F!NN"N!!!XXdo..
	)tZHHJD$$| 	) 	) 	)#C(((	)  	1 	1HC3xx1}}Q3oc!f-3xx!||BQB4!""gJNN3''E >#& byyy"Cyyy+//44 CCCC>#&D  3t{t,,8fdA..2FD#&&&$$c3Z0000  	<Ks   A: :B	BBc                 <    | j         t          d          | j         S )zReturns the list of (option, value) tuples processed by the
        previous run of 'getopt()'.  Raises RuntimeError if
        'getopt()' hasn't been called yet.
        Nz!'getopt()' hasn't been called yet)r   RuntimeError)r   s    r   get_option_orderzFancyGetopt.get_option_order  s%    
 $BCCC$$r   c                    d}| j         D ]A}|d         }|d         }t          |          }|d         dk    r|dz
  }||dz   }||k    r|}B|dz   dz   dz   }d}||z
  }	d	|z  }
|r|g}nd
g}| j         D ]}|dd         \  }}}t          ||	          }|d         dk    r
|dd         }|?|r"|                    d|||d         fz             n_|                    d||fz             nD|d|d}|r"|                    d|||d         fz             n|                    d|z             |dd         D ]}|                    |
|z              |S )zGenerate help text (a list of strings, one per suggested line of
        output) from the option table for this FancyGetopt object.
        r   r?   r@   rA   N   r>   N   rP   zOption summary:r<   z  --%-*s  %sz
  --%-*s  z (-)z  --%-*s)r
   rD   	wrap_textr!   )r   headermax_optr   rJ   rK   l	opt_width
line_width
text_width
big_indentlinesrL   text	opt_namess                  r   generate_helpzFancyGetopt.generate_help  s    ' 		 		F!9D1IED		ABx3E E7{{aK!Oa'	0 
)+
9_
 	(HEE&'E' 	- 	-F &rr
D%T:..DBx3AbDz } ALL7D$q'2J!JKKKKLL$!?@@@@
 +/$$6	 9LL")9d1g!>"? @ @ @ @ LLi!7888!""X - -Z!^,,,,-r   c                     |t           j        }|                     |          D ]}|                    |dz              d S )N
)rR   stdoutrt   write)r   rj   filelines       r   
print_helpzFancyGetopt.print_helph  sN    <:D&&v.. 	$ 	$DJJtd{####	$ 	$r   r	   )NN)__name__
__module____qualname____doc__r   r   r   r%   r(   r-   r6   r8   r:   rN   rV   rd   rt   r{    r   r   r   r      s       	 	& & & &P2 2 2
  4 4 4 40 0 0
4 4 4P P P  
- - -K1 K1 K1Z; ; ; ;z% % %M M M M^$ $ $ $ $ $r   r   c                 v    t          |           }|                    |           |                    ||          S r	   )r   r:   rV   )optionsnegative_optr\   r[   parsers        r   fancy_getoptr   o  s7    !!F
---==v&&&r   c                 .    i | ]}t          |          d S )rP   )ord).0_wschars     r   
<dictcomp>r   u  s     @@@7CLL3@@@r   c                    | g S t          |           |k    r| gS |                                 } |                     t                    } t	          j        d|           }d |D             }g }|rg }d}|r\t          |d                   }||z   |k    r$|                    |d                    |d= ||z   }n|r|d         d         dk    r|d= n|\|rQ|dk    r6|                    |d         d|                    |d         |d         |d<   |d         d         dk    r|d= |                    d                    |                     ||S )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( +|-+)c                     g | ]}||S r   r   )r   chs     r   
<listcomp>zwrap_text.<locals>.<listcomp>  s    (((RR(b(((r   r   r@   rP   rQ   )rD   
expandtabsr+   WS_TRANSresplitr!   rU   )rr   widthchunksrq   cur_linecur_lenrl   s          r   ri   ri   w  s    |	
4yyEv??D>>(##DXj$''F((6(((FE
  ( 
	F1IA{e##q	***1I!A+  %Q3 6 6   
	  	 !||q	!E' 2333"1Ieff-q	
 ay|s""1I 	RWWX&&'''A   (D Lr   c                 6    |                      t                    S )zXConvert a long option name to a valid Python identifier by
    changing "-" to "_".
    r*   )r5   s    r   translate_longoptr     s     =='''r   c                       e Zd ZdZg fdZdS )rT   z_Dummy class just used as a place to hold command-line option
    values as instance attributes.c                 2    |D ]}t          | |d           dS )zkCreate a new OptionDummy instance.  The attributes listed in
        'options' will be initialized to None.N)rZ   )r   r   r5   s      r   r   zOptionDummy.__init__  s2      	% 	%CD#t$$$$	% 	%r   N)r|   r}   r~   r   r   r   r   r   rT   rT     s7        & &  " % % % % % %r   rT   __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: %drv   )r   rR   stringr   rV   distutils.errorslongopt_patcompilerH   neg_alias_rerF   	maketransr,   r   r   
whitespacer   ri   r   rT   r|   rr   wprintrU   r   r   r   <module>r      s                     +RZ+-..
 rzzKKKEFF c3''O$ O$ O$ O$ O$ O$ O$ O$d
' ' ' A@f.?@@@3 3 3l( ( (% % % % % % % % z D   kAodii		$**++,,,  r   