U
    ³.¬b
,  ã                	   @   sD  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d dlZd dlZd dl	Z	d dl
mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ e e¡Zd d	lmZ G d
d„ dejƒZd dlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) d dl*m+Z+ d dl,m-Z. d dl/m0Z0 d dl1m2Z2 d dl3m4Z4 e.Z5e6Z6e#Z7dd„ Z8dd„ Z9dNdd„Z:dOdd„Z;zd dl<m=  m>Z? W n( e@k
�r¦   d dlAm=  mBZ? Y nX e?jCZDd dlEZEdd„ ZFeGdd„ ƒZHeGd d!„ ƒZIeHe_HeIe_Id"d#„ ZJd$d%„ ZKze L¡  d&ZMW n eNk
�r   d'ZMY nX d(d)„ ZOdPd*d+„ZPd,d-„ ZQd.d/„ ZRz(d dlSZTe	jU Vd0d1¡ZWeW X¡ d2k ZYW n e@k
�r‚   d'ZYY nX d3ZZd4Z[d5j\e[eZd6�Z]e[e]d7œZ^d8d9d:d;d<d=d>d?d@g	Z_dAZ`dBdC adDdE„ e_D ƒ¡ dF ZbdGe` dH ZcdIeb dB ec dJ Zde edKed dL ¡ZfegdMƒZhzd dliZid&ZjW n e@k
�r>   d'ZjY nX dS )Qé    N)ÚOrderedDict)ÚMutableMapping)Úfloor)Úsix)ÚMD5UnavailableError)Útzlocal)Ú
exceptions)Úhttp_clientc                   @   s   e Zd ZdS )ÚHTTPHeadersN)Ú__name__Ú
__module__Ú__qualname__© r   r   ú3/tmp/pip-unpacked-wheel-7df6wvge/botocore/compat.pyr
   &   s   r
   )
ÚquoteÚ	urlencodeÚunquoteÚunquote_plusÚurlparseÚurlsplitÚ
urlunsplitÚurljoinÚ	parse_qslÚparse_qs)ÚHTTPResponse)ÚIOBase)Úencodebytes)Ú
formatdate)Úzip_longestc                 C   s   | j jjj |¡ dS )z|Set the timeout of the socket from an HTTPResponse.

    :param http_response: An instance of ``httplib.HTTPResponse``

    N)Ú_fpÚfpÚrawÚ_sockÚ
settimeout)Úhttp_responseÚtimeoutr   r   r   Úset_socket_timeoutA   s    r&   c                 C   s   t  | ¡d S )Né   )ÚinspectÚgetfullargspec)Úfuncr   r   r   Úaccepts_kwargsI   s    r+   c                 C   s   | S ©Nr   ©ÚsÚencodingÚerrorsr   r   r   Úensure_unicodeN   s    r1   úutf-8Ústrictc                 C   s<   t | tƒr|  ||¡S t | tƒr$| S tdt| ƒ› d�ƒ‚d S )Nz Expected str or bytes, received Ú.)Ú
isinstanceÚstrÚencodeÚbytesÚ
ValueErrorÚtyper-   r   r   r   Úensure_bytesR   s
    

r;   c                   C   s   t jddtjdd� d S )NÚignorez+A true SSLContext object is not available.*z.*urllib3\.util\.ssl_)ÚmessageÚcategoryÚmodule)ÚwarningsÚfilterwarningsr   ÚInsecurePlatformWarningr   r   r   r   Úfilter_ssl_warningsc   s    ürC   c                 C   s$   | ƒ }|  ¡ D ]\}}|||< q|S r,   )Úitems)ÚclsÚdÚnew_instanceÚkeyÚvaluer   r   r   Ú	from_dictm   s    
rJ   c                 C   s    | ƒ }|D ]\}}|||< q
|S r,   r   )rE   ÚpairsrG   rH   rI   r   r   r   Ú
from_pairsu   s    
rL   c                 C   s   t   | ¡}|S )zI
    This used to be a compat shim for 2.6 but is now just an alias.
    )Úcopy)ÚkwargsÚcopy_kwargsr   r   r   rO   �   s    
rO   c                 C   s   |   ¡ S )zÕ
    Returns the total seconds in a ``datetime.timedelta``.

    This used to be a compat shim for 2.6 but is now just an alias.

    :param delta: The timedelta object
    :type delta: ``datetime.timedelta``
    )Útotal_seconds)Údeltar   r   r   rP   ‰   s    	rP   TFc                  O   s   t rtj| |ŽS tƒ ‚dS )aÿ  
    Attempts to get an md5 hashing object.

    :param raise_error_if_unavailable: raise an error if md5 is unavailable on
        this system. If False, None will be returned if it is unavailable.
    :type raise_error_if_unavailable: bool
    :param args: Args to pass to the MD5 constructor
    :param kwargs: Key word arguments to pass to the MD5 constructor
    :return: An MD5 hashing object if available. If it is unavailable, None
        is returned if raise_error_if_unavailable is set to False.
    N)ÚMD5_AVAILABLEÚhashlibÚmd5r   )ÚargsrN   r   r   r   Úget_md5ž   s    rV   c                 C   s,   |d krt j}|dkrt| ƒS t | ¡S d S )NÚwin32)ÚsysÚplatformÚ_windows_shell_splitÚshlexÚsplit)r.   rY   r   r   r   Úcompat_shell_split°   s
    r]   c                 C   s:  | sg S g }g }d}d}| D ]Ö}|dkr2|d7 }q|dkrŽ|dkr||  dtt|d ƒƒ ¡ |d }d}|dkr||  d¡ q| }|  d¡ q|dkrÎ|sÎ|dkr´|  d| ¡ d}|rò|  d |¡¡ g }q|dkrè|  d| ¡ d}|  |¡ q|�rtd	| › �ƒ‚|dk�r |  d| ¡ |�r6|  d |¡¡ |S )
