
    n&phz-                     @   S SK r S SKJ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  S SKJr  S SKJr  \R$                  r " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rS rS rS r\" S5      rS r SSSSSS.S jjr\S 5       rg)    N)compile)	signaturegetdoc	Parameter)ArgumentParser)contextmanager)wraps)IOBase)AutocommandErrorc                       \ rS rSrSrSrg)AnnotationError   zEAnnotation error: annotation must be a string, type, or tuple of both N__name__
__module____qualname____firstlineno____doc____static_attributes__r       [/var/www/html/venv/lib/python3.13/site-packages/setuptools/_vendor/autocommand/autoparse.pyr   r      s    Or   r   c                       \ rS rSrSrSrg)PositionalArgError#   zI
Postional Arg Error: autocommand can't handle postional-only parameters
r   Nr   r   r   r   r   r   #   s    r   r   c                       \ rS rSrSrSrg)
KWArgError)   z:kwarg Error: autocommand can't handle a **kwargs parameterr   Nr   r   r   r   r   r   )   s    Dr   r   c                       \ rS rSrSrSrg)DocstringError-   zDocstring errorr   Nr   r   r   r   r    r    -   s    r   r    c                       \ rS rSrSrSrg)TooManySplitsError1   z
The docstring had too many ---- section splits. Currently we only support
using up to a single split, to split the docstring into description and
epilog parts.
r   Nr   r   r   r   r#   r#   1   s    r   r#   c                    U [         L a  g[        U 5      (       a  U S4$ [        U [        5      (       a  SU 4$ [        U [        5      (       aU   U u  p[        U5      (       a  [        U[        5      (       a  X4$ [        U[        5      (       a  [        U5      (       a  X!4$ [        U 5      e! [
         a  n[        U 5      UeSnAff = f)z
