a c#@s.ddlZddlZddlmZddlmZddlmZddlm Z ej r^ddl m Z ddl m Z ejejejeefejed d d ZGd d d eZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZdS) N)gettext)ngettext)get_text_stderr)echo)Context) Parameter) param_hintreturncCs*|dur&t|ts&ddd|DS|S)Nz / css|]}t|VqdSN)repr).0xr]/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/click/exceptions.py z$_join_param_hints..) isinstancestrjoin)r rrr_join_param_hintssrcsbeZdZdZdZeddfdd Zeddd Zedd d Zde j e j dd d dZ Z S)ClickExceptionz8An exception that Click can handle and show to the user.rN)messager cst|||_dSr )super__init__r)selfr __class__rrrs zClickException.__init__r cCs|jSr rrrrrformat_message!szClickException.format_messagecCs|jSr rr rrr__str__$szClickException.__str__filer cCs.|durt}ttdj|d|ddS)NError: {message}r)r$)rr_formatr!)rr$rrrshow'szClickException.show)N)__name__ __module__ __qualname____doc__ exit_coderrr!r"tOptionalIOr( __classcell__rrrrrs rcsPeZdZdZdZd eejdddfdd Zd ejej ddd d Z Z S) UsageErrora+An internal exception that signals a usage error. This typically aborts any further handling. :param message: the error message to display. :param ctx: optionally the context that caused this error. Click will fill in the context automatically in some situations. Nr)rctxr cs*t|||_|jr |jjnd|_dSr )rrr4commandcmd)rrr4rrrr9s zUsageError.__init__r#cCs|durt}d}d}|jdur\|jj|jdur\tdj|jj|jjdd}|d}|jdur|jj}t |j d|||dt tdj| d||ddS) Nz"Try '{command} {option}' for help.r)r5option )r$colorr%r) rr4r5Zget_help_optionr&r'Z command_pathZhelp_option_namesr:r get_usager!)rr$r:hintrrrr(>s(  zUsageError.show)N)N) r)r*r+r,r-rr.r/rr0r(r1rrrrr2.sr2csPeZdZdZd eejdejdejeddfdd Zedd d ZZ S) BadParametera An exception that formats out a standardized error message for a bad parameter. This is useful when thrown from a callback or type as Click will attach contextual information to it (for instance, which parameter it is). .. versionadded:: 2.0 :param param: the parameter object that caused this error. This can be left out, and Click will attach this info itself if possible. :param param_hint: a string that shows up as parameter name. This can be used as alternative to `param` in cases where custom validation should happen. If it is a string it's used as such, if it's a list then each item is quoted and separated. Nrr)rr4paramr r cst||||_||_dSr )rrr>r )rrr4r>r rrrrgszBadParameter.__init__rcCsV|jdur|j}n,|jdur,|j|j}ntdj|jdStdjt||jdS)NzInvalid value: {message}rz)Invalid value for {param_hint}: {message})r r)r r>get_error_hintr4r&r'rr)rr rrrr!rs   zBadParameter.format_message)NNN r)r*r+r,rr.r/rr!r1rrrrr=Us r=csleZdZdZd ejeejdejdejeejeddfdd Zedd d Zedd d Z Z S)MissingParameteraRaised if click required an option or argument but it was not provided when invoking the script. .. versionadded:: 4.0 :param param_type: a string that indicates the type of the parameter. The default is to inherit the parameter type from the given `param`. Valid values are ``'parameter'``, ``'option'`` or ``'argument'``. Nrr)rr4r>r param_typer cs t|p d|||||_dS)Nr7)rrrB)rrr4r>r rBrrrrszMissingParameter.__init__rcCs|jdur|j}n|jdur,|j|j}nd}t|}|rFd|nd}|j}|durj|jdurj|jj}|j}|jdur|jj |j}|r|r|d|7}n|}|rd|nd}|dkrt d}n4|dkrt d}n"|dkrt d }nt d j |d }||d |S) N r7z. argumentzMissing argumentr8zMissing optionZ parameterzMissing parameterzMissing {param_type})rB.) r r>r?r4rrBZparam_type_namertypeZget_missing_messager&r')rr rBmsgZ msg_extramissingrrrr!s4      zMissingParameter.format_messagecCs2|js(|jr|jjnd}tdj|dS|jSdS)NzMissing parameter: {param_name}) param_name)rr>namer&r')rrIrrrr"szMissingParameter.__str__)NNNNN) r)r*r+r,r.r/rrr!r"r1rrrrrAs   &rAcsVeZdZdZd eejeejejeejdddfdd Zeddd Z Z S) NoSuchOptionzfRaised if click attempted to handle an option that does not exist. .. versionadded:: 4.0 Nr) option_namer possibilitiesr4r cs6|durtdj|d}t||||_||_dS)NzNo such option: {name})rJ)r&r'rrrLrM)rrLrrMr4rrrrs zNoSuchOption.__init__rcCsH|js |jSdt|j}tddt|jj||d}|jd|S)Nz, zDid you mean {possibility}?z#(Possible options: {possibilities}))Z possibilityrMrC)rMrrsortedrlenr')rZpossibility_strZsuggestrrrr!szNoSuchOption.format_message)NNN) r)r*r+r,rr.r/Sequencerr!r1rrrrrKs rKcs4eZdZdZdeeejdddfdd ZZS)BadOptionUsageaRaised if an option is generally supplied but the use of the option was incorrect. This is for instance raised if the number of arguments for an option is not correct. .. versionadded:: 4.0 :param option_name: the name of the option being used incorrectly. Nr)rLrr4r cst||||_dSr )rrrL)rrLrr4rrrrszBadOptionUsage.__init__)N) r)r*r+r,rr.r/rr1rrrrrQs   rQc@seZdZdZdS)BadArgumentUsagezRaised if an argument is generally supplied but the use of the argument was incorrect. This is for instance raised if the number of values for an argument is not correct. .. versionadded:: 6.0 Nr)r*r+r,rrrrrRsrRcs@eZdZdZd eejeddfdd ZedddZZ S) FileErrorz"Raised if a file cannot be opened.N)filenamer<r cs2|durtd}t|t||_||_dS)Nz unknown error)r&rrosfsdecode ui_filenamerU)rrUr<rrrrs   zFileError.__init__rcCstdj|j|jdS)Nz+Could not open file {filename!r}: {message})rUr)r&r'rXrr rrrr! szFileError.format_message)Nr@rrrrrTsrTc@seZdZdZdS)Abortz=An internal signalling exception that signals Click to abort.NrSrrrrrYsrYc@s&eZdZdZdZdeddddZdS) ExitzAn exception that indicates that the application should exit with some status code. :param code: the status code to exit with. r-rN)coder cCs ||_dSr r[)rr\rrrrsz Exit.__init__)r)r)r*r+r, __slots__intrrrrrrZsrZ)rVtypingr.rr&r_compatrutilsr TYPE_CHECKINGcorerrr/UnionrPrr Exceptionrr2r=rArKrQrRrT RuntimeErrorrYrZrrrrs*       '*E"