U a#@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*|dk r&t|ts&ddd|DS|S)Nz / css|]}t|VqdSN)repr).0xrQC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-s9fh6ldx\click\exceptions.py sz$_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 rrrrr__str__$szClickException.__str__filer cCs.|dkrt}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 )rrr3commandcmd)rrr3rrrr9s zUsageError.__init__r"cCs|dkrt}d}d}|jdk r\|jj|jdk r\tdj|jj|jjdd}|d}|jdk r|jj}t |j d|||dt tdj| d||ddS) Nz"Try '{command} {option}' for help.r)r4option )r#colorr$r) rr3r4Zget_help_optionr%r&Z command_pathZhelp_option_namesr9r get_usager )rr#r9hintrrrr'>s*   zUsageError.show)N)N) r(r)r*r+r,rr-r.rr/r'r0rrrrr1.sr1csPeZdZdZd 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)rr3paramr r cst||||_||_dSr )rrr=r )rrr3r=r rrrrgszBadParameter.__init__rcCsV|jdk r|j}n,|jdk r,|j|j}ntdj|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_message)NNN r(r)r*r+rr-r.rr r0rrrrr<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)rr3r=r param_typer cs t|p d|||||_dS)Nr6)rrrA)rrr3r=r rArrrrszMissingParameter.__init__rcCs|jdk r|j}n|jdk r,|j|j}nd}t|}|rFd|nd}|j}|dkrj|jdk rj|jj}|j}|jdk r|jj |j}|r|r|d|7}n|}|rd|nd}|dkrt d}n4|dkrt d}n"|dkrt d }nt d j |d }||d |S) N r6z. ZargumentzMissing argumentr7zMissing optionZ parameterzMissing parameterzMissing {param_type})rA.) r r=r>r3rrAZparam_type_namertypeZget_missing_messager%r&)rr rAmsgZ msg_extramissingrrrr s4      zMissingParameter.format_messagecCs2|js(|jr|jjnd}tdj|dS|jSdS)NzMissing parameter: {param_name}) param_name)rr=namer%r&)rrGrrrr!szMissingParameter.__str__)NNNNN) r(r)r*r+r-r.rrr r!r0rrrrr@s   &r@csVeZdZdZd eejeejejeejdddfdd Zeddd Z Z S) NoSuchOptionzfRaised if click attempted to handle an option that does not exist. .. versionadded:: 4.0 Nr) option_namer possibilitiesr3r cs6|dkrtdj|d}t||||_||_dS)NzNo such option: {name})rH)r%r&rrrJrK)rrJrrKr3rrrrs zNoSuchOption.__init__rcCsH|js |jSdt|j}tddt|jj||d}|jd|S)Nz, zDid you mean {possibility}?z#(Possible options: {possibilities}))Z possibilityrKrB)rKrrsortedrlenr&)rZpossibility_strZsuggestrrrr szNoSuchOption.format_message)NNN) r(r)r*r+rr-r.Sequencerr r0rrrrrIs rIcs4eZdZdZdeeejdddfdd 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)rJrr3r cst||||_dSr )rrrJ)rrJrr3rrrrszBadOptionUsage.__init__)N) r(r)r*r+rr-r.rr0rrrrrOs rOc@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+rrrrrPsrPcs@eZdZdZd eejeddfdd ZedddZZ S) FileErrorz"Raised if a file cannot be opened.N)filenamer;r cs2|dkrtd}t|t||_||_dS)Nz unknown error)r%rrosfsdecode ui_filenamerS)rrSr;rrrrs   zFileError.__init__rcCstdj|j|jdS)Nz+Could not open file {filename!r}: {message})rSr)r%r&rVrrrrrr szFileError.format_message)Nr?rrrrrRsrRc@seZdZdZdS)Abortz=An internal signalling exception that signals Click to abort.NrQrrrrrWsrWc@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 rY)rrZrrrrsz Exit.__init__)r)r(r)r*r+ __slots__intrrrrrrXsrX)rTtypingr-rr%r_compatrutilsr TYPE_CHECKINGcorerrr.UnionrNrr Exceptionrr1r<r@rIrOrPrR RuntimeErrorrWrXrrrrs*       '*E"