o
    5t¾iñ  ã                   @   s–   d Z ddlZddlZddlmZ ddlmZ dZdZ	eZ
e	Zdeded	ee d
efdd„Zddedee d
efdd„Zddedee d
efdd„ZdS )z0
Import from https://github.com/thombashi/msgfy
é    N)Ú	FrameType)ÚOptionalz{exception}: {error_msg}z;{exception} {file_name}({line_no}) {func_name}: {error_msg}Úexception_objÚ
format_strÚframeÚreturnc                 C   s†   t | tƒs	tdƒ‚|d u rt| ƒS z&| d| jj¡ dtj 	|j
j¡¡ dt|jƒ¡ d|j
j¡ dt| ƒ¡W S  tyB   tdƒ‚w )NzFexception_obj must be an instance of a subclass of the Exception classz{exception}z{file_name}z	{line_no}z{func_name}z{error_msg}zformat_str must be a string)Ú
isinstanceÚ	ExceptionÚ
ValueErrorÚstrÚreplaceÚ	__class__Ú__name__ÚosÚpathÚbasenameÚf_codeÚco_filenameÚf_linenoÚco_nameÚAttributeError©r   r   r   © r   úO/home/ubuntu/.local/lib/python3.10/site-packages/pytablewriter/writer/_msgfy.pyÚ_to_message   s   
ûÿr   c                 C   ó.   |st }t ¡ }|d u rt| ƒS t| ||jƒS ©N)Úerror_message_formatÚinspectÚcurrentframer   r   Úf_backr   r   r   r   Úto_error_message%   ó   r!   c                 C   r   r   )Údebug_message_formatr   r   r   r   r    r   r   r   r   Úto_debug_message0   r"   r$   r   )Ú__doc__r   Úos.pathr   Útypesr   Útypingr   ÚDEFAULT_ERROR_MESSAGE_FORMATÚDEFAULT_DEBUG_MESSAGE_FORMATr   r#   r	   r   r   r!   r$   r   r   r   r   Ú<module>   s     