
    ,hz-                     <   d dl Z d dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ ej$                  Z G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Zd Zd Zd Z ed      Zd Z	 dddddddZed        Zy)    N)compile)	signaturegetdoc	Parameter)ArgumentParser)contextmanager)wraps)IOBase)AutocommandErrorc                       e Zd ZdZy)AnnotationErrorzEAnnotation error: annotation must be a string, type, or tuple of bothN__name__
__module____qualname____doc__     j/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/setuptools/_vendor/autocommand/autoparse.pyr   r      s    Or   r   c                       e Zd ZdZy)PositionalArgErrorzQ
    Postional Arg Error: autocommand can't handle postional-only parameters
    Nr   r   r   r   r   r   #   s    r   r   c                       e Zd ZdZy)
KWArgErrorz:kwarg Error: autocommand can't handle a **kwargs parameterNr   r   r   r   r   r   )   s    Dr   r   c                       e Zd ZdZy)DocstringErrorzDocstring errorNr   r   r   r   r   r   -   s    r   r   c                       e Zd ZdZy)TooManySplitsErrorz
    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.
    Nr   r   r   r   r   r   1   s    r   r   c                 R   | t         u ryt        |       r| dfS t        | t              rd| fS t        | t              rD	 | \  }}t        |      rt        |t              r||fS t        |t              rt        |      r||fS t        |       # t
        $ r}t        |       |d}~ww xY w)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_descriptionr)   9   s     V	*	4	J	$Z	J	&	"#JD$ ~*T3"7Tz!D#&8D>Tz!
*
%%  	5!*-14	5s   B 	B&B!!B&c                    | j                   | j                  u rt        |       | j                   | j                  u rt	        |       i }d}t        | j                        \  }}| j                  }||t        dhvrt        |      }|t        ur||d<   d}|?|t        u r|r|t        u rd|d<   nd|d<   d}nt        |t              r
t        |d<   n||d<   | j                   | j                  u rd	|d
<   |||d<   g }	| j                  }
|r|
d   |
d   j!                         fD ]9  }||vs|j#                  |       |	j%                  dj'                  |              n t)        |
      dkD  s|	s |	j%                  dj'                  |
             |
|d<   n|	j%                  |
        |j*                  |	i | |r8|t        u r/|j+                  dj'                  |
      d|
|t        ur|nd       yyy)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)r-   r4   const)kindPOSITIONAL_ONLYr   VAR_KEYWORDr   r)   r%   r+   r   r/   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descriptionr+   flagsr<   letters               r   _add_argumentsrM   S   s#    zzU*** ''	u((	( HI 2%2B2BCHk mmG GFD>9= f%	 tg/%1"%2" I ("HV  (HV
 zzU))) & E::D1gtAw//11 	F^+""6*U\\&12		 t9q=LLt,-TF+(+ 8t#T" $F2'	 	 	? $wr   c                     t        ||      }dh}t        | j                  j                         d       }|D ]  }t	        ||||        |S )zE
    Given the signature of a function, create an ArgumentParser
    )rJ   epiloghc                 2    t        | j                        dkD  S Nr3   )rA   r<   )rC   s    r   <lambda>zmake_parser.<locals>.<lambda>   s    #ejj/A- r   )key)r   sorted
parametersvaluesrM   )func_sigrJ   rO   rF   rD   rE   paramsrC   s           r   make_parserrZ      s^     FCFUN
 ""$-/F  ?ufng>? Mr   z\n\s*-{4,}\s*\nc                     | yt         j                  |       }t        |      dk(  r| dfS t        |      dk(  r
|d   |d   fS t               )zH
    Given a docstring, parse it into a description and epilog part
    ) r\   r3   r\      r   )_DOCSTRING_SPLITsplitrA   r   )	docstringpartss     r   parse_docstringrb      sY     ""9-E
5zQ"}	UqQxq!! ""r   FrJ   rO   rF   rD   c                      fdS t               t        t                     \  }}t        xs |xs |      t	               d fd	       } |_        |_        |S )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                 $    t        |       S )Nrc   )	autoparse)frF   rJ   rO   rD   s    r   rS   zautoparse.<locals>.<lambda>  s    ;	 r   c                     | t         j                  dd  } j                         }|j                  j	                  t        j                  |                     |j                  i |j                  S rR   )	sysargvbind_partial	argumentsupdatevars
parse_argsargskwargs)rj   parsed_argsfuncrX   rD   s     r   autoparse_wrapperz$autoparse.<locals>.autoparse_wrapper"  sg    <88AB<D
 ++-$$T&*;*;D*A%BC[%%<););<<r   N)r   rb   r   rZ   r	   rs   rD   )	rs   rJ   rO   rF   rD   docstr_descriptiondocstr_epilogrt   rX   s	   `````   @r   rf   rf      s    P | 	 H(7t(E%~--#m	 4[
= 
= "%r   c              /      K   t        | t        t        t        f      rt	        | g|i |5 }| ddd       y|  y# 1 sw Y   yxY ww)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_filerp   rq   files       r   
smart_openr~   7  sU     $ "S%$56"4T4V4 	J	 	 	 	s   +AA A A	Aru   ) ri   rer   compile_regexinspectr   r   r   argparser   
contextlibr   	functoolsr	   ior
   autocommand.errorsr   emptyr   r   r   r   r   r   r)   rM   rZ   r^   rb   rf   r~   r   r   r   <module>r      s   $  ' 0 0 # %   / 
P& P) E! E%  &4i?X* !!34 #$ LL^  r   