B \3@sddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZeeZe jrddlmZGdddejZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#m$Z$ddl%m&Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-e'Z.e/Z/eZ0ddZ1ddZ2dEddZ3dFd d!Z4ndd l5mZdd l5mZdd l5mZdd l5mZdd lmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"dd"l6m7Z7ddl8m+Z+e9Z.dd#l,m:Z/dd$l,m;Z-ddlm?Z?Wn"e@k rdd-lAm?Z?YnXejBdd.d/krddlCZDeEZFd0d1ZGn"ddlHZIeIjJjKjLZFddlDZDd2d1ZGd3d4ZMeNd5d6ZOeNd7d8ZPeOe_OePe_Pd9d:ZQd;d<ZRyeSd=ZTWneUk rpd>ZTYnXd?d@ZVdJdAdBZWdCdDZXdS)KN)floor)six)MD5UnavailableError) exceptions) http_clientc@s eZdZdS) HTTPHeadersN)__name__ __module__ __qualname__r r 3/tmp/pip-build-uw_ogi45/botocore/botocore/compat.pyr"sr)quote) urlencode)unquote) unquote_plus)urlparse)urlsplit) urlunsplit)urljoin) parse_qsl)parse_qs) HTTPResponse)IOBase) encodebytes) formatdate) zip_longestcCs|jjjj|dS)zSet the timeout of the socket from an HTTPResponse. :param http_response: An instance of ``httplib.HTTPResponse`` N)_fpfpraw_sock settimeout) http_responsetimeoutr r r set_socket_timeout<sr#cCst|dS)N)inspectZgetfullargspec)funcr r r accepts_kwargsDsr'cCs|S)Nr )sencodingerrorsr r r ensure_unicodeIsr+utf-8strictcCs8t|tr|||St|tr$|Stdt|dS)Nz#Expected str or bytes, received %s.) isinstancestrencodebytes ValueErrortype)r(r)r*r r r ensure_bytesMs    r4)Message)izip) izip_longest) encodestringc@seZdZddZdS)rccsx|jD]\}}|VqWdS)N)_headers)selffieldvaluer r r __iter__kszHTTPHeaders.__iter__N)rr r r=r r r r rgscCs||}t||S)N)r0rdecode)r<r)Z byte_stringr r r unquote_stros r?cCs|jjj|dS)zSet the timeout of the socket from an HTTPResponse. :param http_response: An instance of ``httplib.HTTPResponse`` N)rrrr )r!r"r r r r#yscCst|dS)Nr$)r%Z getargspec)r&r r r r'scCst|tjr|St|||S)N)r.r text_typeunicode)r(r)r*r r r r+s cCs8t|tr|||St|tr$|Stdt|dS)Nz%Expected str or unicode, received %s.)r.rAr0r/r2r3)r(r)r*r r r r4s    ) OrderedDictr$)r$cCstjddtjdddS)Nignorez$Certificate has no.*subjectAltName.*z.*urllib3\.connection)messagecategorymodule)warningsfilterwarningsrSecurityWarningr r r r filter_ssl_san_warningss rKcCsdS)Nr r r r r rKscCstjddtjddtdS)NrDz+A true SSLContext object is not available.*z.*urllib3\.util\.ssl_)rErFrG)rHrIrInsecurePlatformWarningrKr r r r filter_ssl_warningss rMcCs(|}x|D]\}}|||<qW|S)N)items)clsd new_instancekeyr<r r r from_dicts rScCs$|}x|D]\}}|||<q W|S)Nr )rOpairsrQrRr<r r r from_pairss rUcCs^tj}|ddkrP|ddkrP|ddkrPi}x*|D]}||||d<q4Wn t|}|S)aJ There is a bug in Python versions < 2.6.5 that prevents you from passing unicode keyword args (#4978). This function takes a dictionary of kwargs and returns a copy. If you are using Python < 2.6.5, it also encodes the keys to avoid this bug. Oh, and version_info wasn't a namedtuple back then, either! rr$rCzutf-8)sys version_infor0copy)kwargsvi copy_kwargsrRr r r r^s$  r^cCs@tjdddkr|S|jdd}|jd}||j|S)a Returns the total seconds in a ``datetime.timedelta``. Python 2.6 does not have ``timedelta.total_seconds()``, so we have to calculate this ourselves. On 2.7 or better, we'll take advantage of the built-in method. The math was pulled from the ``datetime`` docs (http://docs.python.org/2.7/library/datetime.html#datetime.timedelta.total_seconds). :param delta: The timedelta object :type delta: ``datetime.timedelta`` Nr$)r$rCg @g.A)rYrZ total_secondsdays microsecondsseconds)deltaZday_in_secondsZmicro_in_secondsr r r r`s  r`TFcOstrtj||StdS)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_AVAILABLEhashlibmd5r)argsr\r r r get_md5s  ricCs,|dkrtj}|dkrt|St|SdS)Nwin32)rYplatform_windows_shell_splitshlexsplit)r(rkr r r compat_shell_splits rocCs<|sgSg}g}d}d}x|D]}|dkr4|d7}q|dkr|dkr~|dtt|d|d}d}|dkr~|dq| }|dq|dkr|s|dkr|d|d}|r|d|g}q|dkr|d|d}||qW|r td ||dkr"|d||r8|d||S) aSplits 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\rV"r$)  z"No closing quotation in string: %s)appendintrjoinr2)r( componentsZbuffZ is_quotedZnum_backslashes character remainderr r r rl sJ       rl)NN)r,r-)r,)r,r-)r,r-)N)Yr[datetimerYr%rHrfloggingrmmathrZbotocore.vendoredrZbotocore.exceptionsrurllib3r getLoggerrloggerPY3Zbotocore.vendored.six.movesr HTTPMessager urllib.parser rrrrrrrrr http.clientrior_IOBasebase64r email.utilsr itertoolsr file_typezipr?r#r'r+r4urllib email.messager5Z email.Utilsfiler6r7httplibr8 collectionsrB ImportErrorZ ordereddictrZZ simplejsonjson SyntaxErrorZ XMLParseErrorrKxml.etree.cElementTreexmletree cElementTree ParseErrorrM classmethodrSrUr^r`rgrer2rirorlr r r r s