o
    j
                     @   sX   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dZG dd dejZdS ))PdfUnspHandler    N)PdfiumError	pypdfium2c                   @   sB   e Zd ZdZdZdd Zdd Zedd Zd	d
 Z	d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                 C   s   i | _ tjdd| _d S )N   )version)handlerspdfium_cUNSUPPORT_INFOrawself r   d/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/pypdfium2/_helpers/unsupported.py__init__   s   zPdfUnspHandler.__init__c                 C   s   | j  D ]}|| qd S N)r   values)r   _typehandlerr   r   r   __call__    s   
zPdfUnspHandler.__call__c                 C   s   t dtj|   d S )NzUnsupported PDF feature: )
lib_loggerwarningpdfium_iUnsupportedInfoToStrget)r   r   r   r   _default$   s   zPdfUnspHandler._defaultc                 C   s   t | j t | j d S r   )idr   r
   r   r   r   r   _keep(   s   
zPdfUnspHandler._keepTc                 C   s`   t jrtdt| jd|  t| j}|std| t _t	
| 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okr   r   r   setup,   s   zPdfUnspHandler.setup)T)__name__
__module____qualname____doc__r    r   r   staticmethodr   r   r(   r   r   r   r   r      s    

r   )__all__r$   loggingpypdfium2.rawr
   r   pypdfium2.internalinternalr   pypdfium2._helpers.miscr   	getLoggerr   AutoCastabler   r   r   r   r   <module>   s   