Given an annotation, return the (type, description) for the parameter.
If you provide an annotation that is somehow both a string and a callable,
the behavior is undefined.
)NNN)_emptycallable
isinstancestrtuple
ValueErrorr   )
annotationarg1arg2es       r   _get_type_descriptionr0   9   s     V	*		4	J	$	$Z	J	&	&	"#JD ~~*T3"7"7z!D#&&8D>>z!
*
%%  	5!*-14	5s   B- -
C7CCc                 (   U R                   U R                  L a  [        U 5      eU R                   U R                  L a  [	        U 5      e0 nSn[        U R                  5      u  pgU R                  nUc  U[        S1;  a  [        U5      nU[        La  XS'   SnUbJ  U[        L a  U(       a	  U[        L a  SUS'   OSUS'   SnO#[        U[        5      (       a
  [        US'   OXdS'   U R                   U R                  L a  S	US
'   Ub  XtS'   / n	U R                  n
U(       a  U
S   U
S   R!                  5       4 H;  nX;  d  M
  UR#                  U5        U	R%                  SR'                  U5      5          O   [)        U
5      S:  d  U	(       d   U	R%                  SR'                  U
5      5        XS'   OU	R%                  U
5        UR*                  " U	0 UD6  U(       a7  U[        L a-  UR+                  SR'                  U
5      SU
U[        La  UOSS9  ggg)a~  
Add the argument(s) to an ArgumentParser (using add_argument) for a given
parameter. used_char_args is the set of -short options currently already in
use, and is updated (if necessary) by this function. If add_nos is True,
this will also add an inverse switch for all boolean options. For
instance, for the boolean parameter "verbose", this will create --verbose
and --no-verbose.
FNdefaultT
store_trueactionstore_falsetype*nargshelpr   z-{}   z--{}destz--no-{}store_const)r4   r;   const)kindPOSITIONAL_ONLYr   VAR_KEYWORDr   r0   r,   r2   r&   r6   boolr(   r
   r)   VAR_POSITIONALnameswapcaseaddappendformatlenadd_argument)paramparserused_char_argsadd_nosarg_spec	is_optionarg_typedescriptionr2   flagsrC   letters               r   _add_argumentsrT   S   s    zzU*** ''	u((	( HI 2%2B2BCH mmG GFD>9= f%	 tg/%1"%2" I (("HV  (V
 zzU))) & E::D1gtAw//11F+""6*U\\&12	 2 t9q=LLt,-T
+(+ 8t#T" $F2'	 	 	? $wr   c                     [        XS9nS1n[        U R                  R                  5       S S9nU H  n[	        XtXS5        M     U$ )z=
Given the signature of a function, create an ArgumentParser
)rQ   epiloghc                 2    [        U R                  5      S:  $ Nr:   )rH   rC   )rJ   s    r   <lambda>make_parser.<locals>.<lambda>   s    #ejj/A-r   )key)r   sorted
parametersvaluesrT   )func_sigrQ   rV   rM   rK   rL   paramsrJ   s           r   make_parserrb      sS     CFUN
 ""$-/F un>  Mr   z\n\s*-{4,}\s*\nc                     U c  g[         R                  U 5      n[        U5      S:X  a  U S4$ [        U5      S:X  a
  US   US   4$ [        5       e)z@
Given a docstring, parse it into a description and epilog part
) rd   r:   rd      r   )_DOCSTRING_SPLITsplitrH   r#   )	docstringpartss     r   parse_docstringrj      sY     ""9-E
5zQ"}	UqQxq!! ""r   FrQ   rV   rM   rK   c                   ^ ^^^^^ T c	  UUUU4S j$ [        T 5      m[        [        T 5      5      u  pVTc   [        TT=(       d    UT=(       d    UT5      m[	        T 5      SU UU4S jj5       nT Ul        TUl        U$ )a  
This decorator converts a function that takes normal arguments into a
function which takes a single optional argument, argv, parses it using an
argparse.ArgumentParser, and calls the underlying function with the parsed
arguments. If it is not given, sys.argv[1:] is used. This is so that the
function can be used as a setuptools entry point, as well as a normal main
function. sys.argv[1:] is not evaluated until the function is called, to
allow injecting different arguments for testing.

It uses the argument signature of the function to create an
ArgumentParser. Parameters without defaults become positional parameters,
while parameters *with* defaults become --options. Use annotations to set
the type of the parameter.

The `desctiption` and `epilog` parameters corrospond to the same respective
argparse parameters. If no description is given, it defaults to the
decorated functions's docstring, if present.

If add_nos is True, every boolean option (that is, every parameter with a
default of True/False or a type of bool) will have a --no- version created
as well, which inverts the option. For instance, the --verbose option will
have a --no-verbose counterpart. These are not mutually exclusive-
whichever one appears last in the argument list will have precedence.

If a parser is given, it is used instead of one generated from the function
signature. In this case, no parser is created; instead, the given parser is
used to parse the argv argument. The parser's results' argument names must
match up with the parameter names of the decorated function.

The decorated function is attached to the result as the `func` attribute,
and the parser is attached as the `parser` attribute.
c                    > [        U TTTTS9$ )Nrk   )	autoparse)frM   rQ   rV   rK   s    r   rZ   autoparse.<locals>.<lambda>  s    ;	r   c                    > U c  [         R                  SS  n TR                  5       nUR                  R	                  [        TR                  U 5      5      5        T" UR                  0 UR                  D6$ rY   )	sysargvbind_partial	argumentsupdatevars
parse_argsargskwargs)rs   parsed_argsfuncr`   rK   s     r   autoparse_wrapper$autoparse.<locals>.autoparse_wrapper"  sg    <88AB<D
 ++-$$T&*;*;D*A%BC[%%<););<<r   N)r   rj   r   rb   r	   r|   rK   )	r|   rQ   rV   rM   rK   docstr_descriptiondocstr_epilogr}   r`   s	   `````   @r   rn   rn      s    P | 	 H(7t(E%~--#m	 4[
= 
= 
= "%r   c              /      #    [        U [        [        [        45      (       a  [	        U /UQ70 UD6 nUv   SSS5        gU v   g! , (       d  f       g= f7f)a%  
This context manager allows you to open a filename, if you want to default
some already-existing file object, like sys.stdout, which shouldn't be
closed at the end of the context. If the filename argument is a str, bytes,
or int, the file object is created via a call to open with the given *args
and **kwargs, sent to the context, and closed at the end of the context,
just like "with open(filename) as f:". If it isn't one of the openable
types, the object simply sent to the context unchanged, and left unclosed
at the end of the context. Example:

    def work_with_file(name=sys.stdout):
        with smart_open(name) as f:
            # Works correctly if name is a str filename or sys.stdout
            print("Some stuff", file=f)
            # If it was a filename, f is closed at the end here.
N)r(   r)   bytesintopen)filename_or_filery   rz   files       r   
smart_openr   7  sN     $ "S%$566"4T4V4J 54  54s   0AAA
AAr   ) rr   rer   compile_regexinspectr   r   r   argparser   
contextlibr   	functoolsr	   ior
   autocommand.errorsr   emptyr&   r   r   r   r    r#   r0   rT   rb   rf   rj   rn   r   r   r   r   <module>r      s   $  ' 0 0 # %   / 
P& P) E! E%  &4i?X* !!34 #$ LL^  r   