§
    é˜ºhy  ã                  óÆ   — d Z ddlmZ ddlZddlZddlmZ ddlmZ  G d„ de	ej
        ¬¦  «        Z G d	„ d
e¦  «        Z G d„ de¦  «        Z G d„ dej        ¦  «        ZdS )a  Customized ArgumentParser.

The default behvaior of argparse.ArgumentParser's parse_args() method  is to
exit with a SystemExit exception in the following cases:
1. When the user requests a help message (with the --help or -h flags), or
2. When there's a parsing error (e.g. missing required flags or mistyped flags)

To make the errors more user-friendly, this class customizes
argparse.ArgumentParser and raises either ParserNormalExit for (1) or
ParserError for (2); this way the caller has control over how to display them
to the user.
é    )ÚannotationsN)ÚSequence)Úipython_envc                  ó\   ‡ — e Zd ZdZdˆ fd„Zdd	„Zd
„ Zdd„Zej	        dd„¦   «         Z
ˆ xZS )Ú_ParserBaseExceptionz7Base class for parser exceptions including normal exit.ÚmsgsúSequence[str]c                ó„   •—  t          ¦   «         j        d                     |¦  «        g|¢R i |¤Ž || _        d | _        d S )NÚ )ÚsuperÚ__init__ÚjoinÚ_msgsÚ_ipython_env)Úselfr   ÚargsÚkwargsÚ	__class__s       €út/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/google/generativeai/notebook/argument_parser.pyr   z_ParserBaseException.__init__'   sI   ø€ Ø�‰ŒÔ˜Ÿš ™œÐ8¨Ð8Ð8Ð8°Ð8Ð8Ð8ØˆŒ
Ø;?ˆÔÐÐó    Úenvúipython_env.IPythonEnvÚreturnÚNonec                ó   — || _         d S ©N)r   ©r   r   s     r   Úset_ipython_envz$_ParserBaseException.set_ipython_env,   s   € ØˆÔÐÐr   c                ó:   — |                       | j        ¦  «         d S r   )Údisplayr   ©r   s    r   Ú_ipython_display_z&_ParserBaseException._ipython_display_/   s   € Ø�Š�TÔ&Ñ'Ô'Ð'Ð'Ð'r   c                ó   — | j         S r   )r   r!   s    r   r   z_ParserBaseException.msgs2   s
   € ØŒzÐr   úipython_env.IPythonEnv | Nonec                ó   — dS )z-Display this exception on an IPython console.N© r   s     r   r    z_ParserBaseException.display5   s   € € € r   )r   r	   )r   r   r   r   )r   r	   ©r   r$   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r"   r   ÚabcÚabstractmethodr    Ú__classcell__©r   s   @r   r   r   $   s¤   ø€ € € € € ØAÐAð@ð @ð @ð @ð @ð @ð
 ð  ð  ð  ð(ð (ð (ðð ð ð ð 	Ôð<ð <ð <ñ Ôð<ð <ð <ð <ð <r   r   )Ú	metaclassc                  ó   — e Zd ZdZdd„ZdS )	ÚParserNormalExitzzException thrown when the parser exits normally.

    This is usually thrown when the user requests the help message.
    r   r$   r   r   c                ó8   — | j         D ]}t          |¦  «         Œd S r   )r   Úprint©r   r   Úmsgs      r   r    zParserNormalExit.displayD   s*   € Ø”:ð 	ð 	ˆCÝ�#‰JŒJˆJˆJð	ð 	r   Nr'   ©r(   r)   r*   r+   r    r&   r   r   r2   r2   >   s2   € € € € € ðð ð
ð ð ð ð ð r   r2   c                  ó   — e Zd ZdZdd„ZdS )	ÚParserErrorz(Exception thrown when there is an error.r   r$   r   r   c                ój   — | j         D ]}t          |¦  «         Œ|�|                     d¦  «         d S d S )Nz,<b style='font-family:courier new'>ERROR</b>)r   r4   Údisplay_htmlr5   s      r   r    zParserError.displayL   sG   € Ø”:ð 	ð 	ˆCÝ�#‰JŒJˆJˆJØˆ?à×ÒÐKÑLÔLÐLÐLÐLð ˆ?r   Nr'   r7   r&   r   r   r9   r9   I   s4   € € € € € Ø2Ð2ðMð Mð Mð Mð Mð Mr   r9   c                  ó2   ‡ — e Zd ZdZˆ fd„Zdd„Zdd„Zˆ xZS )	ÚArgumentParsera!  Customized ArgumentParser for LLM Magics.

    This class overrides the parent argparse.ArgumentParser's error-handling
    methods to avoid side-effects like printing to stderr. The messages are
    accumulated and passed into the raised exceptions for the caller to
    handle them.
    c                óH   •—  t          ¦   «         j        |i |¤Ž g | _        d S r   )r   r   Ú	_messages)r   r   r   r   s      €r   r   zArgumentParser.__init__]   s*   ø€ Ø�‰ŒÔ˜$Ð) &Ð)Ð)Ð)Ø$&ˆŒˆˆr   Nc                ó<   — ~| j                              |¦  «         dS )z2Override ArgumentParser's _print_message() method.N)r?   Úappend)r   ÚmessageÚfiles      r   Ú_print_messagezArgumentParser._print_messagea   s!   € àØŒ×Ò˜gÑ&Ô&Ð&Ð&Ð&r   r   c                ó˜   — |r|                       |¦  «         | j        }g | _        |dk    rt          |¬¦  «        ‚t          |¬¦  «        ‚)z(Override ArgumentParser's exit() method.r   )r   )rD   r?   r2   r9   )r   ÚstatusrB   r   s       r   ÚexitzArgumentParser.exitf   sW   € àð 	)Ø×Ò Ñ(Ô(Ð(àŒ~ˆØˆŒØ�QŠ;ˆ;Ý"¨Ð-Ñ-Ô-Ð-å 4Ð(Ñ(Ô(Ð(r   r   )r   N)r(   r)   r*   r+   r   rD   rG   r.   r/   s   @r   r=   r=   T   sj   ø€ € € € € ðð ð'ð 'ð 'ð 'ð 'ð'ð 'ð 'ð 'ð

)ð 
)ð 
)ð 
)ð 
)ð 
)ð 
)ð 
)r   r=   )r+   Ú
__future__r   r,   ÚargparseÚtypingr   Úgoogle.generativeai.notebookr   ÚRuntimeErrorÚABCMetar   r2   r9   r=   r&   r   r   ú<module>rN      s!  ððð ð #Ð "Ð "Ð "Ð "Ð "à 
€
€
€
Ø €€€Ø Ð Ð Ð Ð Ð Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4ð<ð <ð <ð <ð <˜<°3´;ð <ñ <ô <ð <ð4ð ð ð ð Ð+ñ ô ð ðMð Mð Mð Mð MÐ&ñ Mô Mð Mð)ð )ð )ð )ð )�XÔ,ñ )ô )ð )ð )ð )r   