o
    vvXj§
  ã                   @   sì   d Z ddlmZmZ ddlZddlmZ ddlmZ ddl	m
Z
mZmZ zddlZW n ey5   dZY nw zddlmZ W n eyK   d	d
„ ZY nw dd„ Zdd„ Ze
r_dd„ Zdd„ Zndd„ Zdd„ ZG dd„ dejƒZdd„ ZdS )zCompatibility utilities.é    )Úabsolute_importÚunicode_literalsN)Úpromise©Úwrapsé   )ÚPY3Ústring_tÚtext_t)Úset_cloexecc                 C   sd   t du rdS zt j}W n ty   tdƒ‚w t   | t j¡}|r%||O }n|| M }t   | t j|¡S )z Set flag to close fd after exec.Nz1close-on-exec flag not supported on this platform)ÚfcntlÚ
FD_CLOEXECÚAttributeErrorÚNotImplementedErrorÚF_GETFDÚF_SETFD)ÚfdÚcloexecr   Úflags© r   úG/var/www/html/myproject/venv/lib/python3.10/site-packages/amqp/utils.pyr      s   
ÿÿ

r   c                 C   sj   z| j W S  ty4   zt| jtƒr!t| jƒdkr%| jd W  Y S W Y dS W Y dS  ty3   Y Y dS w w )z’Get exception errno (if set).

    Notes:
        :exc:`socket.error` and :exc:`IOError` first got
        the ``.errno`` attribute in Py2.7.
    é   r   )Úerrnor   Ú
isinstanceÚargsÚtupleÚlen)Úexcr   r   r   Ú	get_errno'   s   ÿüþþûr   c                    s   t ˆ ƒ‡ fdd„ƒ}|S )z,Decorator to mark generator as a co-routine.c                     s   ˆ | i |¤Ž}t |ƒ |S ©N)Únext)r   ÚkwargsÚco©Úgenr   r   Ú_boot<   s   zcoro.<locals>._bootr   )r$   r%   r   r#   r   Úcoro:   s   r&   c                 C   ó   t | tƒr|  dd¡S | S )úConvert str to bytes.úutf-8Úsurrogatepass)r   ÚstrÚencode©Úsr   r   r   Ústr_to_bytesG   ó   
r/   c                 C   r'   )úConvert bytes to str.r)   r*   )r   ÚbytesÚdecoder-   r   r   r   Úbytes_to_strM   r0   r4   c                 C   s   t | tƒr
|  d¡S | S )r(   r)   )r   r
   r,   r-   r   r   r   r/   T   s   

c                 C   s   | S )r1   r   r-   r   r   r   r4   Z   s   c                   @   s   e Zd ZdZdd„ ZdS )ÚNullHandlerz$A logging handler that does nothing.c                 C   s   d S r   r   )ÚselfÚrecordr   r   r   Úemitb   s   zNullHandler.emitN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r8   r   r   r   r   r5   _   s    r5   c                 C   s*   t | tƒr
t | ¡} | js|  tƒ ¡ | S )zGet logger by name.)r   r	   ÚloggingÚ	getLoggerÚhandlersÚ
addHandlerr5   )Úloggerr   r   r   Ú
get_loggerf   s
   

rB   )r<   Ú
__future__r   r   r=   Úviner   Ú
vine.utilsr   Úfiver   r	   r
   r   ÚImportErrorÚosr   r   r&   r/   r4   ÚHandlerr5   rB   r   r   r   r   Ú<module>   s2    ÿþ