a  Splits up a windows command as the built-in command parser would.

    Windows has potentially bizarre rules depending on where you look. When
    spawning a process via the Windows C runtime (which is what python does
    when you call popen) the rules are as follows:

    https://docs.microsoft.com/en-us/cpp/cpp/parsing-cpp-command-line-arguments

    To summarize:

    * Only space and tab are valid delimiters
    * Double quotes are the only valid quotes
    * Backslash is interpreted literally unless it is part of a chain that
      leads up to a double quote. Then the backslashes escape the backslashes,
      and if there is an odd number the final backslash escapes the quote.

    :param s: The command string to split up into parts.
    :return: A list of command components.
    Fr   ú\é   ú"r'   Ú )ú ú	z No closing quotation in string: )ÚappendÚintr   Újoinr9   )r.   Ú
componentsZbuffZ	is_quotedZnum_backslashesÚ	characterÚ	remainderr   r   r   rZ   º   sJ    


rZ   c                  C   s(   t jdkrddlm}  t| fS tfS d S )NrW   r   ©Ú
tzwinlocal)rX   rY   Údateutil.tzrk   r   rj   r   r   r   Úget_tzinfo_options  s    
rm   ZBOTO_DISABLE_CRTÚfalseÚtruez(?:[0-9]{1,3}\.){3}[0-9]{1,3}z[0-9A-Fa-f]{1,4}z(?:{hex}:{hex}|{ipv4}))ÚhexZipv4)rp   Úls32z(?:%(hex)s:){6}%(ls32)sz::(?:%(hex)s:){5}%(ls32)sz%(?:%(hex)s)?::(?:%(hex)s:){4}%(ls32)sz2(?:(?:%(hex)s:)?%(hex)s)?::(?:%(hex)s:){3}%(ls32)sz6(?:(?:%(hex)s:){0,2}%(hex)s)?::(?:%(hex)s:){2}%(ls32)sz/(?:(?:%(hex)s:){0,3}%(hex)s)?::%(hex)s:%(ls32)sz'(?:(?:%(hex)s:){0,4}%(hex)s)?::%(ls32)sz&(?:(?:%(hex)s:){0,5}%(hex)s)?::%(hex)sz(?:(?:%(hex)s:){0,6}%(hex)s)?::zDABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._!\-~z(?:ú|c                 C   s   g | ]}|t  ‘qS r   )Ú_subs)Ú.0Úxr   r   r   Ú
<listcomp>Q  s     rv   ú)z(?:%25|%)(?:[z]|%[a-fA-F0-9]{2})+z\[z)?\]ú^ú$z	
)NN)r2   r3   )N)krM   ÚdatetimerX   r(   r@   rS   Úloggingr[   ÚreÚosÚcollectionsr   Úcollections.abcr   Úmathr   Zbotocore.vendoredr   Zbotocore.exceptionsr   rl   r   Úurllib3r   Ú	getLoggerr   ÚloggerZbotocore.vendored.six.movesr	   ÚHTTPMessager
   Úurllib.parser   r   r   r   r   r   r   r   r   r   Úhttp.clientr   Úior   Ú_IOBaseÚbase64r   Úemail.utilsr   Ú	itertoolsr   Ú	file_typeÚzipZunquote_strr&   r+   r1   r;   Úxml.etree.cElementTreeÚetreeÚcElementTreeZETreeÚImportErrorÚxml.etree.ElementTreeÚElementTreeÚ
ParseErrorZXMLParseErrorÚjsonrC   ÚclassmethodrJ   rL   rO   rP   rT   rR   r9   rV   r]   rZ   rm   Zawscrt.authZawscrtÚenvironÚgetÚdisabledÚlowerZHAS_CRTÚIPV4_PATÚHEX_PATÚformatÚLS32_PATrs   Ú_variationsÚUNRESERVED_PATrf   ÚIPV6_PATÚZONE_ID_PATÚIPV6_ADDRZ_PATÚcompileÚIPV6_ADDRZ_REÚ	frozensetZUNSAFE_URL_CHARSÚgzipZHAS_GZIPr   r   r   r   Ú<module>   s°   
0







^
	
îÿ