o
    5׾g$
                     @   s   d dl Z d dlZd dlmZ d dlZd dlmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlmZ G dd	 d	e jZd
ZdefddZedd ZdZdS )    N)contextmanager)logger)	LogConfigStdLogOutput)misc)LayoutError)SigningErrorc                   @   s   e Zd ZdefddZdS )NoStackTraceFormatterreturnc                 C   s   dS )N  )selfeir   r   ]/var/www/html/backend_erp/backend_erp_env/lib/python3.10/site-packages/pyhanko/cli/runtime.pyformatException   s   z%NoStackTraceFormatter.formatExceptionN)__name__
__module____qualname__strr   r   r   r   r   r	      s    r	   z4%(asctime)s - %(name)s - %(levelname)s - %(message)sverbosec                 C   s   |   D ]G\}}t|}||j t|jtr6ttjkr%t	t
j}nt	 }|r1tt}ntt}nt|j}tt}|| || qd S )N)itemslogging	getLoggersetLevellevel
isinstanceoutputr   STDOUTStreamHandlersysstdout	FormatterLOG_FORMAT_STRINGr	   FileHandlersetFormatter
addHandler)log_configsr   module
log_config
cur_loggerhandler	formatterr   r   r   logging_setup   s   




r,   c               
   c   sv   d  } }zd V  W n t jy     tjy- } z|}d|j } W Y d }~nd }~w tjyG } z|}d|j } W Y d }~nfd }~w tjya } z|}d|j } W Y d }~nLd }~w tyz } z|}d|j } W Y d }~n3d }~w ty } z|}d|j } W Y d }~nd }~w t	y } z
|}d} W Y d }~nd }~ww |d urt
j| |d t | d S )NzcFailed to read PDF file in strict mode; rerun with --no-strict-syntax to try again.
Error message: zFailed to read PDF file: zFailed to write PDF file: z*Error raised while producing signed file: z/Error raised while producing signature layout: zGeneric processing error.)exc_info)clickClickExceptionr   PdfStrictReadErrormsgPdfReadErrorPdfWriteErrorr   r   	Exceptionr   error)r1   	exceptioner   r   r   pyhanko_exception_manager.   sL   

r8   zpyhanko.yml)r   r   
contextlibr   r.   pyhanko.cli.utilsr   pyhanko.config.loggingr   r   pyhanko.pdf_utilsr   pyhanko.pdf_utils.layoutr   pyhanko.sign.generalr   r!   r	   r"   boolr,   r8   DEFAULT_CONFIG_FILEr   r   r   r   <module>   s    
"