U
    M8c,                  	   @   sT  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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G d
d de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-m.Z. d dl/m0Z0 d dl1m2Z2 e,Z3e4Z4e"Z5dd Z6dd Z7dNddZ8dOddZ9zd dl:m;  m<Z= W n( e>k
r   d dl?m;  m@Z= Y nX e=jAZBd dlCZCdd ZDeEdd ZFeEd d! ZGeFe_FeGe_Gd"d# ZHd$d% ZIzeJ  d&ZKW n eLk
r   d'ZKY nX d(d) ZMdPd*d+ZNd,d- ZOd.d/ ZPz(d dlQZRejSTd0d1ZUeUV d2k ZWW n e>k
r   d'ZWY nX d3ZXe
Yd4eX d5 ZZd6Z[d7j\e[eXd8Z]e[e]d9Z^d:d;d<d=d>d?d@dAdBg	Z_dCZ`dDdEadFdG e_D  dH ZbdIe` dJ ZcdKeb dD ec dL Zde
Yd4ed d5 ZeefdMZgzd dlhZhd&ZiW n e>k
rN   d'ZiY nX dS )Q    N)HTTPMessage)OrderedDict)MutableMapping)floor)six)MD5UnavailableError)tzlocal)
exceptionsc                   @   s   e Zd ZdS )HTTPHeadersN)__name__
__module____qualname__ r   r   3/tmp/pip-unpacked-wheel-ozje0y8b/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_timeout@   s    r&   c                 C   s   t | d S )N   )inspectgetfullargspec)funcr   r   r   accepts_kwargsH   s    r+   c                 C   s   | S Nr   sencodingerrorsr   r   r   ensure_unicodeM   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_bytesQ   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_warningsb   s    rC   c                 C   s$   |  }|  D ]\}}|||< q|S r,   )items)clsdnew_instancekeyvaluer   r   r   	from_dictl   s    
rJ   c                 C   s    |  }|D ]\}}|||< q
|S r,   r   )rE   pairsrG   rH   rI   r   r   r   
from_pairst   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)rr   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     rx   )z(?:%25|%)(?:[z]|%[a-fA-F0-9]{2})+z\[z)?\]z	
)NN)r2   r3   )N)jrM   datetimerX   r(   r@   rS   http.clientr   loggingr[   reoscollectionsr   collections.abcr   mathr   Zbotocore.vendoredr   Zbotocore.exceptionsr   rl   r   urllib3r	   	getLoggerr   loggerr
   urllib.parser   r   r   r   r   r   r   r   r   r   r   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compileIPV4_REHEX_PATformatLS32_PATru   _variationsUNRESERVED_PATrf   IPV6_PATZONE_ID_PATIPV6_ADDRZ_PATIPV6_ADDRZ_RE	frozensetZUNSAFE_URL_CHARSgzipZHAS_GZIPr   r   r   r   <module>   s   
0







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