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	jUVd0d1ZWeWX 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`dBdCadDdE 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







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