o
    0×¾g5  ã                   @   s<   d Z ddlmZ ddlZdgZG dd„ deƒZe ¡ jZdS )z\Error formatting function for Windows.

The code is taken from twisted.python.win32 module.
é    )Úabsolute_importNÚformatErrorc                   @   s,   e Zd ZdZdd„ Zedd„ ƒZdd„ ZdS )	Ú_ErrorFormattera7  
    Formatter for Windows error messages.

    @ivar winError: A callable which takes one integer error number argument
        and returns an L{exceptions.WindowsError} instance for that error (like
        L{ctypes.WinError}).

    @ivar formatMessage: A callable which takes one integer error number
        argument and returns a C{str} giving the message for that error (like
        L{win32api.FormatMessage}).

    @ivar errorTab: A mapping from integer error numbers to C{str} messages
        which correspond to those errors (like L{socket.errorTab}).
    c                 C   s   || _ || _|| _d S )N)ÚwinErrorÚformatMessageÚerrorTab)ÚselfÚWinErrorÚFormatMessager   © r   úZ/var/www/html/backend_erp/backend_erp_env/lib/python3.10/site-packages/gevent/win32util.pyÚ__init__0   s   
z_ErrorFormatter.__init__c                 C   s„   zddl m} W n ty   d}Y nw zddlm} W n ty'   d}Y nw zddlm} W n ty;   d}Y nw | |||ƒS )z˜
        Get as many of the platform-specific error translation objects as
        possible and return an instance of C{cls} created with them.
        r   )r	   N)r
   )r   )Úctypesr	   ÚImportErrorÚwin32apir
   Úsocketr   )Úclsr	   r
   r   r   r   r   ÚfromEnvironment5   s    ÿÿÿz_ErrorFormatter.fromEnvironmentc                 C   sX   | j durt|   |¡ƒS | jdur|  |¡S | jdur'| j |¡}|dur'|S t |¡S )aÛ  
        Returns the string associated with a Windows error message, such as the
        ones found in socket.error.

        Attempts direct lookup against the win32 API via ctypes and then
        pywin32 if available), then in the error table in the socket module,
        then finally defaulting to C{os.strerror}.

        @param errorcode: the Windows error code
        @type errorcode: C{int}

        @return: The error message string
        @rtype: C{str}
        N)r   Ústrr   r   ÚgetÚosÚstrerror)r   Ú	errorcodeÚresultr   r   r   r   I   s   




z_ErrorFormatter.formatErrorN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úclassmethodr   r   r   r   r   r   r   !   s    
r   )	r   Ú
__future__r   r   Ú__all__Úobjectr   r   r   r   r   r   r   Ú<module>   s   A