o
    H!i                     @   s
  d dl Z d dlZd dlmZ d dlmZ g 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G dd de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$ddZd$ddZd$ddZdd Zd$dd Zd!eeef fd"d#ZdS )%    N)Path)Union)
UnsupportedAPIErrorUnsupportedParamErrorCalledProcessErrorraise_unsupported_api_errorraise_key_not_found_errorraise_class_not_found_error raise_no_entity_registered_errorraise_unsupported_device_errorraise_model_not_found_errorDuplicateRegistrationErrorc                   @      e Zd Zd ZdS )r   N__name__
__module____qualname____doc__ r   r   g/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/paddlex/utils/errors/others.pyr   "       r   c                   @   r   )r   Nr   r   r   r   r   r   &   r   r   c                   @   r   )KeyNotFoundErrorNr   r   r   r   r   r   *   r   r   c                   @   r   )ClassNotFoundExceptionNr   r   r   r   r   r   .   r   r   c                   @   r   )NoEntityRegisteredExceptionNr   r   r   r   r   r   2   r   r   c                   @   r   )UnsupportedDeviceErrorNr   r   r   r   r   r   6   r   r   c                       s*   e Zd Zd Zd fdd	Zdd Z  ZS )r   Nc                    s&   t    || _|| _|| _|| _d S N)super__init__
returncodecmdoutputstderr)selfr   r   r    r!   	__class__r   r   r   =   s
   

zCalledProcessError.__init__c                 C   s   | j r4| j dk r4zdt| j dtt| j   dW S  ty3   dt| j d| j   d Y S w dt| j d| j  dS )Nr   zCommand z died with .z died with unknown signal z returned non-zero exit status )r   reprr   signalSignals
ValueError)r"   r   r   r   __str__D   s   ( zCalledProcessError.__str__)NN)r   r   r   r   r   r*   __classcell__r   r   r#   r   r   :   s    r   c                   @   r   )r   Nr   r   r   r   r   r   N   r   r   c                   @   s   e Zd ZdZdS )ModelNotFoundErrorzModel Not Found ErrorNr   r   r   r   r   r,   R   r   r,   c                 C   s.   |dur|j  d|  }n| }td| d)zraise unsupported api errorNr%   z	The API `z` is not supported.)r   r   )Zapi_nameclsnamer   r   r   r   V   s   r   c                 C   s6   d|  d}|rt j|ddd}|d| 7 }t|)zraise key not found error`z` not found in config.   F)indentensure_asciiz
The content of config:
)jsondumpsr   )keyconfigmsgZ
config_strr   r   r   r   `   s
   r   c                 C   sB   |j }d|  d| d}|durd|}|d| d7 }t|)zraise class not found errorr/   z` is not registered on r%   Nz,  z
The registied entities: [])r   joinr   )cls_namebase_clsZall_entitiesbase_cls_namer7   Zall_entities_strr   r   r   r	   i   s   
r	   c                 C   s   | j }d| d}t|)z raise no entity registered errorzThere no entity register on z+. Hint: Maybe the subclass is not imported.)r   r   )r;   r<   r7   r   r   r   r
   s   s   r
   c                 C   s6   d|  d}|durd |}|d| d7 }t|)r   zThe device `z` is not supported! Nz, z!The supported device types are: [z].)r9   r   )ZdeviceZsupported_devicer7   Zsupported_device_strr   r   r   r   z   s
   
r   
model_pathc                 C   s   d|  d}t |)z_raise ModelNotFoundError

    Args:
        model_path (str|Path): the path to model file.
    zThe model file(s)(`z`) is not found.)r,   )r=   r7   r   r   r   r      s   r   r   )r3   r'   pathlibr   typingr   __all__	Exceptionr   r   r   r   r   r   r   r   r,   r   r   r	   r
   r   strr   r   r   r   r   <module>   s(   



	

	