
    1 j
                         S r SSKrSSKrSSKJr  SSKJr  SSK	J
r
  \R                  " S5      r " S S\R                  5      rg))PdfUnspHandler    N)PdfiumError	pypdfium2c                   H    \ rS rSrSrSrS rS r\S 5       r	S r
S
S jrS	rg)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                 D    0 U l         [        R                  " SS9U l        g )N   )version)handlerspdfium_cUNSUPPORT_INFOrawselfs    o/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/pypdfium2/_helpers/unsupported.py__init__PdfUnspHandler.__init__   s    **15    c                 V    U R                   R                  5        H  nU" U5        M     g N)r   values)r   _typehandlers       r   __call__PdfUnspHandler.__call__    s     }}++-GDM .r   c                 n    [         R                  S[        R                  R	                  U 5       35        g )NzUnsupported PDF feature: )
lib_loggerwarningpdfium_iUnsupportedInfoToStrget)r   s    r   _defaultPdfUnspHandler._default$   s+    6x7T7T7X7XY]7^6_`ar   c                 X    [        U R                  5        [        U R                  5        g r   )idr   r   r   s    r   _keepPdfUnspHandler._keep(   s    
4==
488r   c                    [         R                  (       a  [        S5      e[        R                  " U R
                  SU 5        [        R                  " U R
                  5      nU(       d  [        S5      eU [         l        [        R                  " U R                  5        U(       a  [         R                  U R                  S'   gg)a2  
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   setupPdfUnspHandler.setup,   s     ##bccdhh(@$G33DHH=IJJ#'  	

#'5'>'>DMM)$ r   )r   r   )T)__name__
__module____qualname____firstlineno____doc__r,   r   r   staticmethodr#   r'   r4   __static_attributes__ r   r   r   r      s8     I6 b b?r   r   )__all__r0   loggingpypdfium2.rawr   r   pypdfium2.internalinternalr    pypdfium2._helpers.miscr   	getLoggerr   AutoCastabler   r=   r   r   <module>rF      s=         % /{+
6?h++ 6?r   