
                         n   S r SSKJr  SSKJr  SSKJr  SSKrSSKr " S S\R                  5      r " S S	\5      r " S
 S\5      r	 " S S\5      r
 " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg) zCalliope parsing errors for logging and collecting metrics.

Refer to the calliope.parser_extensions module for a detailed overview.
    )absolute_import)division)unicode_literalsNc                   :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )ArgumentError   a  Base class for argument errors with metrics.

ArgumentError instances are intercepted by
parser_extensions.ArgumentParser.error(), which
  1. reports a failed command to metrics
  2. prints a usage diagnostic to the standard error
  3. exits with status 2, bypassing gcloud_main exception handling

Attributes:
  argument: str, The argument name(s) causing the error.
  error_extra_info: {str: str}, Extra info dict for error_format.
  error_format: str, A .format() string for constructng the error message
    from error_extra_info.
  extra_path_arg: str, Dotted command path to append to the command path.
  parser: ArgmentParser, Used to generate the usage string for the command.
    This could be a different subparser than the command parser.
c                    > Xl         X l        X0l        X@l        XPl        [
        [        U ]  S [        R                  " U 5      5        g )N)
error_formatargumentextra_path_argparsererror_extra_infosuperr   __init__six	text_type)selfr
   r   r   r   kwargs	__class__s         ,lib/googlecloudsdk/calliope/parser_errors.pyr   ArgumentError.__init__0   s9    $M(K"	-'cmmD.AB    c                 d   [        S0 U R                  D6n  U R                  R                  " S0 UD6n U R                  (       a  SR                  U R                  US9nU$ ! [         a#  nUR
                  S   nSU-   S-   X'    S nAO&S nAf[        [        4 a    U R                  n Mw  f = fM  )Nr   {}zargument {argument}: {message})r   message )	dictr   r
   formatKeyErrorargs
IndexError
ValueErrorr   )r   keysr   ekeys        r   __str__ArgumentError.__str__9   s    ($''(D

##**2T2 }}077==' 8 3gN  $ffQi#IO	*% ## s   A" "
B-,B

B-,B-)r   r   r
   r   r   )NNN)	__name__
__module____qualname____firstlineno____doc__r   r'   __static_attributes____classcell__r   s   @r   r   r      s"    $ BFC r   r   c                       \ rS rSrSrSrg)OtherParsingErrorM   z6Some other parsing error that is not any of the above.r   Nr)   r*   r+   r,   r-   r.   r   r   r   r2   r2   M   s    >r   r2   c                       \ rS rSrSrSrg)TooFewArgumentsErrorQ   z/Argparse didn't use all the Positional objects.r   Nr4   r   r   r   r6   r6   Q   s    7r   r6   c                       \ rS rSrSrSrg)UnknownCommandErrorU   zUnknown command error.r   Nr4   r   r   r   r9   r9   U   s    r   r9   c                       \ rS rSrSrSrg)UnrecognizedArgumentsErrorY   z<User entered arguments that were not recognized by argparse.r   Nr4   r   r   r   r<   r<   Y       Dr   r<   c                       \ rS rSrSrSrg)DetailedArgumentError]   z:A DetailedArgumentError is preferable to an ArgumentError.r   Nr4   r   r   r   r@   r@   ]   s    Br   r@   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )ModalGroupErrora   zModal group conflict error.c                 4   > [         [        U ]
  "  SSU0UD6  g )Nconflict)z{conflict} must be specified.)r   rC   r   r   rF   r   r   s      r   r   ModalGroupError.__init__d   s'    	/4)' r   r   r)   r*   r+   r,   r-   r   r.   r/   r0   s   @r   rC   rC   a   s    # r   rC   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )OptionalMutexErrork   zOptional mutex conflict error.c                 4   > [         [        U ]
  "  SSU0UD6  g )NrF   )z+At most one of {conflict} can be specified.)r   rK   r   rG   s      r   r   OptionalMutexError.__init__n   s(    	
d,5 r   r   rI   r0   s   @r   rK   rK   k       & r   rK   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )RequiredErroru   zRequired error.c                 0   > [         [        U ]
  "  S0 UD6  g )N)zMust be specified.)r   rQ   r   )r   r   r   s     r   r   RequiredError.__init__x   s    	-'
r   r   rI   r0   s   @r   rQ   rQ   u   s     r   rQ   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )RequiredMutexError~   zRequired mutex conflict error.c                 4   > [         [        U ]
  "  SSU0UD6  g )NrF   )z,Exactly one of {conflict} must be specified.)r   rV   r   rG   s      r   r   RequiredMutexError.__init__   s(    	
d,6 r   r   rI   r0   s   @r   rV   rV   ~   rO   r   rV   c                       \ rS rSrSrSrg)WrongTrackError   z)For parsed commands in a different track.r   Nr4   r   r   r   r[   r[      s    1r   r[   c                       \ rS rSrSrSrg)ArgumentException   z>ArgumentException is for problems with the declared arguments.r   Nr4   r   r   r   r^   r^      s    Fr   r^   c                       \ rS rSrSrSrg)UnknownDestinationException   z<Fatal error for an internal dest that has no associated arg.r   Nr4   r   r   r   ra   ra      r>   r   ra   )r-   
__future__r   r   r   argparser   r   r2   r6   r9   r<   r@   rC   rK   rQ   rV   r[   	Exceptionr^   ra   r   r   r   <module>rf      s    
 '  '  
-H** -`? ?8= 8- E ECM C+ . ) . 2+ 2G	 GE) Er   