o +ca#@s0ddlZddlZddlmZddlmZddlmZddlm Z ej r/ddl m Z ddl m Z d ejejejeefd ejefd d ZGd ddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdd d eZdS)!N)gettext)ngettext)get_text_stderr)echo)Context) Parameter param_hintreturncCs*|durt|tsddd|DS|S)Nz / css|]}t|VqdSN)repr).0xr2/usr/lib/python3/dist-packages/click/exceptions.py sz$_join_param_hints..) isinstancestrjoin)r rrr_join_param_hintssrcsfeZdZdZdZdeddffdd Zdefdd Zdefd d Zdd e j e j ddfd dZ Z S)ClickExceptionz8An exception that Click can handle and show to the user.rmessager Ncst|||_dSr )super__init__r)selfr __class__rrrs  zClickException.__init__cC|jSr rrrrrformat_message!zClickException.format_messagecCrr rrrrr__str__$r!zClickException.__str__filecCs.|durt}ttdj|d|ddS)NError: {message}r)r#)rr_formatr )rr#rrrshow's zClickException.showr )__name__ __module__ __qualname____doc__ exit_coderrr r"tOptionalIOr' __classcell__rrrrrs$rcsVeZdZdZdZd dedejdddffdd Zd d ejej ddfd 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. Nrctxrr cs0t|||_|jr|jj|_dSd|_dSr )rrr3commandcmd)rrr3rrrr9s zUsageError.__init__r#cCs|durt}d}d}|jdur.|jj|jdur.tdj|jj|jjdd}|d}|jdurF|jj}t |j d|||dt tdj| d||ddS) Nz"Try '{command} {option}' for help.r)r4option )r#colorr$r) rr3r4get_help_optionr%r& command_pathhelp_option_namesr9r get_usager )rr#r9hintrrrr'>s$    zUsageError.showr ) r(r)r*r+r,rr-r.rr/r'r0rrrrr1.s "$r1c s^eZdZdZ   ddedejddejddejed df fd d Zd efd 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. Nrr3rparamrr r cst||||_||_dSr )rrr@r )rrr3r@r rrrrgs zBadParameter.__init__cCsV|jdur |j}n|jdur|j|j}n tdj|jdStdjt||jdS)NzInvalid value: {message}rz)Invalid value for {param_hint}: {message})r r)r r@get_error_hintr3r%r&rr)rr rrrr rs   zBadParameter.format_messageNNN r(r)r*r+rr-r.rr r0rrrrr?Us" r?c seZdZdZ     ddejedejddejddejed ejed df fd d Zd efd dZd efddZ 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'``. Nrr3rr@rr param_typer cs t|pd|||||_dS)Nr6)rrrE)rrr3r@r rErrrrs zMissingParameter.__init__cCs|jdur |j}n|jdur|j|j}nd}t|}|r#d|nd}|j}|dur5|jdur5|jj}|j}|jdurS|jj |j}|rS|rQ|d|7}n|}|rZd|nd}|dkret d}n|dkrnt d}n|dkrwt d }nt d j |d }||d |S) N r6z. argumentzMissing argumentr7zMissing option parameterzMissing parameterzMissing {param_type})rE.) r r@rAr3rrEparam_type_namertypeget_missing_messager%r&)rr rEmsg msg_extramissingrrrr s4      zMissingParameter.format_messagecCs.|js|jr |jjnd}tdj|dS|jS)NzMissing parameter: {param_name}) param_name)rr@namer%r&)rrPrrrr"szMissingParameter.__str__)NNNNN) r(r)r*r+r-r.rrr r"r0rrrrrDs,  &rDc sdeZdZdZ   d dedejedejejedejdddf fd d Zdefd d Z Z S) NoSuchOptionzfRaised if click attempted to handle an option that does not exist. .. versionadded:: 4.0 N option_namer possibilitiesr3rr cs6|dur tdj|d}t||||_||_dS)NzNo such option: {name})rQ)r%r&rrrSrT)rrSrrTr3rrrrs  zNoSuchOption.__init__cCsH|js|jSdt|j}tddt|jj||d}|jd|S)Nz, zDid you mean {possibility}?z#(Possible options: {possibilities})) possibilityrTrF)rTrrsortedrlenr&)rpossibility_strsuggestrrrr szNoSuchOption.format_messagerB) r(r)r*r+rr-r.Sequencerr r0rrrrrRs" rRc s<eZdZdZ d dededejdddffdd 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. NrSrr3rr cst||||_dSr )rrrS)rrSrr3rrrrs zBadOptionUsage.__init__r ) r(r)r*r+rr-r.rr0rrrrr[s r[c@eZdZdZdS)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+rrrrr]r]csDeZdZdZd dedejeddffdd Zdefdd ZZ S) FileErrorz"Raised if a file cannot be opened.Nfilenamer>r cs2|durtd}t|t||_||_dS)Nz unknown error)r%rrosfsdecode ui_filenamera)rrar>rrrrs    zFileError.__init__cCstdj|j|jdS)Nz+Could not open file {filename!r}: {message})rar)r%r&rdrrrrrr szFileError.format_messager rCrrrrr`s"r`c@r\)Abortz=An internal signalling exception that signals Click to abort.Nr^rrrrrer_rec@s(eZdZdZdZd deddfddZdS) ExitzAn exception that indicates that the application should exit with some status code. :param code: the status code to exit with. r,rcoder NcCs ||_dSr rg)rrhrrrrs z Exit.__init__)r)r(r)r*r+ __slots__intrrrrrrfsrf)rbtypingr-rr%r_compatrutilsr TYPE_CHECKINGcorerrr.UnionrZrr Exceptionrr1r?rDrRr[r]r` RuntimeErrorrerfrrrrs0        '*E"