B x `@sddlmZddlmZddlmZddlmZddZGdddeZGd d d eZ Gd d d e Z Gd dde Z Gddde Z Gddde Z Gddde ZGdddeZGdddeZGdddeZdS))filename_to_ui)get_text_stderr)PY2)echocCs&t|ttfr"ddd|DS|S)Nz / css|]}t|VqdS)N)repr).0xr 4/tmp/pip-unpacked-wheel-za9e8r29/click/exceptions.py sz$_join_param_hints..) isinstancetuplelistjoin) param_hintr r r _join_param_hintssrc@sFeZdZdZdZddZddZddZer8eZ d dZd d d Z d S)ClickExceptionz8An exception that Click can handle and show to the user.rcCs0|}tr|dk r|d}t||||_dS)Nzutf-8)rencode Exception__init__message)selfrZctor_msgr r r rs   zClickException.__init__cCs|jS)N)r)rr r r format_messageszClickException.format_messagecCs|jS)N)r)rr r r __str__szClickException.__str__cCs |jdS)Nzutf-8)rr)rr r r r$sNcCs(|dkrt}td||ddS)Nz Error: {})file)rrformatr)rrr r r show'szClickException.show)N) __name__ __module__ __qualname____doc__ exit_coderrrr __unicode__rr r r r r src@s(eZdZdZdZdddZd ddZdS) 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. NcCs*t||||_|jr |jjnd|_dS)N)rrctxcommandcmd)rrr%r r r r8s zUsageError.__init__cCs|dkrt}d}d}|jdk rJ|j|jdk rJd|jj|jjd}|jdk rx|jj}td|j |||dtd| ||ddS)NzTry '{} {}' for help. z{} {})rcolorz Error: {}) rr'Zget_help_optionr%rZ command_pathZhelp_option_namesr*r get_usager)rrr*hintr r r r=s zUsageError.show)N)N)rrrr r!rrr r r r r#-s r#c@s"eZdZdZdddZddZdS) 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. NcCst|||||_||_dS)N)r#rparamr)rrr%r.rr r r r^szBadParameter.__init__cCsN|jdk r|j}n&|jdk r,|j|j}n d|jSt|}d||jS)NzInvalid value: {}zInvalid value for {}: {})rr.get_error_hintr%rrr)rrr r r rcs   zBadParameter.format_message)NNN)rrrr rrr r r r r-Ls r-c@s:eZdZdZd ddZddZddZer6eZd dZdS) 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'``. NcCst|||||||_dS)N)r-r param_type)rrr%r.rr1r r r r{szMissingParameter.__init__cCs|jdk r|j}n|jdk r,|j|j}nd}t|}|j}|dkrX|jdk rX|jj}|j}|jdk r|jj |j}|r|r|d |7}n|}d ||rd |nd|rdnd|pdS)Nz. {}zMissing {}{}{}{}z {}r(z. .) rr.r/r%rr1Zparam_type_namertypeZget_missing_messager)rrr1msgZ msg_extrar r r rs*    zMissingParameter.format_messagecCs0|jdkr&|jr|jjnd}d|S|jSdS)Nzmissing parameter: {})rr.namer)r param_namer r r rs  zMissingParameter.__str__cCs|dS)Nzutf-8)r"r)rr r r rs)NNNNN) rrrr rrrrr"r r r r r0os  r0c@s"eZdZdZdddZddZdS) NoSuchOptionzfRaised if click attempted to handle an option that does not exist. .. versionadded:: 4.0 NcCs0|dkrd|}t|||||_||_dS)Nzno such option: {})rr#r option_name possibilities)rr8rr9r%r r r rs  zNoSuchOption.__init__cCs^|jg}|jrTt|jdkr4|d|jdn t|j}|dd|d|S)NrzDid you mean {}?r)z(Possible options: {})z, z )rr9lenappendrsortedr)rbitsr9r r r rs zNoSuchOption.format_message)NNN)rrrr rrr r r r r7s r7c@seZdZdZdddZdS)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. NcCst|||||_dS)N)r#rr8)rr8rr%r r r rszBadOptionUsage.__init__)N)rrrr rr r r r r>sr>c@seZdZdZdddZdS)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 NcCst|||dS)N)r#r)rrr%r r r rszBadArgumentUsage.__init__)N)rrrr rr r r r r?sr?c@s"eZdZdZdddZddZdS) FileErrorz"Raised if a file cannot be opened.NcCs0t|}|dkrd}t||||_||_dS)Nz unknown error)rrr ui_filenamefilename)rrBr,rAr r r rs  zFileError.__init__cCsd|j|jS)NzCould not open file {}: {})rrAr)rr r r rszFileError.format_message)N)rrrr rrr r r r r@s r@c@seZdZdZdS)Abortz=An internal signalling exception that signals Click to abort.N)rrrr r r r r rCsrCc@seZdZdZdZdddZdS)ExitzAn exception that indicates that the application should exit with some status code. :param code: the status code to exit with. )r!r)cCs ||_dS)N)r!)rcoder r r rsz Exit.__init__N)r))rrrr __slots__rr r r r rDsrDN)_compatrrrutilsrrrrr#r-r0r7r>r?r@ RuntimeErrorrCrDr r r r s     #=