
    )Jf5                        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j        d          Z ej                    dk    Z ej                    dk    Z ej                    dk    Z ej        defi           Zej	        dd         d	k     rej        ZneZ	 ej        Zn# e$ r
 ej        ZY nw xY werFd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 Z.d Z/d Z0d Z1d Z2d Z3 G d de4          Z5d Z6d Z7nId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 Z.d Z6d Z7d Z@d ZAd ZBejC        dk    ZDej	        dd         dk    ZEdZF ej                    dk    r eB ejG                              ZFd ZHd!ZIejJ        ejK        df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                  (    t          j                    S )z2
        Python 3 supports monotonic time
        )time	monotonic     N/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/pika/compat.pytime_nowr   9   s     ~r   c                 D    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dcts    r   dictkeysr   ?   s     CHHJJr   c                 D    t          |                                           S )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   s    r   
dictvaluesr   K   s     CJJLL!!!r   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   s    r   dict_iteritemsr!   V   s     yy{{r   c                 *    |                                  S )zw
        :param dict dct:
        :returns: an iterator of the values of a dictionary
        :rtype: iterator
        )r   r   s    r   dict_itervaluesr#   a   s     zz||r   c                       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)argss    r   byter'   i   s     T{{r   c                       e Zd ZdZd Zd ZdS )longzy
        A marker class that signifies that the integer value should be
        serialized as `l` instead of `I`
        c                 :    t          t          |                     S )N)strintselfs    r   __str__zlong.__str__y   s    s4yy>>!r   c                 &    t          |           dz   S )NLr+   r-   s    r   __repr__zlong.__repr__|   s    t99s?"r   N)__name__
__module____qualname____doc__r/   r3   r   r   r   r)   r)   s   s<        	 	
	" 	" 	"	# 	# 	# 	# 	#r   r)   c                      t          |           S )zs
        Return the canonical str value for the string.
        In both Python 3 and Python 2 this is str.
        r2   values    r   canonical_strr;      s     5zzr   c                 ,    t          | t                    S z&
        Is value an integer?
        )
isinstancer,   r9   s    r   
is_integerr?      s     %%%%r   )r	   r
   r   )r   r   c                  (    t          j                     S )z:
        Python 2 does not support monotonic time
        )r   r   r   r   r   r      s     y{{r   c                     	 t          |           S # t          $ r% t          |                     d                    cY S w xY 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encoder9   s    r   r;   r;      sN    	.u::! 	. 	. 	.u||G,,-----	.s    ,A A c                 :    t          | t          t          f          S r=   )r>   r,   r)   r9   s    r   r?   r?      s     %#t---r   c                 Z    t          | t                    s|                     d          S | S )z 
    Returns value as bytes
    zUTF-8)r>   r%   rC   r9   s    r   as_bytesrF      s-     eU## %||G$$$Lr   c                     |                                  rt          |           S t                              |           }|r't          |                                d                   ndS )z%
    Returns value as in integer
    r   )isdigitr,   RE_NUMmatchgroups)r:   rJ   s     r   to_digitrL      sV     }} 5zzLLE%*13u||~~a !!!1r   c                     |                      d          d         }t          t          t          |                     d          dd                             S )z
    Gets linux version
    -r   .Nr   )splittuplemaprL   )release_strver_strs     r   get_linux_versionrU      sI     $$Q'GXw}}S11"1"566777r   posix)r      z	127.0.0.1z::1c                 h   | 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          j         | ||          }	 |                    |df           |                    t          t           j
        d                     |                                dd         \  }}t          j         | ||          }	 |                    ||f           |                                \  }}	n## t          $ r |                                  w xY w	 |                                 n# |                                 w xY 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_s
             r   _nonblocking_socketpairru      s    	6?	"	" ) * * 	*f(((KLLLzz:;;;M&+u55E

D!9S)3//000&&((!,
dfk599	MM4,'''||~~HE11 	 	 	KKMMM	 
 	 
e	e%<s%   A9E- .D4 3E- 4 EE- -F)Mr7   abcosplatformrerZ   sys_sysr   version_infomajorPY2PY3compilerI   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)   r;   r?   urllibunicodedictr   r   	iteritems
itervalueschrrF   rL   rU   nameHAVE_SIGNALEINTR_IS_EXPOSEDLINUX_VERSIONreleaser\   r^   r[   r`   ru   r   r   r   <module>r      s    


 				  				      
"
g	J		8?'			h	&X_)+
 s{>F9b99RaR6!!<LL L!nGG ! ! ! GGG!  M.M M M M M M M M M M M M M M J <L F L     
  
  
 	" 	" 	"	 	 	    
# 
# 
# 
# 
#s 
# 
# 
#  & & & & ONNNNNNNNN========!!!!!!JLFLyHJ^NoODD  
. 
. 
.. . .  2 2 28 8 8 g $RaR(F2 8?%%&6h&6&8&899M
 $*>(.(:"#) ) ) ) ) )s   ,B4 4CC