o
    ei5                     @   sL  d Z ddlZddlZddlZddlZddlZddlZddlZej	j
dkZe ZedZe dkZe dkZe dkZedefi Zej	dd d	k rSejZneZzejZW n eyf   ejZY nw erdd
lmZmZ m!Z!m"Z#m$Z$ ddl%m&Z& e'fZ(e'e)fZ*e+Z,e'Z-dd Z.dd Z/dd Z0dd Z1dd Z2dd Z3G dd de4Z5dd Z6dd Z7n<ddl8mZmZ m!Z! ddl$m"Z#m$Z$ ddl&m&Z& e(Z(e(Z*e,Z,e9Z-e:j;Z/e:j<Z0e:j=Z1e:j>Z2e?Z3e5Z5d d Z.d!d Z6d"d Z7d#d$ Z@d%d& ZAd'd( ZBejCd)kZDej	dd d*kZEdZFe dkreBeG ZFd+ZHd,ZIejJejKdfd-d.ZLdS )/zPThe compat module provides various Python 2 / Python 3
compatibility functions

    N   z(\d+).+LinuxDarwinWindowsAbstractBase)   r   )quoteunquote	urlencodeparse_qsurlparse)StringIOc                   C   s   t  S )z2
        Python 3 supports monotonic time
        )time	monotonic r   r   J/var/www/html/pca-backend/venv/lib/python3.10/site-packages/pika/compat.pytime_now9      r   c                 C      t |  S )a   
        Returns a list of keys of dictionary

        dict.keys returns a view that works like .keys in Python 2
        *except* any modifications in the dictionary will be visible
        (and will cause errors if the view is being iterated over while
        it is modified).
        )listkeysdctr   r   r   dictkeys?   s   
r   c                 C   r   )a(  
        Returns a list of values of a dictionary

        dict.values returns a view that works like .values in Python 2
        *except* any modifications in the dictionary will be visible
        (and will cause errors if the view is being iterated over while
        it is modified).
        )r   valuesr   r   r   r   
dictvaluesK   s   	r   c                 C      |   S )a<  
        Returns an iterator of items (key/value pairs) of a dictionary

        dict.items returns a view that works like .items in Python 2
        *except* any modifications in the dictionary will be visible
        (and will cause errors if the view is being iterated over while
        it is modified).
        )itemsr   r   r   r   dict_iteritemsV   s   	r   c                 C   r   )zw
        :param dict dct:
        :returns: an iterator of the values of a dictionary
        :rtype: iterator
        )r   r   r   r   r   dict_itervaluesa      r   c                  G      t | S )a  
        This is the same as Python 2 `chr(n)` for bytes in Python 3

        Returns a single byte `bytes` for the given int argument (we
        optimize it a bit here by passing the positional argument tuple
        directly to the bytes constructor.
        )bytes)argsr   r   r   bytei   s   r$   c                   @   s    e Zd ZdZdd Zdd ZdS )longzy
        A marker class that signifies that the integer value should be
        serialized as `l` instead of `I`
        c                 C   s   t t| S )N)strintselfr   r   r   __str__y      zlong.__str__c                 C   s   t | d S )NLr&   r(   r   r   r   __repr__|   r+   zlong.__repr__N)__name__
__module____qualname____doc__r*   r.   r   r   r   r   r%   s   s    r%   c                 C   r!   )zs
        Return the canonical str value for the string.
        In both Python 3 and Python 2 this is str.
        r-   valuer   r   r   canonical_str   r    r5   c                 C   s
   t | tS z&
        Is value an integer?
        )
isinstancer'   r3   r   r   r   
is_integer   s   
r8   )r   r	   r
   )r   r   c                   C   s   t   S )z:
        Python 2 does not support monotonic time
        )r   r   r   r   r   r      r   c                 C   s,   zt | W S  ty   t | d Y S w )z
        Returns the canonical string value of the given string.
        In Python 2 this is the value unchanged if it is an str, otherwise
        it is the unicode value encoded as UTF-8.
        zutf-8)r&   UnicodeEncodeErrorencoder3   r   r   r   r5      s
   
c                 C   s   t | ttfS r6   )r7   r'   r%   r3   r   r   r   r8      s   c                 C   s   t | ts
| dS | S )z 
    Returns value as bytes
    zUTF-8)r7   r"   r:   r3   r   r   r   as_bytes   s   

r;   c                 C   s2   |   rt| S t| }|rt| d S dS )z%
    Returns value as in integer
    r   )isdigitr'   RE_NUMmatchgroups)r4   r>   r   r   r   to_digit   s   
r@   c                 C   s*   |  dd }ttt| ddd S )z
    Gets linux version
    -r   .Nr   )splittuplemapr@   )release_strver_strr   r   r   get_linux_version   s   rH   posix)r      z	127.0.0.1z::1c           
      C   s  | t jkrt}n| t jkrt}ntd|t jkrtd|dkr%tdt  | ||}zC||df |t	t j
d | dd \}}t  | ||}z|||f | \}}	W n tyi   |   w W |  n|  w |d |d ||fS )	z
    Returns a pair of sockets in the manner of socketpair with the additional
    feature that they will be non-blocking. Prior to Python 3.5, socketpair
    did not exist on Windows at all.
    z?Only AF_INET and AF_INET6 socket address families are supportedz0Only SOCK_STREAM socket socket_type is supportedr   zOnly protocol zero is supported   Nr   F)socketAF_INET
_LOCALHOSTAF_INET6_LOCALHOST_V6
ValueErrorSOCK_STREAMbindlistenmin	SOMAXCONNgetsocknameconnectaccept	Exceptionclosesetblocking)
familysocket_typeprotohostlsockaddrportcsockssock_r   r   r   _nonblocking_socketpair   s6   




rg   )Mr2   abcosplatformrerL   sys_sysr   version_infomajorPY2PY3compiler=   systemON_LINUXON_OSX
ON_WINDOWSABCMetaobjectr   errorSOCKET_ERROROSErrorSOL_TCPAttributeErrorIPPROTO_TCPurllib.parser   	url_quoter	   url_unquoter
   r   url_parse_qsr   ior   r&   
basestringr"   str_or_bytesrangexrangeunicode_typer   r   r   r   r   r$   r'   r%   r5   r8   urllibunicodedictr   r   	iteritems
itervalueschrr;   r@   rH   nameHAVE_SIGNALEINTR_IS_EXPOSEDLINUX_VERSIONreleaserN   rP   rM   rR   rg   r   r   r   r   <module>   s    




	

