\bgz-^ddlZddlmZddlmZmZmZddlm Z ddl m Z ddl m Z ddlmZddlmZejZGd d eZGd d eZGd deZGddeZGddeZdZdZdZedZdZ dddddddZe dZdS)N)compile) signaturegetdoc Parameter)ArgumentParser)contextmanager)wraps)IOBase)AutocommandErrorceZdZdZdS)AnnotationErrorzEAnnotation error: annotation must be a string, type, or tuple of bothN__name__ __module__ __qualname____doc__y/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/setuptools/_vendor/autocommand/autoparse.pyr r sOOOOrr ceZdZdZdS)PositionalArgErrorzQ Postional Arg Error: autocommand can't handle postional-only parameters Nrrrrrr#srrceZdZdZdS) KWArgErrorz:kwarg Error: autocommand can't handle a **kwargs parameterNrrrrrr)sDDDDrrceZdZdZdS)DocstringErrorzDocstring errorNrrrrrr-srrceZdZdZdS)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. Nrrrrrr1srrc|turdSt|r|dfSt|trd|fSt|try |\}}t|rt|tr||fSt|trt|r||fSn"#t $r}t ||d}~wwxYwt |)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)_emptycallable isinstancestrtuple ValueErrorr ) annotationarg1arg2es r_get_type_descriptionr)9s Vz *   "4 J $ $ "Z J & & " "#JD$~~ "*T3"7"7 "Tz!D#&& "8D>> "Tz!  5 5 5!*--1 4 5 * % %%sB$$ C.B>>Cc|j|jurt||j|jurt |i}d}t |j\}}|j}||tdhvrt|}|tur||d<d}|G|tur|r |turd|d<nd|d<d}n%t|tr t|d<n||d<|j|jurd |d <|||d <g} |j} |r| d | d fD]E} | |vr?|| | d | nFt)| dks| s(| d| | |d<n| | |j| i||rB|tur;|d| d| |tur|nddSdSdS)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. FNdefaultT store_trueaction store_falsetype*nargshelprz-{}z--{}destz--no-{} store_const)r-r4const)kindPOSITIONAL_ONLYr VAR_KEYWORDrr)r%r+rr/boolr!r r"VAR_POSITIONALnameswapcaseaddappendformatlen add_argument) paramparserused_char_argsadd_nosarg_spec is_optionarg_type descriptionr+flagsr<letters r_add_argumentsrMSs zU*** ''' u( ( (HI2%2BCCHkmGGFD>99==f%  t   3g//%1""%2"II ( ( ("HV   (HV   zU)))& E :D1gtAw//111  F^++""6*** U\\&11222, t99q=== LLt,, - - - TF+(+++?8t##   T " " $F22''  ? ? ? ? ???##rct||}dh}t|jd}|D]}t |||||S)zE Given the signature of a function, create an ArgumentParser )rJepiloghc2t|jdkSNr3)rAr<)rCs rzmake_parser..s#ej//A-r)key)rsorted parametersvaluesrM)func_sigrJrOrFrDrEparamsrCs r make_parserrZsx F C C CFUN ""$$ - -///F??ufng>>>> Mrz\n\s*-{4,}\s*\nc|dSt|}t|dkr|dfSt|dkr|d|dfSt)zH Given a docstring, parse it into a description and epilog part N)r\r3r\r)_DOCSTRING_SPLITsplitrAr) docstringpartss rparse_docstringrbsiv  " "9 - -E 5zzQ"} UqQxq!! """rFrJrOrFrDcfdSttt\}}tp|p|t dfd }|_|_|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. Nc,t|S)Nrc) autoparse)frFrJrOrDs rrSzautoparse..s$ ; rc|tjdd}}|jt ||ji|jSrR) sysargv bind_partial argumentsupdatevars parse_argsargskwargs)rj parsed_argsfuncrXrDs rautoparse_wrapperz$autoparse..autoparse_wrapper"sr <8ABBrs7$ ''''''0000000000######%%%%%%////// PPPPP&PPP) EEEEE!EEE%&&&4i?i?i?X*!=!344###$L LLLLL^r