o
    ~îjT  ã                   @  s¤   d Z ddlmZ ddlZddlmZmZ ddlmZ er&ddl	m
Z
mZmZ ddd„Zddd„ZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )zBase pip exception classes.é    )ÚannotationsN)ÚTYPE_CHECKINGÚLiteral)ÚText)ÚConsoleÚConsoleOptionsÚRenderResultÚsÚstrÚreturnÚboolc                 C  s   t  d| ¡d uS )Nz^[a-z]+(-[a-z]+)*$)ÚreÚmatch)r	   © r   úh/raid/bulk_storage/M2HATS/real-image-venv/lib/python3.10/site-packages/pip/_internal/exceptions/_base.pyÚ_is_kebab_case   s   r   ú
Text | strÚconsoler   ÚprefixÚindentr   c                C  sJ   t | tƒr| }n| | ¡}|j|dd�|jd|› �dd� |jdd�¡ S )NÚignore)ÚoverflowÚ
T)Úallow_blank)Ú
isinstancer   Ú
render_strÚjoinÚsplit)r	   r   r   r   Útextr   r   r   Ú_prefix_with_indent   s   


ÿþr   c                   @  ó   e Zd ZdZdS )ÚPipErrorzThe base pip error.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r!   #   ó    r!   c                   @  r    )ÚInstallationErrorz%General exception during installationNr"   r   r   r   r   r(   '   r'   r(   c                   @  r    )ÚBlockedImportErrorzŒAn import blocked after wheel installation started.

    ImportError would be swallowed by codec lookup and cache the codec as missing.
    Nr"   r   r   r   r   r)   +   r'   r)   c                      sL   e Zd ZU dZded< dddddœd‡ fdd„Zddd„Zd dd„Z‡  ZS )!ÚDiagnosticPipErrora§  An error, that presents diagnostic information to the user.

    This contains a bunch of logic, to enable pretty presentation of our error
    messages. Each error gets a unique reference. Each error can also include
    additional context, a hint and/or a note -- which are presented with the
    main error message in a consistent style.

    This is adapted from the error output styling in `sphinx-theme-builder`.
    r
   Ú	referenceÚerrorN)Úkindr+   Ú	note_stmtÚlinkr-   úLiteral['error', 'warning']ú
str | NoneÚmessageú
str | TextÚcontextústr | Text | NoneÚ	hint_stmtr.   r/   r   ÚNonec                  s~   |d u rt | dƒsJ dƒ‚| j}t|ƒsJ dƒ‚|| _|| _|| _|| _|| _|| _|| _t	ƒ  
d| jj› d| j› d�¡ d S )Nr+   zerror reference not provided!z#error reference must be kebab-case!ú<z: ú>)Úhasattrr+   r   r-   r2   r4   r.   r6   r/   ÚsuperÚ__init__Ú	__class__r#   )Úselfr-   r+   r2   r4   r6   r.   r/   ©r=   r   r   r<   ?   s   $zDiagnosticPipError.__init__c                 C  s8   d| j j› d| j›d| j›d| j›d| j›d| j›d�S )Nr8   z(reference=z
, message=z
, context=z, note_stmt=z, hint_stmt=z)>)r=   r#   r+   r2   r4   r.   r6   )r>   r   r   r   Ú__repr__]   s   ÿþýüûÿzDiagnosticPipError.__repr__r   r   Úoptionsr   r   c                 c  sD  � | j dkrdnd}d|› d| j › d| j› d�V  dV  |jsT| jd urIt| j|d|› d	�d|› d
�d�V  t| j|d|› d�d|› d�d�V  nt| j|ddd�V  n| jV  | jd urddV  | jV  | jd usn| jd urqdV  | jd ur€t| j|ddd�V  | jd ur�t| j|ddd�V  | jd ur dV  d| j› �V  d S d S )Nr,   ÚredÚyellowú[z bold]z[/]: [bold]z[/]Ú u   ]Ã—[/] u   ]â”‚[/] )r   r   u   ]â•°â”€>[/] z]   [/] u   [red]Ã—[/] z  z[magenta bold]note[/]: z      z[cyan bold]hint[/]: zLink: )	r-   r+   Ú
ascii_onlyr4   r   r2   r.   r6   r/   )r>   r   rA   Úcolourr   r   r   Ú__rich_console__h   s`   €


ü


ü
ü

ü
ü
þz#DiagnosticPipError.__rich_console__)r-   r0   r+   r1   r2   r3   r4   r5   r6   r5   r.   r5   r/   r1   r   r7   )r   r
   )r   r   rA   r   r   r   )	r#   r$   r%   r&   Ú__annotations__r<   r@   rH   Ú__classcell__r   r   r?   r   r*   2   s   
 
÷
r*   )r	   r
   r   r   )
r	   r   r   r   r   r
   r   r
   r   r   )r&   Ú
__future__r   r   Útypingr   r   Úpip._vendor.rich.textr   Úpip._vendor.rich.consoler   r   r   r   r   Ú	Exceptionr!   r(   r)   r*   r   r   r   r   Ú<module>   s    

