
    ϔ j
                         d Z ddlZddlZddlmZ ddlmZ ddl	m
Z
  ej        d          Z G d dej                  ZdS ))PdfUnspHandler    N)PdfiumError	pypdfium2c                   F    e Zd ZdZdZd Zd Zed             Zd Z	d	dZ
dS )
r   am  
    Unsupported feature handler helper class.
    
    Attributes:
        raw (UNSUPPORT_INFO):
           The underlying pdfium ``UNSUPPORT_INFO`` struct.
        handlers (dict[str, typing.Callable]):
            A dictionary of named handler functions to be called with an unsupported code (:attr:`FPDF_UNSP_*`) when PDFium detects an unsupported feature.
    Nc                 H    i | _         t          j        d          | _        d S )N   )version)handlerspdfium_cUNSUPPORT_INFOrawselfs    rC:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\pypdfium2/_helpers/unsupported.py__init__zPdfUnspHandler.__init__   s"    *1555    c                 T    | j                                         D ]} ||           d S N)r
   values)r   _typehandlers       r   __call__zPdfUnspHandler.__call__    s8    }++-- 	 	GGDMMMM	 	r   c                 z    t                               dt          j                            |                       d S )NzUnsupported PDF feature: )
lib_loggerwarningpdfium_iUnsupportedInfoToStrget)r   s    r   _defaultzPdfUnspHandler._default$   s7    `x7T7X7XY]7^7^``aaaaar   c                 V    t          | j                   t          | j                   d S r   )idr
   r   r   s    r   _keepzPdfUnspHandler._keep(   s#    
4=
48r   Tc                 @   t           j        rt          d          t          j        | j        d|            t          j        | j                  }|st          d          | t           _        t          j
        | j                   |rt           j        | j        d<   dS dS )a  
        Register the handler with PDFium, and install an exit function that will keep the object alive until the end of session.
        
        Once set up, a :class:`.PdfUnspHandler` cannot be removed. It stands and falls with the library.
        Thus, this function can only be called once in a session.
        However, you may change the wrapped :attr:`.handlers` callbacks.
        Call ``.handlers.clear()`` to remove all handlers, thereby effectively disabling the instance.
        
        Parameters:
            add_default (bool):
                If True, add a default callback that will log unsupported features as warning.
        zAOnly one PdfUnspHandler instance can be registered for a session.FSDK_UnSupport_Handlerz)Failed to register PdfUnspHandler object.defaultN)r   	SINGLETONRuntimeErrorr   set_callbackr   r   FSDK_SetUnSpObjProcessHandlerr   atexitregisterr#   r    r
   )r   add_defaultoks      r   setupzPdfUnspHandler.setup,   s     # 	dbcccdh(@$GGG3DH== 	KIJJJ#'  	
### 	?'5'>DM)$$$	? 	?r   )T)__name__
__module____qualname____doc__r'   r   r   staticmethodr    r#   r/    r   r   r   r      s          I6 6 6   b b \b  ? ? ? ? ? ?r   r   )__all__r+   loggingpypdfium2.rawr   r   pypdfium2.internalinternalr   pypdfium2._helpers.miscr   	getLoggerr   AutoCastabler   r5   r   r   <module>r>      s                   % % % % % % / / / / / /W{++
6? 6? 6? 6? 6?h+ 6? 6? 6? 6? 6?r   