jf{J dZddlZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Z ej rddlZdd lmZdd lmZdd lmZddlmZejdZeZdejedejedejejej eejej!edfej"effdZ#dedejeeffdZ$dedej!ddefdZ%dedej"efdZ&GddZGddZGdd Z'Gd!d"Z(dS)#a; This module started out as largely a copy paste from the stdlib's optparse module with the features removed that we do not need from optparse because we implement them in Click on a higher level (for instance type handling, help formatting and a lot more). The plan is to remove more and more from here over time. The reason this is a different module and not optparse from the stdlib is that there are differences in 2.x and 3.x about the error messages generated and optparse in the stdlib uses gettext for no good reason and might cause us issues. Click uses parts of optparse written by Gregory P. Ward and maintained by the Python Software Foundation. This is limited to code in parser.py. Copyright 2001-2006 Gregory P. Ward. All rights reserved. Copyright 2002-2006 Python Software Foundation. All rights reserved. N)deque)gettext)ngettext)BadArgumentUsage)BadOptionUsage) NoSuchOption) UsageError)Argument)Context)Option) ParameterVargs nargs_specreturnctt|}g}ddddtjtffd |r|}||dkr|n|dkrUfdt |D}||t|n;|dkr5td t||d|ˉ6t|<gt|dzd|dzd<t|tfS) aGiven an iterable of arguments and an iterable of nargs specifications, it returns a tuple with all the unpacked arguments at the first index and all remaining arguments as the second. The nargs specification is the number of arguments that should be consumed or `-1` to indicate that this position should eat up all the remainders. Missing items are filled with `None`. Ncz te.Deque[V]rc| |S|S#t$rYdSwxYwN)popleftpop IndexError)rsposs l/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/click/parser.py_fetchz_unpack_args.._fetchBsJ |yy{{"uuww   44 s-- ;;rc&g|] }Sr).0_rrs r z _unpack_args..Ts!444!444rzCannot have two nargs < 0) rtOptionalrappendrangereversetuple TypeErrorlenreversedlist)rrrvnargsxrrs` @@r _unpack_argsr01s ;;Dz""JDFB D-AJqM z"" =  A:: IIffTll # # # # QYY44444uU||444A IIeAhh     QYY ;<<<r77D IIdOOO- 4 ;;4!"TAXZZ.114!8:: 99d4jj  r"optc|dd}|rd|fS|dd|kr|dd|ddfS||ddfS)Nr)isalnum)r1firsts r split_optr7msh GE }}3w 1Q3x52A2wABB #abb'>r"ctxr cn||j|St|\}}|||Sr)token_normalize_funcr7)r1r8prefixs r normalize_optr<vsB {c.6 C..KFC 5c..s33 5 55r"stringcddl}||d}d|_d|_g} |D]}||n*#t$r||jYnwxYw|S)aSplit an argument string as with :func:`shlex.split`, but don't fail if the string is incomplete. Ignores a missing closing quote or incomplete escape sequence and uses the partial token as-is. .. code-block:: python split_arg_string("example 'my file") ["example", "my file"] split_arg_string("example my\") ["example", "my"] :param string: String to split. rNT)posixr3)shlexwhitespace_split commentersr% ValueErrortoken)r=r@lexoutrDs rsplit_arg_stringrG}sLLL ++fD+ ) )CCCN C  E JJu       39  JsA$A/.A/ceZdZ ddddejedejedejeded ejejf d Z e d e fd Z d ejddd dfdZ dS)r Nrobj CoreOptionoptsdestactionr.constcg|_g|_t|_|D]}t |\}} |st d|d|j|dt|dkr.t| dkr|j||j||j||d}||_ ||_ ||_ ||_ ||_ dS)Nz$Invalid start character for option ()rrstore) _short_opts _long_optssetprefixesr7rCaddr*r%rLrMr.rNrI) selfrIrKrLrMr.rNr1r;values r__init__zOption.__init__s$'EE  * *C%cNNMFE P !N!N!N!NOOO M  fQi ( ( (6{{aCJJ!OO '',,,,&&s+++ !!&)))) >F    r"rc|jdvS)N)rQr%)rM)rWs r takes_valuezOption.takes_values{111r"rXstate ParsingStatech|jdkr||j|j<n|jdkr|j|j|j<n|jdkr4|j|jg|n|jdkr9|j|jg|jnT|jdkr1|j|jddz|j|j<ntd|jd |j|j dS) NrQ store_constr% append_constcountrrzunknown action '') rMrKrLrN setdefaultr%getrCorderrI)rWrXr\s rprocesszOption.processs! ;' ! !$)EJty ! ! [M ) )$(JEJty ! ! [H $ $ J ! !$)R 0 0 7 7 > > > > [N * * J ! !$)R 0 0 7 7 C C C C [G # #$)JNN49a$@$@1$DEJty ! !> >>>?? ? 48$$$$$r"NrN)__name__ __module__ __qualname__r#Sequencestrr$intAnyrYpropertyboolr[rfrr"rr r s #'#' jojo   3   z!% B2T222X2 %QU %> %d % % % % % %r"r ceZdZd dddejedefdZdejejeej ejefdd d d fd Z d S)r rrI CoreArgumentrLr.c0||_||_||_dSr)rLr.rIrWrIrLr.s rrYzArgument.__init__s  r"rXr\r]rNc|jdkrt|Jtd|D}|t|krd}nA|dkr;tt d|j|j|jdkr|jj|dkrd}||j |j<|j |jdS)Nrc3K|]}|dV dS)Nrrrr/s r z#Argument.process..s"66aAIIIII66r"rz'Argument {name!r} takes {nargs} values.namer.r) r.sumr*rr formatrLrIenvvarrKrer%)rWrXr\holess rrfzArgument.processs :>>$$$66566666EE ""!&?@@GG!YdjH :   ; E % 49 48$$$$$r"r) rhrirjr#r$rlrmrYUnionrkrfrr"rr r sN!*S/# %wqz# 1:c?(CCD%%  %%%%%%r"r c4eZdZdejeddfdZdS)r]rargsrNc>i|_g|_||_g|_dSr)rKlargsrre)rWrs rrYzParsingState.__init__s"(* "$  .0 r")rhrirjr#ListrlrYrr"rr]r]s<1afSk1d111111r"r]c$eZdZdZd!dejdddfdZ d"dd d ejed ejed ejed e dejej ddfdZ d#ddd ejed e ddfdZ dej edejejeej fej eej dffdZdeddfdZdeddfdZdedejededdfdZdededdfdZdedededej fdZdededdfd ZdS)$ OptionParsera+The option parser is an internal class that is ultimately used to parse options and arguments. It's modelled after optparse and brings a similar but vastly simplified API. It should generally not be used directly as the high level Click classes wrap it for you. It's not nearly as extensible as optparse or argparse as it does not implement features that are implemented on a higher level (such as types or defaults). :param ctx: optionally the :class:`~click.Context` where this parser should go with. Nr8r rc||_d|_d|_||j|_|j|_i|_i|_ddh|_g|_dS)NTF---)r8allow_interspersed_argsignore_unknown_options _short_opt _long_opt _opt_prefixes_args)rWr8s rrYzOptionParser.__init__ s_ .2$ -2# ?+.+FD (*-*DD '/1.0!4[') r"rrIrJrKrLrMr.rNcfd|D}t||||||}j|j|jD] }|j|< |jD] }|j|< dS)azAdds a new option named `dest` to the parser. The destination is not inferred (unlike with optparse) and needs to be explicitly provided. Action can be any of ``store``, ``store_const``, ``append``, ``append_const`` or ``count``. The `obj` can be used to identify the option in the order list that is returned from the parser. c:g|]}t|jSr)r<r8)rr1rWs rr!z+OptionParser.add_option..4s%=== c48,,===r")rMr.rNN)r rupdaterUrRrrSr) rWrIrKrLrMr.rNoptionr1s ` r add_optionzOptionParser.add_option#s">======T4e5QQQ !!&/222% * *C#)DOC $ ) )C"(DN3   ) )r"rrcZ|jt|||dS)zAdds a positional argument named `dest` to the parser. The `obj` can be used to identify the option in the order list that is returned from the parser. )rLr.N)rr%r rts r add_argumentzOptionParser.add_argument<s/ (3T???@@@@@r"r CoreParameterct|} ||||n$#t$r|j |jjsYnwxYw|j|j|jfS)aZParses positional arguments and returns ``(values, args, order)`` for the parsed options and arguments as well as the leftover arguments if there are any. The order is a list of objects as they appear on the command line. If arguments appear multiple times they will be memorized multiple times as well. ) r]_process_args_for_options_process_args_for_argsr r8resilient_parsingrKrre)rWrr\s r parse_argszOptionParser.parse_argsFsT""   * *5 1 1 1  ' ' . . . .   xtx'A  z5; 33s*<AAr\ct|j|jzd|jD\}}t |jD]!\}}||||"||_g|_dS)Ncg|] }|j Sr)r.rws rr!z7OptionParser._process_args_for_args..Zs'D'D'DA'D'D'Dr")r0rrr enumeraterf)rWr\pargsridxargs rrz#OptionParser._process_args_for_argsXs" K%+ %'D'D'D'D'D  t"$*-- + +HC KKc E * * * *  r"cb|jr|jd}t|}|dkrdS|dd|jvr|dkr|||n?|jr|j|n|jd|dS|jdSdS)Nrrr) rrr*r _process_optsrrr%insert)rWr\rarglens rrz&OptionParser._process_args_for_optionscsk +//!$$CXXFd{{RaRD...6A::""3....-  ""3'''' ""1c***k     r"r1explicit_valuec||jvr.ddlm}|||j}t|||j|j|}|jr5||jd|||||}n5|1t|td |d}| ||dS)Nr)get_close_matches) possibilitiesr8z&Option {name!r} does not take a value.)rz) rdifflibrr r8r[rr_get_value_from_staterr r}rf)rWr1rr\rrrrXs r_match_long_optzOptionParser._match_long_opts dn $ $ 1 1 1 1 1 1--c4>BBMs-TXNNN N$    ) ""1n555..sFEBBEE  ' Q?@@GGSGQQ  Eue$$$$$r"rcxd}d}|d}g}|ddD]}t|||j}|j|} |dz }| s3|jr||Yt ||j| jrP|t|kr%|j d||dd}| || |} nd} | | ||rn|jr5|r5|j |d|dSdSdS)NFrr)r8Tr3)r<r8rrdrr%r r[r*rrrrfrjoin) rWrr\stopir;unknown_optionschr1rrXs r_match_short_optzOptionParser._match_short_opts Qabb'  B62::C_((--F FA 6.#**2..."3DH5555! s3xx<<K&&q#abb'222D223FF NN5% ( ( (    & F? F K  &D"''/*B*BDD E E E E E F F F Fr" option_namerc|j}t|j|krH|jjrt}nt |t dd||||dkru|jd}|jjrAt|tr,|dd|j vrt|dkrt}nA|j d}n&t|jd|}|jd|=|S)Nz%Option {name!r} requires an argument.z+Option {name!r} requires {nargs} arguments.ryrr) r.r*rrI_flag_needs_valuerrr} isinstancerlrrr()rWrrr\r.rX next_rargs rrz"OptionParser._get_value_from_states  u{  e # #z+ )$?Ef+Uf;; aZZ AI , +y#.. +bqbMT%777 NNQ&&* **%+fuf-..E FUF# r"c^d}d|vr|dd\}}n|}t||j} ||||dS#t$rP|dd|jvr|||YdS|js|j |YdSwxYw)N=rr4) splitr<r8rr rrrrr%)rWrr\rlong_opt norm_long_opts rrzOptionParser._process_optss #::'*yya'8'8 $HnnH%h99  $   F F F F F $ $ $2A2wd000%%c5111.  K  s # # # # # # $sA1B,"B,+B,rrgr)rhrirj__doc__r#r$rYrkrlrmrnrrrTupleDictrr]rrrrr rrrr"rrrs  **AJy1*T****:#'#')) )jo)jo )  3 )  )z!% ) ))))4HIAA!A)*CAADA AAAA4F3K4 QU #QVC[!&2II J4444$ L T    |H%%() 3%@L% %%%%<&FC&F &F&F&F&F&FP$$(.$7C$ $$$$L$$\$d$$$$$$r"r))rtypingr# collectionsrrr r exceptionsrrr r TYPE_CHECKINGtyping_extensionstecorer rrr r rJrrTypeVarrobjectrrkrlrmrrr$rr0r7r<rGr]rrr"rrs. ((((((&&&&&&$$$$$$""""""?1""""......******000000 AIcNN FHH9! *S/9!'(z#9!WQZQZ 3%@$ FG H!&QT+ UV9!9!9!9!x31738,6s6I!6636666SQVC[D3%3%3%3%3%3%3%3%l%%%%%%%%@11111111T$T$T$T$T$T$T$T$T$T$r"