ok

Mini Shell

Direktori : /opt/alt/python311/lib64/python3.11/urllib/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/urllib/__pycache__/request.cpython-311.opt-1.pyc

�

�fw���>�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlmZmZmZddlmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+	ddl,Z,dZ-n
#e.$rdZ-YnwxYwgd�Z/d	e
j0dd
�zZ1da2dej3fddddd�d�Z4d
�Z5gZ6dgd�Z7d�Z8e
j9de
j:��Z;d�Z<Gd�d��Z=Gd�d��Z>d�Z?Gd�d��Z@Gd�de@��ZAGd�de@��ZBGd�de@��ZCd�ZDGd �d!e@��ZEGd"�d#��ZFGd$�d%eF��ZGGd&�d'eG��ZHGd(�d)��ZIGd*�d+eIe@��ZJGd,�d-eIe@��ZKejLZMGd.�d/��ZNGd0�d1e@eN��ZOGd2�d3e@eN��ZPGd4�d5e@��ZQGd6�d7eQ��ZReSejTd8��r#Gd9�d:eQ��ZUe/�Vd:��Gd;�d<e@��ZWGd=�d>e@��ZXd?�ZYd@�ZZGdA�dBe@��Z[dC�Z\GdD�dEe@��Z]GdF�dGe]��Z^GdH�dIe@��Z_dJZ`ejadKkr	ddLlbmcZcmdZdndM�ZcdN�ZdiZeGdO�dP��ZfGdQ�dRef��ZgdahdS�ZidajdT�ZkdaldU�ZmdandV�ZoGdW�dX��ZpdY�ZqdhdZ�Zrd[�Zsd\�Zte
jud]krdd^lvmwZwmxZxd_�Zyd`�Zzda�Z{db�Z|dSejadKkrdc�Z}dd�Z|de�Z~df�Z{dSeqZ|erZ{dS)ia�
An extensible library for opening URLs using a variety of protocols

The simplest way to use this module is to call the urlopen function,
which accepts a string containing a URL or a Request object (described
below).  It opens the URL and returns the results as file-like
object; the returned object has some extra methods described below.

The OpenerDirector manages a collection of Handler objects that do
all the actual work.  Each Handler implements a particular protocol or
option.  The OpenerDirector is a composite object that invokes the
Handlers needed to open the requested URL.  For example, the
HTTPHandler performs HTTP GET and POST requests and deals with
non-error returns.  The HTTPRedirectHandler automatically deals with
HTTP 301, 302, 303, 307, and 308 redirect errors, and the
HTTPDigestAuthHandler deals with digest authentication.

urlopen(url, data=None) -- Basic usage is the same as original
urllib.  pass the url and optionally data to post to an HTTP URL, and
get a file-like object back.  One difference is that you can also pass
a Request instance instead of URL.  Raises a URLError (subclass of
OSError); for HTTP errors, raises an HTTPError, which can also be
treated as a valid response.

build_opener -- Function that creates a new OpenerDirector instance.
Will install the default handlers.  Accepts one or more Handlers as
arguments, either instances or Handler classes that it will
instantiate.  If one of the argument is a subclass of the default
handler, the argument will be installed instead of the default.

install_opener -- Installs a new opener as the default opener.

objects of interest:

OpenerDirector -- Sets up the User Agent as the Python-urllib client and manages
the Handler classes, while dealing with requests and responses.

Request -- An object that encapsulates the state of a request.  The
state can be as simple as the URL.  It can also include extra HTTP
headers, e.g. a User-Agent.

BaseHandler --

internals:
BaseHandler and parent
_call_chain conventions

Example usage:

import urllib.request

# set up authentication info
authinfo = urllib.request.HTTPBasicAuthHandler()
authinfo.add_password(realm='PDQ Application',
                      uri='https://mahler:8092/site-updates.py',
                      user='klem',
                      passwd='geheim$parole')

proxy_support = urllib.request.ProxyHandler({"http" : "http://ahad-haam:3128"})

# build a new opener that adds authentication and caching FTP handlers
opener = urllib.request.build_opener(proxy_support, authinfo,
                                     urllib.request.CacheFTPHandler)

# install it
urllib.request.install_opener(opener)

f = urllib.request.urlopen('https://www.python.org/')
�N)�URLError�	HTTPError�ContentTooShortError)�urlparse�urlsplit�urljoin�unwrap�quote�unquote�
_splittype�
_splithost�
_splitport�
_splituser�_splitpasswd�
_splitattr�_splitquery�_splitvalue�	_splittag�	_to_bytes�unquote_to_bytes�
urlunparse)�
addinfourl�addclosehookTF)!�Request�OpenerDirector�BaseHandler�HTTPDefaultErrorHandler�HTTPRedirectHandler�HTTPCookieProcessor�ProxyHandler�HTTPPasswordMgr�HTTPPasswordMgrWithDefaultRealm�HTTPPasswordMgrWithPriorAuth�AbstractBasicAuthHandler�HTTPBasicAuthHandler�ProxyBasicAuthHandler�AbstractDigestAuthHandler�HTTPDigestAuthHandler�ProxyDigestAuthHandler�HTTPHandler�FileHandler�
FTPHandler�CacheFTPHandler�DataHandler�UnknownHandler�HTTPErrorProcessor�urlopen�install_opener�build_opener�pathname2url�url2pathname�
getproxies�urlretrieve�
urlcleanup�	URLopener�FancyURLopenerz%d.%d�)�cafile�capath�	cadefault�contextc��|s|s|r�ddl}|jdtd��|�td���tstd���tjt
jj||���}|�	dg��t|�	��}t|��}	nA|r t|�	��}t|��}	nt�t��xa}	nt}	|	�
|||��S)
a�Open the URL url, which can be either a string or a Request object.

    *data* must be an object specifying additional data to be sent to
    the server, or None if no such data is needed.  See Request for
    details.

    urllib.request module uses HTTP/1.1 and includes a "Connection:close"
    header in its HTTP requests.

    The optional *timeout* parameter specifies a timeout in seconds for
    blocking operations like the connection attempt (if not specified, the
    global default timeout setting will be used). This only works for HTTP,
    HTTPS and FTP connections.

    If *context* is specified, it must be a ssl.SSLContext instance describing
    the various SSL options. See HTTPSConnection for more details.

    The optional *cafile* and *capath* parameters specify a set of trusted CA
    certificates for HTTPS requests. cafile should point to a single file
    containing a bundle of CA certificates, whereas capath should point to a
    directory of hashed certificate files. More information can be found in
    ssl.SSLContext.load_verify_locations().

    The *cadefault* parameter is ignored.


    This function always returns an object which can work as a
    context manager and has the properties url, headers, and status.
    See urllib.response.addinfourl for more detail on these properties.

    For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse
    object slightly modified. In addition to the three new methods above, the
    msg attribute contains the same information as the reason attribute ---
    the reason phrase returned by the server --- instead of the response
    headers as it is specified in the documentation for HTTPResponse.

    For FTP, file, and data URLs and requests explicitly handled by legacy
    URLopener and FancyURLopener classes, this function returns a
    urllib.response.addinfourl object.

    Note that None may be returned if no handler handles the request (though
    the default installed global OpenerDirector uses UnknownHandler to ensure
    this never happens).

    In addition, if proxy settings are detected (for example, when a *_proxy
    environment variable like http_proxy is set), ProxyHandler is default
    installed and makes sure the requests are handled through the proxy.

    rNzJcafile, capath and cadefault are deprecated, use a custom context instead.r;zDYou can't pass both context and any of cafile, capath, and cadefaultzSSL support not available)r<r=zhttp/1.1)r?)�warnings�warn�DeprecationWarning�
ValueError�	_have_ssl�ssl�create_default_context�Purpose�SERVER_AUTH�set_alpn_protocols�HTTPSHandlerr3�_opener�open)
�url�data�timeoutr<r=r>r?rA�
https_handler�openers
          �5/opt/alt/python311/lib64/python3.11/urllib/request.pyr1r1�s/��h����9��������
�0�1C�Q�	H�	H�	H�������
��	:��8�9�9�9��,�S�[�-D�4:�4:�<�<�<��	�"�"�J�<�0�0�0�$�W�5�5�5�
��m�,�,���	��$�W�5�5�5�
��m�,�,���	��'�>�>�)��&�&����;�;�s�D�'�*�*�*�c�
�|adS�N)rL)rRs rSr2r2�s���G�G�GrTc�L�t|��\}}tjt||����5}|���}|dkr/|s-t
j�|��|fcddd��S|rt|d��}n6tj
d���}|j}t�
|��|5||f}	d}
d}d}d}
d	|vrt|d
��}|r
||
|
|��	|�|
��}|sn<|t!|��z
}|�|��|
dz
}
|r
||
|
|���T	ddd��n#1swxYwYddd��n#1swxYwY|dkr||krt%d
||fz|	���|	S)aW
    Retrieve a URL into a temporary location on disk.

    Requires a URL argument. If a filename is passed, it is used as
    the temporary file location. The reporthook argument should be
    a callable that accepts a block number, a read size, and the
    total file size of the URL target. The data argument should be
    valid URL encoded data.

    If a filename is passed and the URL points to a local resource,
    the result is a copy from local file to new file.

    Returns a tuple containing the path to the newly created
    data file as well as the resulting HTTPMessage object.
    �fileN�wbF)�delete� ���r�content-length�Content-LengthT��1retrieval incomplete: got only %i out of %i bytes)r�
contextlib�closingr1�info�os�path�normpathrM�tempfile�NamedTemporaryFile�name�_url_tempfiles�append�int�read�len�writer)rN�filename�
reporthookrO�url_typere�fp�headers�tfp�result�bs�sizerm�blocknum�blocks               rSr7r7�s���  ��_�_�N�H�d�	�	�G�C��.�.�	/�	/�$3�2��'�'�)�)���v���h���7�#�#�D�)�)�7�2�
$3�$3�$3�$3�$3�$3�$3�$3��	,��x��&�&�C�C��-�U�;�;�;�C��x�H��!�!�(�+�+�+�
�	3�	3��w�&�F��B��D��D��H��7�*�*��7�#3�4�5�5���
/��
�8�R��.�.�.�
3�������������E�
�
�"���	�	�%� � � ��A�
���3��J�x��T�2�2�2�
3��	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�!$3�$3�$3�$3�$3�$3�$3�$3�$3�$3�$3����$3�$3�$3�$3�L�q�y�y�T�D�[�[�"�?��T�l�
�"�$�$�	$��Ms=�=E8�?AE8�
B
E!�E8�!E%	�%E8�(E%	�)E8�8E<�?E<c��tD]'}	tj|���#t$rY�$wxYwtdd�=trdadSdS)z0Clean up temporary files from urlretrieve calls.N)rjrd�unlink�OSErrorrL)�	temp_files rSr8r8sr��#���	�	��I�i� � � � ���	�	�	��D�	����	�q�q�q���������s� �
-�-z:\d+$c���|j}t|��d}|dkr|�dd��}t�d|d��}|���S)z�Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    r_��Host)�full_urlr�
get_header�_cut_port_re�sub�lower)�requestrN�hosts   rS�request_hostr�-sa���
�C��C�=�=���D��r�z�z��!�!�&�"�-�-�����B��a�(�(�D��:�:�<�<�rTc��eZdZdidddfd�Zed���Zejd���Zejd���Zed���Zejd���Zejd	���Zd
�Z	d�Z
d�Zd
�Zd�Z
d�Zd�Zd�Zdd�Zd�Zd�ZdS)rNFc��||_i|_i|_d|_||_d|_|���D]\}}|�||���|�t|��}||_	||_
|r	||_dSdSrV)r�rt�unredirected_hdrs�_datarO�_tunnel_host�items�
add_headerr��origin_req_host�unverifiable�method)	�selfrNrOrtr�r�r��key�values	         rS�__init__zRequest.__init__?s�����
����!#�����
���	� ���!�-�-�/�/�	(�	(�J�C���O�O�C��'�'�'�'��"�*�4�0�0�O�.���(����	!� �D�K�K�K�	!�	!rTc�^�|jr d�|j|j��S|jS)Nz{}#{})�fragment�format�	_full_url�r�s rSr�zRequest.full_urlQs-���=�	A��>�>�$�.�$�-�@�@�@��~�rTc��t|��|_t|j��\|_|_|���dSrV)r	r�rr��_parse�r�rNs  rSr�zRequest.full_urlWs:�� ������(1�$�.�(A�(A�%����
����
�
�
�
�
rTc�0�d|_d|_d|_dS)Nr�)r�r��selectorr�s rSr�zRequest.full_url^s�������
���
�
�
rTc��|jSrV)r�r�s rSrOzRequest.datads
���z�rTc��||jkr3||_|�d��r|�d��dSdSdS)N�Content-length)r��
has_header�
remove_header)r�rOs  rSrOzRequest.datahsZ���4�:����D�J����/�0�0�
5��"�"�#3�4�4�4�4�4�
��

5�
5rTc��d|_dSrV)rOr�s rSrOzRequest.datars
����	�	�	rTc��t|j��\|_}|j�td|jz���t|��\|_|_|jrt|j��|_dSdS)Nzunknown url type: %r)	rr��typerDr�r
r�r�r)r��rests  rSr�zRequest._parsevst��$�T�^�4�4���	�4��9���3�d�m�C�D�D�D�#-�d�#3�#3� ��	�4�=��9�	+���	�*�*�D�I�I�I�	+�	+rTc�:�|j�dnd}t|d|��S)z3Return a string indicating the HTTP request method.N�POST�GETr�)rO�getattr)r��default_methods  rS�
get_methodzRequest.get_method~s$��#'�9�#8���e���t�X�~�6�6�6rTc��|jSrV)r�r�s rS�get_full_urlzRequest.get_full_url�s
���}�rTc�x�|jdkr|js
|j|_n||_|j|_||_dS)N�https)r�r�r�r�r�)r�r�r�s   rS�	set_proxyzRequest.set_proxy�s?���9�����(9�� $�	�D����D�I� �M�D�M���	�	�	rTc�"�|j|jkSrV)r�r�r�s rS�	has_proxyzRequest.has_proxy�s���}��
�-�-rTc�>�||j|���<dSrV)rt�
capitalize�r�r��vals   rSr�zRequest.add_header�s��),���S�^�^�%�%�&�&�&rTc�>�||j|���<dSrV)r�r�r�s   rS�add_unredirected_headerzRequest.add_unredirected_header�s��36���s�~�~�/�/�0�0�0rTc�&�||jvp||jvSrV)rtr��r��header_names  rSr�zRequest.has_header�s!���t�|�+�6��t�5�5�	7rTc�j�|j�||j�||����SrV)rt�getr�)r�r��defaults   rSr�zRequest.get_header�s5���|�����"�&�&�{�G�<�<�>�>�	>rTc�r�|j�|d��|j�|d��dSrV)rt�popr�r�s  rSr�zRequest.remove_header�s9�������d�+�+�+���"�"�;��5�5�5�5�5rTc�d�i|j�|j�}t|�����SrV)r�rt�listr�)r��hdrss  rS�header_itemszRequest.header_items�s,��9�$�(�9�D�L�9���D�J�J�L�L�!�!�!rTrV)�__name__�
__module__�__qualname__r��propertyr��setter�deleterrOr�r�r�r�r�r�r�r�r�r�r��rTrSrr=s�������!%�r�!%�E��!�!�!�!�$����X��
�_����_���������
����X��
�[�5�5��[�5�
�\����\��+�+�+�7�7�7�
������.�.�.�-�-�-�7�7�7�7�7�7�>�>�>�>�
6�6�6�"�"�"�"�"rTrc�J�eZdZd�Zd�Zd�Zd�Zdejfd�Z	d	d�Z
d�ZdS)
rc�t�dtz}d|fg|_g|_i|_i|_i|_i|_dS)N�Python-urllib/%sz
User-agent)�__version__�
addheaders�handlers�handle_open�handle_error�process_response�process_request)r��client_versions  rSr�zOpenerDirector.__init__�sH��+�k�9��(�.�9�:�����
������� "���!����rTc�L�t|d��stdt|��z���d}t|��D�].}|dvr�|�d��}|d|�}||dzd�}|�d��ro|�d��|zdz}||dzd�}	t
|��}n#t$rYnwxYw|j�	|i��}	|	|j|<n1|dkr
|}|j
}	n!|d	kr
|}|j}	n|d
kr
|}|j}	n��|	�
|g��}
|
rtj|
|��n|
�|��d}��0|r1tj|j|��|�|��dSdS)N�
add_parentz%expected BaseHandler instance, got %rF)�redirect_request�do_open�
proxy_open�_r_�errorrM�responser�T)�hasattr�	TypeErrorr��dir�find�
startswithrlrDr�r�r�r�r��
setdefault�bisect�insortrkr�r�)r��handler�added�meth�i�protocol�	condition�j�kind�lookupr�s           rS�add_handlerzOpenerDirector.add_handler�s���w��-�-�	+��C� ��M�M�*�+�+�
+�����L�L�#	�#	�D��D�D�D���	�	�#���A��B�Q�B�x�H��Q�q�S�T�T�
�I��#�#�G�,�,�
��N�N�3�'�'�!�+�a�/���A�a�C�D�D�z����t�9�9�D�D��!�����D������*�.�.�x��<�<��.4��!�(�+�+��f�$�$����)����j�(�(����.����i�'�'����-�����(�(��r�2�2�H��
)��
�h��0�0�0�0�����(�(�(��E�E��	%��M�$�-��1�1�1����t�$�$�$�$�$�	%�	%s�3C�
C�Cc��dSrVr�r�s rS�closezOpenerDirector.close�����rTc�r�|�|d��}|D]}t||��}||�}|�|cS�dS)Nr�)r�r�)	r��chainr��	meth_name�argsr�r��funcrvs	         rS�_call_chainzOpenerDirector._call_chain�s^���9�9�T�2�&�&���	�	�G��7�I�.�.�D��T�4�[�F��!��
�
�
�"�	�	rTNc��t|t��rt||��}n|}|�||_||_|j}|dz}|j�|g��D]}t||��}||��}�tj
d|j|j|j|�
����|�||��}	|dz}|j�|g��D]}t||��}|||	��}	�|	S)N�_requestzurllib.Request�	_response)�
isinstance�strrrOrPr�r�r�r��sys�auditr�rtr��_openr�)
r��fullurlrOrP�reqr�r��	processorr�r�s
          rSrMzOpenerDirector.open�s"���g�s�#�#�	 ��'�4�(�(�C�C��C����������8���Z�'�	��-�1�1�(�B�?�?�	�	�I��9�i�0�0�D��$�s�)�)�C�C��	�"�C�L�#�(�C�K����IY�IY�Z�Z�Z��:�:�c�4�(�(���[�(�	��.�2�2�8�R�@�@�	+�	+�I��9�i�0�0�D��t�C��*�*�H�H��rTc���|�|jdd|��}|r|S|j}|�|j||dz|��}|r|S|�|jdd|��S)Nr��default_openr�unknown�unknown_open)r�r�r�)r�rrOrvr�s     rSrzOpenerDirector._opens����!�!�$�"2�I�"0�#�7�7���	��M��8���!�!�$�"2�H�h�")�?*�+.�0�0���	��M����� 0�)� .��5�5�	5rTc��|dvr|jd}|d}d|z}d}|}n|j}|dz}d}|||f|z}|j|�}|r|S|r|dd	f|z}|j|�SdS)
N��httpr�rr;z
http_error_%sr_�_errorrr��http_error_default)r�r�)r��protor��dictr��http_err�	orig_argsrvs        rSr�zOpenerDirector.error s����%�%�%��$�V�,�D���G�E�'�%�/�I��H��I�I��$�D���(�I��H��e�Y�'�$�.��!��!�4�(���	��M��	+��)�%9�:�Y�F�D�#�4�#�T�*�*�	+�	+rTrV)r�r�r�r�r�r�r��socket�_GLOBAL_DEFAULT_TIMEOUTrMrr�r�rTrSrr�s�������	"�	"�	"�-%�-%�-%�^
�
�
�	�	�	�"&�v�/M�����:
5�
5�
5�
5�+�+�+�+�+rTrc	���t��}ttttt
ttttg	}ttjd��r|�
t��t��}|D]g}|D]b}t!|t"��r&t%||��r|�|���=t!||��r|�|���c�h|D]}|�|���|D]}|�|����� |D]6}t!|t"��r
|��}|�|���7|S)a*Create an opener object from a list of handlers.

    The opener will use several default handlers, including support
    for HTTP, FTP and when applicable HTTPS.

    If any of the handlers passed as arguments are subclasses of the
    default handlers, the default handlers will not be used.
    �HTTPSConnection)rr r/r*rrr,r+r0r.r�r�clientrkrK�setrr��
issubclass�add�remover�)r�rR�default_classes�skip�klass�check�hs       rSr3r39sw���
�
�F�#�^�[�.�0C�!�;�0B�"�$�O��t�{�-�.�.�-����|�,�,�,��5�5�D� � � ���	 �	 �E��%��&�&�
 ��e�U�+�+�$��H�H�U�O�O�O���E�5�)�)�
 ���������	 ��&�&�����u�%�%�%�%� �$�$�����5�5�7�7�#�#�#�#�
�����a����	�����A����1������MrTc�$�eZdZdZd�Zd�Zd�ZdS)r��c��||_dSrV)�parent)r�r(s  rSr�zBaseHandler.add_parent`s
������rTc��dSrVr�r�s rSr�zBaseHandler.closecr�rTc�F�t|d��sdS|j|jkS)N�
handler_orderT)r�r+)r��others  rS�__lt__zBaseHandler.__lt__gs,���u�o�.�.�	��4��!�E�$7�7�7rTN)r�r�r�r+r�r�r-r�rTrSrr]sF�������M����
�
�
�8�8�8�8�8rTrc� �eZdZdZdZd�ZeZdS)r0zProcess HTTP error responses.i�c��|j|j|���}}}d|cxkrdks!n|j�d|||||��}|S)N���,r)�code�msgrcr(r�)r�r�r�r2r3r�s      rS�
http_responsez HTTPErrorProcessor.http_responsetsg��"�-���x�}�}���4�c���t�!�!�!�!�c�!�!�!�!��{�(�(����4��d�<�<�H��rTN)r�r�r��__doc__r+r4�https_responser�rTrSr0r0ps/������'�'��M�	�	�	�#�N�N�NrTr0c��eZdZd�ZdS)rc�2�t|j||||���rV)rr�)r�rrsr2r3r�s      rSrz*HTTPDefaultErrorHandler.http_error_default�s�����d�C��r�:�:�:rTN)r�r�r�rr�rTrSrr�s#������;�;�;�;�;rTrc�6�eZdZdZdZd�Zd�ZexZxZxZ	Z
dZdS)r��
c�*�	�|���}|dvr|dvs"|dvr|dkst|j||||���|�dd��}d�	�	fd�|j���D��}t
|||jd	�
��S)a�Return a Request or None in response to a redirect.

        This is called by the http_error_30x methods when a
        redirection response is received.  If a redirection should
        take place, return a new Request to allow http_error_30x to
        perform the redirect.  Otherwise, raise HTTPError if no-one
        else should try to handle this url.  Return None if you can't
        but another Handler might.
        )�-�.�/i3i4)r��HEAD)r=r>r?r�� z%20)r]zcontent-typec�H��i|]\}}|����v�||��Sr�)r�)�.0�k�v�CONTENT_HEADERSs   �rS�
<dictcomp>z8HTTPRedirectHandler.redirect_request.<locals>.<dictcomp>�s;���;�;�;�t�q�!������/�9�9���9�9�9rTT)rtr�r�)r�rr��replacertr�rr�)
r�rrsr2r3rt�newurl�m�
newheadersrFs
         @rSr�z$HTTPRedirectHandler.redirect_request�s����
�N�N�����2�2�2�q�O�7K�7K���&�&�1��;�;��C�L�$��W�b�A�A�A�����U�+�+��<��;�;�;�;�s�{�'8�'8�':�':�;�;�;�
��v�)�'*�':�$(�*�*�*�	*rTc�r�d|vr	|d}nd|vr	|d}ndSt|��}|jdvrt|||�d|�d�||���|js|jrt|��}d|d<t
|��}t|dtj	�	��}t|j|��}|�||||||��}|�dSt|d
��rf|jx}	|_|	�|d��|jkst#|	��|jkr t|j||j|z||���nix}	x|_|_|	�|d��dz|	|<|���|���|j�||j�
��S)N�location�uri�rr��ftpr�z - Redirection to url 'z' is not allowed�/r;z
iso-8859-1)�encoding�safe�
redirect_dictrr_�rP)r�schemerre�netlocr�rr
�string�punctuationrr�r�r�rTr��max_repeatsrn�max_redirections�inf_msgrmr�r(rMrP)
r�rrsr2r3rtrI�urlparts�new�visiteds
          rS�http_error_302z"HTTPRedirectHandler.http_error_302�s���� � ��Z�(�F�F�
�g�
�
��U�^�F�F��F��F�#�#��
�?�">�>�>����AD���f�f�f�M�����
�
�}�	���	��H�~�~�H��H�Q�K��H�%�%��
��\��0B�D�D�D�����v�.�.��
�#�#�C��T�3���H�H���;��F��3��(�(�	A�*-�*;�;�G�c�'����F�A�&�&�$�*:�:�:��G���� 5�5�5����d� $��s� 2�G�R�A�A�A�6�?A�@�G�@�c�'�#�*;�!�+�+�f�a�0�0�1�4����	���	�	�	�
���
�
�
��{����S�[��9�9�9rTzoThe HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
N)r�r�r�rZr[r�r`�http_error_301�http_error_303�http_error_307�http_error_308r\r�rTrSrr�s\�������K��� *� *� *�L::�::�::�xIW�V�N�V�^�V�n�~�2�G�G�GrTrc��t|��\}}|�d��sd}|}n|�d��std|z���d|vr,|�d��}|�d|��}n|�dd��}|dkrd}|d|�}t	|��\}}|�t|��\}}	ndx}}	|||	|fS)aReturn (scheme, user, password, host/port) given a URL or an authority.

    If a URL is supplied, it must have an authority (host:port) component.
    According to RFC 3986, having an authority component means the URL must
    have two slashes after the scheme.
    rQN�//zproxy URL with no authority: %r�@r;r\)rr�rDr�rr)
�proxyrV�r_scheme�	authority�host_separator�end�userinfo�hostport�user�passwords
          rS�_parse_proxyrq�s��"�%�(�(��F�H����s�#�#�$����	�	��"�"�4�(�(�	H��>��F�G�G�G��(�?�?�%�]�]�3�/�/�N��-�-��^�4�4�C�C��-�-��Q�'�'�C��"�9�9��C��Q�s�U�O�	�#�I�.�.��H�h���%�h�/�/���h�h����x��4��8�+�+rTc� �eZdZdZdd�Zd�ZdS)r �dNc���|�t��}||_|���D]7\}}|���}t	|d|z|||jfd����8dS)Nz%s_openc��||||��SrVr�)�rrhr�r�s    rS�<lambda>z'ProxyHandler.__init__.<locals>.<lambda>#s����Q��t�,�,�rT)r6�proxiesr�r��setattrr�)r�rxr�rNs    rSr�zProxyHandler.__init__s����?� �l�l�G���� �����	.�	.�I�D�#��:�:�<�<�D��D�)�d�*�$'�d���-�-�-�
.�
.�
.�
.�	.�	.rTc��|j}t|��\}}}}|�|}|jrt|j��rdS|ru|rst	|���dt	|����}	tj|	������d��}
|�	dd|
z��t	|��}|�
||��||ks|dkrdS|j�||j
���S)N�:�ascii�Proxy-authorization�Basic r�rU)r�rqr��proxy_bypassr�base64�	b64encode�encode�decoder�r�r(rMrP)r�rrhr��	orig_type�
proxy_typerorprn�	user_pass�credss           rSr�zProxyHandler.proxy_open&s���H�	�/;�E�/B�/B�,�
�D�(�H���"�J��8�	��S�X�.�.�	��4��	D�H�	D�#*�4�=�=�=�=�#*�8�#4�#4�#4�6�I��$�Y�%5�%5�%7�%7�8�8�?�?��H�H�E��N�N�0�(�U�2B�C�C�C��8�$�$���
�
�h�
�+�+�+��
�"�"�i�7�&:�&:��4��;�#�#�C���#�=�=�=rTrV)r�r�r�r+r�r�r�rTrSr r s<�������M�	.�	.�	.�	.�>�>�>�>�>rTr c�.�eZdZd�Zd�Zd�Zdd�Zd�ZdS)	r!c��i|_dSrV)�passwdr�s rSr�zHTTPPasswordMgr.__init__Ds
������rTc�����t|t��r|g}|�jvr
i�j|<dD]0�t��fd�|D����}||f�j||<�1dS)N�TFc3�D�K�|]}��|���V��dSrV)�
reduce_uri)rC�u�default_portr�s  ��rS�	<genexpr>z/HTTPPasswordMgr.add_password.<locals>.<genexpr>NsB����� ?� ?�56�����<�0�0� ?� ?� ?� ?� ?� ?rT)rrr��tuple)r��realmrNror��reduced_urir�s`     @rS�add_passwordzHTTPPasswordMgr.add_passwordGs������c�3���	��%�C����#�#�!#�D�K���'�	=�	=�L�� ?� ?� ?� ?� ?�:=� ?� ?� ?�?�?�K�/3�V�n�D�K���{�+�+�	=�	=rTc���|j�|i��}dD]U}|�||��}|���D](\}}|D] }|�||��r|cccS�!�)�VdS)Nr��NN)r�r�r�r��	is_suburi)	r�r��authuri�domainsr��reduced_authuri�uris�authinforNs	         rS�find_user_passwordz"HTTPPasswordMgr.find_user_passwordRs����+�/�/�%��,�,��'�	(�	(�L�"�o�o�g�|�D�D�O�")�-�-�/�/�
(�
(���h��(�(�C��~�~�c�?�;�;�(�'��������(�(�
(��zrTTc���t|��}|dr|d}|d}|dpd}nd}|}d}t|��\}}|r%|�#|�!ddd��|��}	|	�d	||	fz}||fS)
z@Accept authority or URI and extract only the authority and path.r_rr;rQN�Pi�rz%s:%d)rrr�)
r�rNr��partsrVrjrer��port�dports
          rSr�zHTTPPasswordMgr.reduce_uri\s�����
�
����8�		��1�X�F��a��I���8�?�s�D�D��F��I��D��	�*�*�
��d��	4�D�L�V�-?��!����s�6�{�{�
�� �#�t�U�m�3�	��$��rTc��||krdS|d|dkrdS|d}|dd�dkr|dz
}|d�|��S)zcCheck if test is below base in a URI tree

        Both args must be URIs in reduced form.
        TrFr_r\NrQ)r�)r��base�test�prefixs    rSr�zHTTPPasswordMgr.is_suburissg��
�4�<�<��4���7�d�1�g����5��a����"�#�#�;�#����c�M�F��A�w�!�!�&�)�)�)rTN)T)r�r�r�r�r�r�r�r�r�rTrSr!r!Bsd���������	=�	=�	=��������.*�*�*�*�*rTr!c��eZdZd�ZdS)r"c��t�|||��\}}|�||fSt�|d|��SrV)r!r�)r�r�r�rorps     rSr�z2HTTPPasswordMgrWithDefaultRealm.find_user_password�sL��(�;�;�D�%�<C�E�E���h�����>�!��1�1�$��g�F�F�FrTN)r�r�r�r�r�rTrSr"r"�s(������G�G�G�G�GrTr"c�8��eZdZ�fd�Zd�fd�	Zdd�Zd�Z�xZS)r#c�H��i|_t��j|i|��dSrV)�
authenticated�superr�)r�r��kwargs�	__class__s   �rSr�z%HTTPPasswordMgrWithPriorAuth.__init__�s-�����������$�)�&�)�)�)�)�)rTFc����|�||��|�$t���d|||��t���||||��dSrV)�update_authenticatedr�r�)r�r�rNror��is_authenticatedr�s      �rSr�z)HTTPPasswordMgrWithPriorAuth.add_password�sb����!�!�#�'7�8�8�8����G�G� � ��s�D�&�9�9�9�
�����U�C��v�6�6�6�6�6rTc��t|t��r|g}dD]'}|D]"}|�||��}||j|<�#�(dS�Nr�)rrr�r�)r�rNr�r�r�r�s      rSr�z1HTTPPasswordMgrWithPriorAuth.update_authenticated�sr���c�3���	��%�C�'�	C�	C�L��
C�
C��"�o�o�a��>�>��2B��"�;�/�/�
C�	C�	CrTc��dD]I}|�||��}|jD])}|�||��r|j|ccS�*�JdSr�)r�r�r�)r�r�r�r�rNs     rSr�z-HTTPPasswordMgrWithPriorAuth.is_authenticated�sz��'�	3�	3�L�"�o�o�g�|�D�D�O��)�
3�
3���>�>�#��7�7�3��-�c�2�2�2�2�2�2�3�
3�	3�	3rT)F)r�r�r�r�r�r�r��
__classcell__)r�s@rSr#r#�s}�������*�*�*�*�*�7�7�7�7�7�7�C�C�C�C�3�3�3�3�3�3�3rTr#c�h�eZdZejdej��Zd	d�Zd�Zd�Z	d�Z
d�Zd�ZeZ
eZdS)
r$z1(?:^|,)[ 	]*([^ 	,]+)[ 	]+realm=(["']?)([^"']*)\2Nc�V�|�t��}||_|jj|_dSrV)r!r�r�)r��password_mgrs  rSr�z!AbstractBasicAuthHandler.__init__�s-����*�,�,�L�"��� �K�4����rTc#�"K�d}tj�|��D]A}|���\}}}|dvrt	jdtd��||fV�d}�B|s'|r|���d}nd}|dfV�dSdS)NF)�"�'zBasic Auth Realm was unquoted�Trr�)r$�rx�finditer�groupsrArB�UserWarning�split)r��header�found_challenge�morVr
r�s       rS�_parse_realmz%AbstractBasicAuthHandler._parse_realm�s�������*�-�6�6�v�>�>�	#�	#�B�#%�9�9�;�;� �F�E�5��J�&�&��
�=�)�1�.�.�.��5�/�!�!�!�"�O�O��	!��
�������*������4�.� � � � � �	!�	!rTc��|�|��}|sdSd}|D]U}|�|��D]=\}}|���dkr|}� |�|�|||��ccS�>�V|�t	d|�����dS)N�basicz@AbstractBasicAuthHandler does not support the following scheme: )�get_allr�r��retry_http_basic_authrD)	r��authreqr�rrt�unsupportedr�rVr�s	         rS�http_error_auth_reqedz.AbstractBasicAuthHandler.http_error_auth_reqed�s����/�/�'�*�*���	��F����
	H�
	H�F�!%�!2�!2�6�!:�!:�	
H�	
H�
����<�<�>�>�W�,�,�"(�K���$� �5�5�d�C��G�G�G�G�G�G�G�	%�	
H��"��*� &��)�*�*�
*�#�"rTc��|j�||��\}}|��|�d|��}dtj|������d��z}|�|jd��|krdS|�|j|��|j	�
||j���SdS)Nr{r~r|rU)r�r�r�r�r�r�r��auth_headerr�r(rMrP)r�r�rr�ro�pw�raw�auths        rSr�z.AbstractBasicAuthHandler.retry_http_basic_auth�s����;�1�1�%��>�>���b�
�>�!�T�T�2�2�&�C��f�.�s�z�z�|�|�<�<�C�C�G�L�L�L�D��~�~�d�.��5�5��=�=��t��'�'��(8�$�?�?�?��;�#�#�C���#�=�=�=��4rTc���t|jd��r|j�|j��s|S|�d��s�|j�d|j��\}}d�||�����}tj	|���
��}|�dd�|�������|S)Nr��
Authorizationz{0}:{1}zBasic {})
r�r�r�r�r�r�r�r�r��standard_b64encoder�r��strip)r�rror��credentials�auth_strs      rS�http_requestz%AbstractBasicAuthHandler.http_requests������%7�8�8�	��{�+�+�C�L�9�9�	��J��~�~�o�.�.�	M��;�9�9�$���M�M�L�D�&�#�*�*�4��8�8�?�?�A�A�K��0��=�=�D�D�F�F�H��'�'��(2�(9�(9�(�.�.�:J�:J�(K�(K�
M�
M�
M��
rTc���t|jd��rVd|jcxkrdkr$nn!|j�|jd��n |j�|jd��|S)Nr�r0r1TF)r�r�r2r�r�)r�rr�s   rSr4z&AbstractBasicAuthHandler.http_response
sx���4�;� 2�3�3�	F��h�m�)�)�)�)�c�)�)�)�)�)���0�0���t�D�D�D�D���0�0���u�E�E�E��rTrV)r�r�r��re�compile�Ir�r�r�r�r�r�r4�
https_requestr6r�rTrSr$r$�s�������
���1��D�
�
�B�5�5�5�5�!�!�!�(*�*�*�4
�
�
�������!�M�"�N�N�NrTr$c��eZdZdZd�ZdS)r%r�c�D�|j}|�d|||��}|S)N�www-authenticate)r�r�)r�rrsr2r3rtrNr�s        rS�http_error_401z#HTTPBasicAuthHandler.http_error_401s-���l���-�-�.@�*-�s�G�=�=���rTN)r�r�r�r�r�r�rTrSr%r%s(������!�K�����rTr%c��eZdZdZd�ZdS)r&r}c�D�|j}|�d|||��}|S�N�proxy-authenticate)r�r�)r�rrsr2r3rtrjr�s        rS�http_error_407z$ProxyBasicAuthHandler.http_error_407)s1��
�H�	��-�-�.B�*3�S�'�C�C���rTN)r�r�r�r�r�r�rTrSr&r&%s(������'�K�����rTr&c�@�eZdZd
d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
dS)r'Nc��|�t��}||_|jj|_d|_d|_d|_dS�Nr)r!r�r��retried�nonce_count�
last_nonce)r�r�s  rSr�z"AbstractDigestAuthHandler.__init__Cs@���>�$�&�&�F���� �K�4�������������rTc��d|_dSr�)r�r�s rS�reset_retry_countz+AbstractDigestAuthHandler.reset_retry_countLs
������rTc��|�|d��}|jdkrt|jdd|d���|xjdz
c_|rr|���d}|���dkr|�||��S|���dkrtd|z���dSdS)	N�i�zdigest auth failedr_r�digestr�zEAbstractDigestAuthHandler does not support the following scheme: '%s')r�r�rr�r�r��retry_http_digest_authrD)r�r�r�rrtr�rVs       rSr�z/AbstractDigestAuthHandler.http_error_auth_reqedOs����+�+�k�4�0�0���<�!����C�L�#�/C�#�T�+�+�
+�
�L�L�A��L�L��	I��]�]�_�_�Q�'�F��|�|�~�~��)�)��2�2�3��@�@�@������7�*�*� �"?�AG�"H�I�I�I�	I�	I�+�*rTc��|�dd��\}}ttdt|������}|�||��}|rid|z}|j�|jd��|krdS|�|j|��|j	�
||j���}|SdS)NrAr_z	Digest %srU)r��parse_keqv_list�filter�parse_http_list�get_authorizationrtr�r�r�r(rMrP)r�rr��token�	challenge�chal�auth_val�resps        rSr�z0AbstractDigestAuthHandler.retry_http_digest_authcs����:�:�c�1�-�-���y��v�d�O�I�,F�,F�G�G�H�H���%�%�c�4�0�0���	�"�T�)�H��{���t�/��6�6�(�B�B��t��'�'��(8�(�C�C�C��;�#�#�C���#�=�=�D��K�
	�	rTc���|j�d|�dtj���d�}|�d��t	d��z}tj|�����}|dd�S)Nr{r|��)r��time�ctimer��_randombytes�hashlib�sha1�	hexdigest)r��nonce�s�b�digs     rS�
get_cnoncez$AbstractDigestAuthHandler.get_cnonceosi�� �+�+�+�U�U�U�D�J�L�L�L�L�A��
�H�H�W����Q���/���l�1�o�o�'�'�)�)���3�B�3�x�rTc��	|d}|d}|�d��}|�dd��}|�dd��}n#t$rYdSwxYw|�|��\}}	|�dS|j�||j��\}
}|
�dS|j�|�|j|��}nd}|
�d|�d|��}
|����d|j	��}|�$|	||
��|�d||������}n�d|�
d	��vrx||jkr|xjd
z
c_nd
|_||_d|jz}|�
|��}|�d|�d|�dd�d||����	}|	||
��|��}ntd|z���d
|
�d|�d|�d|j	�d|�d�}|r|d|zz
}|r|d|zz
}|d|zz
}|r|d|�d|�d�z
}|S)Nr�r�qop�	algorithm�MD5�opaquer{r��,r_z%08xzqop '%s' is not supported.z
username="z
", realm="z
", nonce="z", uri="z
", response="r�z
, opaque="%s"z
, digest="%s"z, algorithm="%s"z, qop=auth, nc=z
, cnonce=")r��KeyError�get_algorithm_implsr�r�r�rO�get_entity_digestr�r�r�r�r�rr)r�rr�r�rr
rr�H�KDror��entdig�A1�A2�respdig�ncvalue�cnonce�noncebitr�s                    rSr�z+AbstractDigestAuthHandler.get_authorizationzs���		���M�E���M�E��(�(�5�/�/�C�����e�4�4�I��X�X�h��-�-�F�F���	�	�	��4�4�	�����(�(��3�3���2��9��4��;�1�1�%���F�F���b��<��4��8���+�+�C�H�d�;�;�F�F��F��4�4������
+�����(�(�(�(����&��
�;��b���2���5�5�5�!�!�B�%�%�%� 8�9�9�G�G�
�s�y�y��~�~�
%�
%����'�'�� � �A�%� � � �#$�� �"'����t�/�/�G��_�_�U�+�+�F�+0�5�5�'�'�'�6�6�6�6�6�6�1�1�R�5�5�5�Q�H��b���2����)�)�G�G��7�#�=�>�>�>��
#'�$�$����u�u�u�c�l�l�l�")�'�'�+���	-��O�f�,�,�D��	-��O�f�,�,�D��"�Y�.�.���	I��D�������H�H�D��s�AA�
A"�!A"c�b��|dkrd��n|dkrd��ntd|z����fd�}�|fS)Nrc�t�tj|�d�������S�Nr|)r�md5r�r��xs rSrwz?AbstractDigestAuthHandler.get_algorithm_impls.<locals>.<lambda>�s(��'�+�a�h�h�w�&7�&7�8�8�B�B�D�D�rT�SHAc�t�tj|�d�������Sr )rrr�rr"s rSrwz?AbstractDigestAuthHandler.get_algorithm_impls.<locals>.<lambda>�s(��'�,�q�x�x��'8�'8�9�9�C�C�E�E�rTz.Unsupported digest authentication algorithm %rc�$���|�d|����S)Nr{r�)r�drs  �rSrwz?AbstractDigestAuthHandler.get_algorithm_impls.<locals>.<lambda>�s���!�!�q�q�q�!�!�,�-�-�rT)rD)r�rrrs   @rSrz-AbstractDigestAuthHandler.get_algorithm_impls�se�������D�D�A�A�
�%�
�
�E�E�A�A��,�.7�8�9�9�
9�
-�
-�
-�
-���"�u�rTc��dSrVr�)r�rOr�s   rSrz+AbstractDigestAuthHandler.get_entity_digest�s���trTrV)r�r�r�r�r�r�r�rr�rrr�rTrSr'r'8s��������������I�I�I�(
�
�
�	�	�	�<�<�<�|�������rTr'c� �eZdZdZdZdZd�ZdS)r(z�An authentication protocol defined by RFC 2069

    Digest authentication improves on basic authentication because it
    does not transmit passwords in the clear.
    r���c��t|j��d}|�d|||��}|���|S)Nr_r�)rr�r�r��r�rrsr2r3rtr��retrys        rSr�z$HTTPDigestAuthHandler.http_error_401�sL�����%�%�a�(���*�*�+=�+/��g�?�?����� � � ��rTN)r�r�r�r5r�r+r�r�rTrSr(r(�s9��������"�K��M�����rTr(c��eZdZdZdZd�ZdS)r)�Proxy-Authorizationr*c�l�|j}|�d|||��}|���|Sr�)r�r�r�r,s        rSr�z%ProxyDigestAuthHandler.http_error_407�s?���x���*�*�+?�+/��g�?�?����� � � ��rTN)r�r�r�r�r+r�r�rTrSr)r)�s-������'�K��M�����rTr)c�.�eZdZdd�Zd�Zd�Zd�Zd�ZdS)	�AbstractHTTPHandlerrc��||_dSrV��_debuglevel)r��
debuglevels  rSr�zAbstractHTTPHandler.__init__�s��%����rTc��||_dSrVr4)r��levels  rS�set_http_debuglevelz'AbstractHTTPHandler.set_http_debuglevel�s�� ����rTc�z�tjj�|j|�����SrV)rr�HTTPConnection�_get_content_lengthrOr��r�r�s  rSr<z'AbstractHTTPHandler._get_content_length�s3���{�)�=�=��L���� � �"�"�	"rTc�`�|j}|std���|j��|j}t|t��rd}t|���|�d��s|�dd��|�d��sf|�d��sQ|�|��}|�$|�dt	|����n|�dd��|}|�	��r)t|j��\}}t|��\}}	|�d��s|�d|��|j
jD]D\}
}|
���}
|�|
��s|�|
|���E|S)	N�
no host givenz\POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.zContent-type�!application/x-www-form-urlencodedr��Transfer-encoding�chunkedr�)r�rrOrrr�r�r�r<r�rr�r
r(r�r�)r�r�r�rOr3�content_length�sel_hostrV�sel�sel_pathrir�s            rS�do_request_zAbstractHTTPHandler.do_request_�s����|���	,��?�+�+�+��<�#��<�D��$��$�$�
%�D����n�n�$��%�%�n�5�5�
9��/�/�"�7�9�9�9��&�&�'7�8�8�
<�#�.�.�/B�C�C�
<�!%�!9�!9�'�!B�!B��!�-��3�3�,�c�.�.A�.A�C�C�C�C��3�3�/��<�<�<��������	1�$�W�%5�6�6�K�F�C�!+�C����H�h��!�!�&�)�)�	>��+�+�F�H�=�=�=��;�1�	=�	=�K�D�%��?�?�$�$�D��%�%�d�+�+�
=��/�/��e�<�<�<���rTc	��
�|j}|std���||fd|ji|��}|�|j��t|j���
�
��
fd�|j�	��D����d�
d<d��
�	��D���
|j
r2i}d}|�
vr�
|||<�
|=|�|j
|���		|�|�
��|j|j�
|�d	���
��n!#t"$r}t|���d}~wwxYw|���}	n#|����xYw|jr |j���d|_|���|	_|	j|	_|	S)z�Return an HTTPResponse object for the request, using http_class.

        http_class must implement the HTTPConnection API from http.client.
        r?rPc�$��i|]\}}|�v�	||��
Sr�r�)rCrDrErts   �rSrGz/AbstractHTTPHandler.do_open.<locals>.<dictcomp>)s3���-�-�-���A��G�+�+��1�+�+�+rTr��
Connectionc�>�i|]\}}|���|��Sr�)�title)rCrir�s   rSrGz/AbstractHTTPHandler.do_open.<locals>.<dictcomp>6s&��F�F�F���s�4�:�:�<�<��F�F�FrTr/�rtrA)�encode_chunkedN)r�rrP�set_debuglevelr5rr��updatertr�r��
set_tunnelr�r�r�rOr�r}�getresponser��sockr�rN�reasonr3)r��
http_classr�http_conn_argsr�r$�tunnel_headers�proxy_auth_hdr�errrvrts          @rSr�zAbstractHTTPHandler.do_opens���
�x���	,��?�+�+�+�
�J�t�C�C�S�[�C�N�C�C��	����)�*�*�*��s�,�-�-�����-�-�-�-���):�):�)<�)<�-�-�-�	.�	.�	.�!(����F�F�g�m�m�o�o�F�F�F����	C��N�2�N���(�(�18��1H��~�.��N�+�
�L�L��)�>�L�B�B�B�		�
$��	�	�#�.�.�*�*�C�L�#�(�G�),���8K�)L�)L��N�N�N�N���
$�
$�
$��s�m�m�#�����
$�����
�
���A�A��	�
�G�G�I�I�I�����

�6�	�
�F�L�L�N�N�N��A�F�� � �"�"��������s+�.A	D8�7E.�8
E�E�E�E.�.FN�r)r�r�r�r�r9r<rGr�r�rTrSr2r2�sj������&�&�&�&�!�!�!�"�"�"�
$�$�$�L@�@�@�@�@rTr2c�"�eZdZd�ZejZdS)r*c�L�|�tjj|��SrV)r�rrr;�r�rs  rS�	http_openzHTTPHandler.http_open`s���|�|�D�K�6��<�<�<rTN)r�r�r�r^r2rGr�r�rTrSr*r*^s'������=�=�=�'�2�L�L�LrTr*rc�*�eZdZdd�Zd�ZejZdS)rKrNc�X�t�||��||_||_dSrV)r2r��_context�_check_hostname)r�r6r?�check_hostnames    rSr�zHTTPSHandler.__init__is-���(�(��z�:�:�:�#�D�M�#1�D� � � rTc�f�|�tjj||j|j���S)N)r?rc)r�rrrrarbr]s  rS�
https_openzHTTPSHandler.https_openns3���<�<��� ;�S��
�d�6J� �L�L�
LrT)rNN)r�r�r�r�rer2rGr�r�rTrSrKrKgs>������	2�	2�	2�	2�
	L�	L�	L�,�7�
�
�
rTrKc�*�eZdZdd�Zd�Zd�ZeZeZdS)rNc�R�ddl}|�|j���}||_dSr�)�http.cookiejar�	cookiejar�	CookieJar)r�rirs   rSr�zHTTPCookieProcessor.__init__ws2����������0�0�2�2�I�"����rTc�:�|j�|��|SrV)ri�add_cookie_headerr=s  rSr�z HTTPCookieProcessor.http_request}s����(�(��1�1�1��rTc�<�|j�||��|SrV)ri�extract_cookies)r�r�r�s   rSr4z!HTTPCookieProcessor.http_response�s����&�&�x��9�9�9��rTrV)r�r�r�r�r�r4r�r6r�rTrSrrvsL������#�#�#�#�������!�M�"�N�N�NrTrc��eZdZd�ZdS)r/c�4�|j}td|z���)Nzunknown url type: %s)r�r)r�rr�s   rSr
zUnknownHandler.unknown_open�s���x���-��4�5�5�5rTN)r�r�r�r
r�rTrSr/r/�s#������6�6�6�6�6rTr/c��i}|D]B}|�dd��\}}|ddkr|ddkr
|dd�}|||<�C|S)z>Parse list of key=value strings where keys are not duplicated.�=r_rr�r\)r�)�l�parsed�eltrDrEs     rSr�r��sc��
�F������y�y��a� � ���1��Q�4�3�;�;�1�R�5�C�<�<��!�B�$��A���q�	�	��MrTc��g}d}dx}}|D]P}|r||z
}d}�|r|dkrd}�|dkrd}||z
}�%|dkr|�|��d}�C|dkrd}||z
}�Q|r|�|��d�|D��S)apParse lists as described by RFC 2068 Section 2.

    In particular, parse comma-separated lists where the elements of
    the list may include quoted-strings.  A quoted-string could
    contain a comma.  A non-quoted string could have quotes in the
    middle.  Neither commas nor quotes count if they are escaped.
    Only double-quotes count, not single-quotes.
    r�F�\Tr�rc�6�g|]}|�����Sr�)r�)rC�parts  rS�
<listcomp>z#parse_http_list.<locals>.<listcomp>�s ��)�)�)�T�D�J�J�L�L�)�)�)rT)rk)r�resry�escaper
�curs      rSr�r��s���
�C�
�D���F�U������	��C�K�D��F���	��d�{�{�����������C�K�D���#�:�:��J�J�t�����D���#�:�:��E���������
�
�4����)�)�S�)�)�)�)rTc�$�eZdZd�ZdZd�Zd�ZdS)r+c���|j}|dd�dkrL|dd�dkr>|jr7|jdkr,|j|���vrtd���dS|�|��S)Nr;rfr�rQ�	localhost�-file:// scheme is supported only on localhost)r�r��	get_namesr�open_local_file)r�rrNs   rS�	file_openzFileHandler.file_open�s����l���r��r�7�d�?�?�s�1�Q�3�x�3���C�H����K�'�'��8�t�~�~�/�/�/�/��N�O�O�O�0�/��'�'��,�,�,rTNc�X�tj��	ttjd��dtjtj����dz��t_n4#tj$r"tjd��ft_YnwxYwtjS)Nr�r;)r+�namesr�r�gethostbyname_ex�gethostname�gaierror�
gethostbynamer�s rSr�zFileHandler.get_names�s�����$�
I�$)��+�K�8�8��;��+�F�,>�,@�,@�A�A�!�D�E�%F�%F��!�!���?�
I�
I�
I�%+�%9�+�%F�%F�$H��!�!�!�
I����� � s�AA,�,.B�Bc�b�ddl}ddl}|j}|j}t	|��}	tj|��}|j}|j�	|j
d���}	|�|��d}
|jd|
pd||	fz��}|rt|��\}}|r%|sRt|��|���vr/|r	d|z|z}
nd|z}
t!t#|d��||
��Sn!#t$$r}t'|���d}~wwxYwt'd���)	NrT��usegmtz6Content-type: %s
Content-length: %d
Last-modified: %s
�
text/plain�file://�rbzfile not on local host)�email.utils�	mimetypesr�r�r5rd�stat�st_size�utils�
formatdate�st_mtime�
guess_type�message_from_stringr�_safe_gethostbynamer�rrMr}r)r�r�emailr�r�rp�	localfile�statsrx�modified�mtypertr��origurl�exps               rSr�zFileHandler.open_local_file�ss�����������x���<�� ��*�*�	�	 ��G�I�&�&�E��=�D��{�-�-�e�n�T�-�J�J�H��(�(��2�2�1�5�E�/�e�/�K��&�,��h�7�8�9�9�G��
.�'��-�-�
��d��
K��
K�1�$�7�7�4�>�>�;K�;K�K�K��3�'�$�.��9�G�G�'�(�2�G�!�$�y�$�"7�"7��'�J�J�J����	 �	 �	 ��3�-�-������	 �����/�0�0�0s�CD�
D�D�D)r�r�r�r�r�r�r�r�rTrSr+r+�sH������-�-�-�
�E�!�!�!�1�1�1�1�1rTr+c�X�	tj|��S#tj$rYdSwxYwrV)rr�r�)r�s rSr�r��s<����#�D�)�)�)���?�����t�t����s��)�)c��eZdZd�Zd�ZdS)r,c��ddl}ddl}|j}|std���t	|��\}}|�|j}nt
|��}t|��\}}|rt|��\}}nd}t|��}|pd}|pd}	tj|��}n!#t$r}t|���d}~wwxYwt|j��\}	}
|	�d��}t!t#t|����}|dd�|d}}|r|ds
|dd�}	|�||||||j��}
|rdpd}|
D]D}t)|��\}}|���d	kr|d
vr|���}�E|
�||��\}}d}|�|j��d}|r|d|zz
}|�|dkr|d|zz
}t5j|��}t9|||j��S#|j$r}t|��|�d}~wwxYw)
Nr�ftp error: no host givenr�rQr\r_r��Dr���a�Ar�r�r'r�zContent-type: %s
zContent-length: %d
)�ftplibr�r�rr�FTP_PORTrlrrrrr�r}rr�r�r��map�connect_ftprPrr��upper�retrfiler�r�r�r�r�
all_errors)r�rr�r�r�r�ror�r3re�attrs�dirsrX�fwr��attrr�rs�retrlenrtr�r�s                      rS�ftp_openzFTPHandler.ftp_open�s����
�
�
������x���	7��5�6�6�6���%�%�
��d��<��?�D�D��t�9�9�D� ��%�%�
��d��	�'��-�-�L�D�&�&��F��t�}�}���z�r����2��	 ��'��-�-�D�D���	 �	 �	 ��3�-�-������	 ���� ���.�.���e��z�z�#�����C���&�&�'�'���#�2�#�Y��R��d���	��Q��	�����8�D�	)��!�!�$���d�D�#�+�N�N�B��<�C�&�3�D��
)�
)��)�$�/�/���e��:�:�<�<�6�)�)��:�:�:� �;�;�=�=�D���+�+�d�D�1�1�K�B���G��(�(���6�6�q�9�E��
8��/�%�7�7���"�w�!�|�|��1�G�;�;���/��8�8�G��b�'�3�<�8�8�8��� �	)�	)�	)��3�-�-�S�(�����	)���s1�
B"�"
C�,B;�;C�8C*H#�#
I�-H=�=Ic	�.�t||||||d���S)NF)�
persistent)�
ftpwrapper)r�ror�r�r�r�rPs       rSr�zFTPHandler.connect_ftp0s(���$���d�D�'�%*�,�,�,�	,rTN)r�r�r�r�r�r�rTrSr,r,�s3������2)�2)�2)�h,�,�,�,�,rTr,c�2�eZdZd�Zd�Zd�Zd�Zd�Zd�ZdS)r-c�L�i|_i|_d|_d|_d|_dS)Nr�<r)�cacherP�soonest�delay�	max_connsr�s rSr�zCacheFTPHandler.__init__7s)����
���������
�����rTc��||_dSrV)r�)r��ts  rS�
setTimeoutzCacheFTPHandler.setTimeout>s
����
�
�
rTc��||_dSrV)r�)r�rJs  rS�setMaxConnszCacheFTPHandler.setMaxConnsAs
������rTc�P�|||d�|��|f}||jvr$tj��|jz|j|<n?t||||||��|j|<tj��|jz|j|<|���|j|S)NrQ)�joinr�rr�rPr��check_cache)r�ror�r�r�r�rPr�s        rSr�zCacheFTPHandler.connect_ftpDs����D�$��������7���$�*��� $�	���d�j� 8�D�L����(��v�t�T�)-�w�8�8�D�J�s�O� $�	���d�j� 8�D�L����������z�#��rTc��tj��}|j|krat|j�����D]:\}}||kr/|j|���|j|=|j|=�;tt|j�������|_t|j��|j
kr�t|j�����D]"\}}||jkr|j|=|j|=n�#tt|j�������|_dSdSrV)rr�r�rPr�r�r��min�valuesrnr�)r�r�rDrEs    rSr�zCacheFTPHandler.check_cacheOs8���I�K�K���<�1����T�\�/�/�1�1�2�2�
(�
(���1��q�5�5��J�q�M�'�'�)�)�)��
�1�
���Q����4��� 3� 3� 5� 5�6�6�7�7����t�z�?�?�d�n�,�,��T�\�/�/�1�1�2�2�
�
���1����$�$��
�1�
���Q���E�%��t�D�L�$7�$7�$9�$9�:�:�;�;�D�L�L�L�
-�,rTc���|j���D]}|����|j���|j���dSrV)r�r�r��clearrP)r��conns  rS�clear_cachezCacheFTPHandler.clear_cachecs\���J�%�%�'�'�	�	�D��J�J�L�L�L�L��
��������������rTN)	r�r�r�r�r�r�r�r�r�r�rTrSr-r-4sn���������������	�	�	�<�<�<�(����rTr-c��eZdZd�ZdS)r.c��|j}|�dd��\}}|�dd��\}}t|��}|�d��rt	j|��}|dd�}|sd}t
jd|t|��fz��}ttj|��||��S)Nr{r_rz;base64i�����text/plain;charset=US-ASCIIz$Content-type: %s
Content-length: %d
)r�r�r�endswithr��decodebytesr�r�rnr�io�BytesIO)r�rrNrVrO�	mediatyperts       rS�	data_openzDataHandler.data_openjs����l���y�y��Q�'�'�����*�*�S��+�+��	�4� ��%�%�����i�(�(�	'��%�d�+�+�D�!�#�2�#��I��	6�5�I��+�,T�
��D�	�	�"�-#�$�$���"�*�T�*�*�G�S�9�9�9rTN)r�r�r�r�r�rTrSr.r.is#������:�:�:�:�:rTr.r;�nt)r5r4c� �t|��S)zOS-specific conversion from a relative URL of the 'file' scheme
        to a file system path; not recommended for general use.)r��pathnames rSr5r5�s���x� � � rTc� �t|��S)zOS-specific conversion from a file system path to a relative URL
        of the 'file' scheme; not recommended for general use.)r
r�s rSr4r4�s���X���rTc��eZdZdZdZdezZdd�Zd�Zd�Z	d�Z
d�Zdd	�Zdd
�Z
dd�Zdd�Zd
�Zdd�Zdd�Zd�Zerd�Zdd�Zd�Zd�Zd�Zdd�ZdS)r9a,Class to open URLs.
    This is a class rather than just a subroutine because we may need
    more than one set of global protocol-specific options.
    Note -- this is a base class for those who don't want the
    automatic handling of errors type 302 (relocated) and 401
    (authorization needed).Nr�c�l�dd|jjiz}tj|td���|�t��}||_|�d��|_|�d��|_	d|j
fdg|_g|_tj|_d|_t"|_dS)	NzW%(class)s style of invoking requests is deprecated. Use newer urlopen functions/methods�classr�)�
stacklevel�key_file�	cert_filez
User-Agent)�Acceptz*/*)r�r�rArBrCr6rxr�r�r��versionr��_URLopener__tempfilesrdr|�_URLopener__unlink�	tempcache�ftpcache)r�rx�x509r3s    rSr�zURLopener.__init__�s���4�7>���@W�6X�Y���
�c�-�!�<�<�<�<��?� �l�l�G��������,�,��
����+�.�.���(�$�,�7�9J�K�������	��
����!��
�
�
rTc�.�|���dSrV)r�r�s rS�__del__zURLopener.__del__�s���
�
�����rTc�.�|���dSrV)�cleanupr�s rSr�zURLopener.close�s���������rTc���|jr:|jD](}	|�|���#t$rY�%wxYw|jdd�=|jr|j���dSdSrV)r�r�r}r�r�)r�rXs  rSr�zURLopener.cleanup�s�����	$��(�
�
����M�M�$�'�'�'�'�������D������ ����#��>�	#��N� � �"�"�"�"�"�	#�	#s�(�
5�5c�:�|j�|��dS)zdAdd a header to be used by the HTTP interface only
        e.g. u.addheader('Accept', 'sound/basic')N)r�rk)r�r�s  rS�	addheaderzURLopener.addheader�s ��	
����t�$�$�$�$�$rTc�.�tt|����}t|d���}|jr:||jvr1|j|\}}t	|d��}t|||��St
|��\}}|sd}||jvr6|j|}t
|��\}}	t|	��\}
}|
|f}nd}d|z}||_	|�
dd��}t||��r|d	kr/|r|�|||��S|�
||��S	|�t||��|��St||��||��S#tt f$r�t"$r}
t#d
|
��|
�d}
~
wwxYw)z6Use URLopener().open(file) instead of open(file, 'r').z%/:=&?~#+!$,;'@()*[]|�rSr�rXN�open_�-r�r�zsocket error)r	rr
r�rMrrrxr
r�rHr��open_unknown_proxy�open_unknownr�rrr})r�rrOrprtrs�urltyperNrh�	proxyhostr�r�rir3s              rSrMzURLopener.open�s�����7�+�+�,�,����&=�>�>�>���>�	4�g���7�7� $��w� 7��H�g��h��%�%�B��b�'�7�3�3�3�!�'�*�*�����	��G��d�l�"�"��L��)�E�!+�E�!2�!2��G�Y�'�	�2�2�N�D�(���/�C�C��E��� ����	��|�|�C��%�%���t�T�"�"�	8�d�.?�&?�&?��
8��.�.�u�g�t�D�D�D��(�(��$�7�7�7�	8��|�*�w�t�T�*�*�3�/�/�/�*�w�t�T�*�*�3��5�5�5���8�$�	�	�	���	8�	8�	8��.�#�.�.�C�7�����	8���s�.E#�	E#�#F�>F�Fc�H�t|��\}}tdd|���)�/Overridable interface to open unknown URL type.�	url errorzunknown url type�rr})r�rrOr�rNs     rSr�zURLopener.open_unknowns&���w�'�'�	��c��k�#5�t�<�<�<rTc�N�t|��\}}tdd|z|���)r�r�zinvalid proxy for %sr�)r�rhrrOr�rNs      rSr�zURLopener.open_unknown_proxys+���w�'�'�	��c��k�#9�D�#@�%�H�H�HrTc��tt|����}|jr||jvr
|j|St|��\}}|�z|r|dkrr	|�|��}|���}|���tt|��d��|fS#t$rYnwxYw|�
||��}	|���}	|rt|d��}
n�t|��\}}t|pd��\}}t|pd��\}}t|pd��\}}tj�|��d}
t!j|
��\}}|j�|��tj|d��}
	||	f}|j�
||j|<d}d}d}d}d	|	vrt+|	d
��}|r
||||��	|�|��}|sn<|t/|��z
}|
�|��|dz
}|r
||||���T	|
���n#|
���wxYw	|���n#|���wxYw|dkr||krt3d||fz|���|S)ztretrieve(url) returns (filename, headers) for a local object
        or (tempfilename, headers) for a remote object.NrXr_rYr�r[r\rr]r^r`)r	rr�rr�rcr�r5r
r}rMrrrdre�splitextrg�mkstempr�rk�fdopenrlrmrnror)r�rNrprqrOr��url1rsr�rtru�garbagere�suffix�fdrvrwrxrmryrzs                     rS�retrievezURLopener.retrieves���Y�s�^�^�$�$���>�	'�c�T�^�3�3��>�#�&�&���_�_�
��d���T��T�V�^�^�
��)�)�$�/�/���w�w�y�y�����
�
�
�#�J�t�$4�$4�Q�$7�8�8�$�>�>���
�
�
���
����
�Y�Y�s�D�
!�
!��%	��g�g�i�i�G��

*��8�T�*�*��� *�3���
��� *�4�:�2� 6� 6�
��� +�D�J�B� 7� 7�
��g� *�4�:�2� 6� 6�
��g���)�)�$�/�/��2��!)�!1�&�!9�!9���X�� �'�'��1�1�1��i��D�)�)��
�!�7�*���>�-�*0�D�N�3�'���������#�w�.�.��w�'7�8�9�9�D��3��J�x��T�2�2�2�7��G�G�B�K�K�E� ����C��J�J�&�D��I�I�e�$�$�$���M�H�!�7�"�
�8�R��6�6�6�7���	�	�������	�	����������H�H�J�J�J�J��B�H�H�J�J�J�J�����1�9�9�����&�C���,�� &�(�(�
(��
s9�A B8�8
C�C�C J�BI0�J�0J�J�J5c�<�d}d}t|t��r8t|��\}}|r!t|��\}}t	|��}|}n�|\}}t|��\}}t|��\}	}
|
}d}|	���dkrd}nBt|
��\}}
|rt|��\}}|r	|	�d|�|
��}t|��r|}|stdd���|rIt	|��}tj
|������d��}nd}|rIt	|��}tj
|������d��}nd}||��}
i}|rd|z|d<|rd|z|d	<|r||d
<d|d<|j
D]
\}}|||<�|�d
|d<|
�d|||��n|
�d||���	|
���}n'#t jj$rt'd���wxYwd|jcxkrdkr"nnt+||jd|z|j��S|�||j|j|j|j|��S)a�Make an HTTP connection using connection_class.

        This is an internal method that should be called from
        open_http() or open_https().

        Arguments:
        - connection_factory should take a host name and return an
          HTTPConnection instance.
        - url is the url to retrieval or a host, relative-path pair.
        - data is payload for a POST request or None.
        Nrz://z
http errorr?r|zBasic %sr/r�r�r�rJr@zContent-Typer�r�rMz$http protocol error: bad status liner0r1�http:)rrr
rrrr�rr}r�r�r�r�r�r�rRrr�
BadStatusLiner�statusrr3�
http_errorrsrT)r��connection_factoryrNrO�user_passwd�proxy_passwdr�r��realhostr�r��
proxy_authr��	http_connrtr�r�r�s                  rS�_open_generic_httpzURLopener._open_generic_httpOs:�������c�3���	$�'��_�_�N�D�(��
%�$.�t�$4�$4�!��T��t�}�}���H�H� �N�D�(�!+�D�!1�!1��L�$�&�x�0�0�M�G�T��C��K��}�}���&�(�(����!+�D�!1�!1���$��A�,6�x�,@�,@�)�K���G�.5�g�g�x�x���F�H���)�)�$�#�D��A�7�<��A�A�A��	�"�<�0�0�L��)�,�*=�*=�*?�*?�@�@�G�G��P�P�J�J��J��	�!�+�.�.�K��#�K�$6�$6�$8�$8�9�9�@�@��I�I�D�D��D�&�&�t�,�,�	����	E�-7�*�-D�G�)�*��	:�(2�T�(9�G�O�$��	'�&�G�F�O�
!(����!�_�	$�	$�M�F�E�#�G�F�O�O���&I�G�N�#����f�h��g�>�>�>�>����e�X�w��?�?�?�	C� �,�,�.�.�H�H���{�(�	C�	C�	C��A�B�B�B�	C�����(�/�'�'�'�'�C�'�'�'�'�'��h���g��m�&�o�/�/�
/��?�?��X�[�����(�,��F�F�
Fs�H�$H9c�N�|�tjj||��S)zUse HTTP protocol.)rrrr;�r�rNrOs   rS�	open_httpzURLopener.open_http�s���&�&�t�{�'A�3��M�M�MrTc���d|z}t||��r6t||��}|�||||||��}	n|||||||��}	|	r|	S|�|||||��S)z�Handle http errors.

        Derived class can override this, or provide specific handlers
        named http_error_DDD where DDD is the 3-digit error code.z
http_error_%d)r�r�r)
r�rNrs�errcode�errmsgrtrOrir�rvs
          rSrzURLopener.http_error�s�����(���4����	%��T�4�(�(�F��|����R��&�'�B�B������R��&�'�4�H�H���$�f�}��&�&�s�B����I�I�IrTc�P�|���t||||d���)z>Default error handler: close the connection and raise OSError.N)r�r�r�rNrsrrrts      rSrzURLopener.http_error_default�s%��
���
�
�
���W�f�g�t�<�<�<rTc�Z�tj�||j|j���S)N)r�r�)rrrr�r�)r�r�s  rS�_https_connectionzURLopener._https_connection�s0���;�.�.�t�48�M�59�^�/�E�E�
ErTc�:�|�|j||��S)zUse HTTPS protocol.)rrrs   rS�
open_httpszURLopener.open_https�s���*�*�4�+A�3��M�M�MrTc�
�t|t��std���|dd�dkr=|dd�dkr/|dd����dkrt	d	���|�|��S)
z/Use local file or FTP depending on form of URL.zEfile error: proxy support for file protocol currently not implementedNr;rfr�rQ�z
localhost/r�)rrrr�rDr�r�s  rS�	open_filezURLopener.open_file�s����#�s�#�#�	d��b�c�c�c��r��r�7�d�?�?�s�1�Q�3�x�3���3�q��t�9�?�?�3D�3D��3T�3T��L�M�M�M��'�'��,�,�,rTc�N�ddl}ddl}t|��\}}t|��}	t	j|��}n,#t$r}t|j|j	���d}~wwxYw|j
}	|j�|j
d���}
|�|��d}|jd|pd|	|
fz��}|s4|}
|dd�dkrd	|z}
t!t#|d
��||
��St%|��\}}|s�t'j|��t+��ft-��zvrU|}
|dd�dkrd	|z}
n |dd�dkrt/d
|z���t!t#|d
��||
��Std���)zUse local file.rNTr�z6Content-Type: %s
Content-Length: %d
Last-modified: %s
r�r_rQr�r�r;z./zAlocal file url may start with / or file:. Unknown url of type: %sz#local file error: not on local host)r�r�r
r5rdr�r}r�strerrorrpr�r�r�r�r�r�rrMrrr�r��thishostrD)r�rNr�r�r�rX�	localnamer��erxr�r�rt�urlfiler�s               rSr�zURLopener.open_local_file�s�������������_�_�
��d� ��&�&�	�	3��G�I�&�&�E�E���	3�	3�	3��1�:�q�z�2�2�2�����	3�����}���;�)�)�%�.��)�F�F���$�$�S�)�)�!�,��+�%�+�G�
�
"�l�D�(�3�
4�5�5���	G��G��B�Q�B�x�3���#�d�*���d�9�d�3�3�W�g�F�F�F���%�%�
��d��	G��#�D�)�)�y�{�{�n�x�z�z�.I�J�J��G��B�Q�B�x�3���#�d�*����b�q�b��T�!�!� �!d�gj�!j�k�k�k��d�9�d�3�3�W�g�F�F�F��<�=�=�=s�A�
A)�
A$�$A)c���t|t��std���ddl}t	|��\}}|std���t|��\}}t
|��\}}|rt|��\}}nd}t|��}t|pd��}t|pd��}tj
|��}|sddl}|j}nt|��}t|��\}}	t|��}|�d��}
|
dd�|
d}}
|
r|
ds
|
dd�}
|
r
|
dsd|
d<|||d�|
��f}t#|j��t&krFt)|j��D]1}
|
|kr)|j|
}|j|
=|����2	||jvrt-|||||
��|j|<|sd	}nd
}|	D]D}t/|��\}}|���dkr|dvr|���}�E|j|�||��\}}|�d
|z��d}d}|r|d|zz
}|�|dkr|d|zz
}t9j|��}t=||d
|z��S#t?��$r}td|����|�d}~wwxYw)zUse FTP protocol.zCftp error: proxy support for ftp protocol currently not implementedrNr�r�rQr\r_r�r�r�r�zftp:zContent-Type: %s
zContent-Length: %d
�ftp error: ) rrrr�r
rrrrrr�r�r�rlrr�r�rnr��MAXFTPCACHEr�r�r�rr�r�r�r�r�r�r�	ftperrors)r�rNr�r�rer�ror�r�r�r�rXr�rDrEr�r�r�rsr�r�rtr�s                       rS�open_ftpzURLopener.open_ftp�sE���#�s�#�#�	b��`�a�a�a�������_�_�
��d��?�8�$>�?�?�?���%�%�
��d���%�%�
��d��	��T� 2� 2���v�v��f��t�}�}���t�z�r�"�"�����2�&�&���#�D�)�)���	��M�M�M��?�D�D��t�9�9�D� ��&�&���e��t�}�}���z�z�#�����#�2�#�Y��R��d���0��Q��0��Q�R�R����.��Q��.�3��a���D�$�������.���t�}����+�+��$�-�(�(�
�
����8�8��
�a�(�A��
�a�(��G�G�I�I�I��	9��$�-�'�'��t�V�T�4��>�>��
�c�"��
�����$��
)�
)��)�$�/�/���e��:�:�<�<�6�)�)��:�:�:� �;�;�=�=�D�� �M�#�.�7�7��d�C�C�M�R���(�(��#��6�6�q�9�E��G��
8��/�%�7�7���"�w�!�|�|��1�G�;�;���/��8�8�G��b�'�6�C�<�8�8�8���{�{�	9�	9�	9��.��.�.�/�/�S�8�����	9���s�C7K	�	K2�K-�-K2c
���t|t��std���	|�dd��\}}n#t$rtdd���wxYw|sd}|�d��}|dkr$d	||d
�vr||dzd
�}|d
|�}nd}g}|�dtj	d
tj
tj������z��|�d|z��|dkr;tj|�
d�����d��}nt|��}|�dt!|��z��|�d��|�|��d�|��}t%j|��}t)j|��}t-|||��S)zUse "data" URL.zEdata error: proxy support for data protocol currently not implementedrr_z
data errorzbad data URLr��;rrrNr�zDate: %sz%a, %d %b %Y %H:%M:%S GMTzContent-type: %sr�r|zlatin-1zContent-Length: %d�
)rrrr�rDr}�rfindrkr�strftime�gmtimer�r�r�r�rrnr�r�r�r��StringIOr)	r�rNrOr��semirRr3rt�fs	         rS�	open_datazURLopener.open_data1s����#�s�#�#�	d��b�c�c�c�	8��9�9�S�!�,�,�L�T�4�4���	8�	8�	8��,��7�7�7�	8�����	1�0�D��z�z�#�����1�9�9��D����K�/�/��D��F�G�G�}�H�����;�D�D��H����
�
�:�d�m�,G�,0�K��	���,D�,D�F�F�F�	G�	G�	G��
�
�%��,�-�-�-��x����%�d�k�k�'�&:�&:�;�;�B�B�9�M�M�D�D��4�=�=�D��
�
�'�#�d�)�)�3�4�4�4��
�
�2�����
�
�4�����i�i��n�n���+�C�0�0���K������!�W�c�*�*�*s�A�ArV�NNN)r�r�r�r5r�r�r�r�r�r�r�r�rMr�r�rrrrrrErrr"r�r-r7r�rTrSr9r9�s����������K� �;�.�G�!�!�!�!�4������#�#�#�%�%�%�"8�"8�"8�"8�H=�=�=�=�
I�I�I�I�=�=�=�=�BZF�ZF�ZF�xN�N�N�N�J�J�J�J� =�=�=�
�N�	E�	E�	E�
	N�	N�	N�	N�-�-�-�>�>�>�@89�89�89�t'+�'+�'+�'+�'+�'+rTr9c��eZdZdZd�Zd�Zdd�Zd�Zdd�Zdd�Z	dd	�Z
dd
�Z		dd�Z		dd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd�ZdS)r:z?Derived class with handlers for errors we can handle (perhaps).c�Z�tj|g|�Ri|��i|_d|_d|_dS)Nrr;)r9r��
auth_cache�tries�maxtries)r�r�r�s   rSr�zFancyURLopener.__init__^s<����4�1�$�1�1�1�&�1�1�1������
���
�
�
rTc�,�t||d|z|��S)z3Default error handling -- don't raise an exception.r	)rrs      rSrz!FancyURLopener.http_error_defaultds���"�g�w��}�g�>�>�>rTNc��|xjdz
c_	|jrE|j|jkr5t|d��r|j}n|j}|||dd|��d|_S|�||||||��}|d|_S#d|_wxYw)z%Error 302 -- relocated (temporarily).r_�http_error_500r&z)Internal Server Error: Redirect Recursionr)r<r=r�r@r�redirect_internal)	r�rNrsrrrtrOr�rvs	         rSr`zFancyURLopener.http_error_302hs����
�
�a��
�
�
	��}�
%���t�}�!<�!<��4�!1�2�2�3��.�D�D��2�D��t�C��S�G�#�%�%��D�J�J�	�+�+�C��W�f�,3�T�;�;�F���D�J�J���D�J�N�N�N�Ns�AB�B�	B
c�$�d|vr	|d}nd|vr	|d}ndS|���t|jdz|z|��}t|��}|jdvrt|||d|zz||���|�|��S)NrMrNr{rOz( Redirection to url '%s' is not allowed.)r�rr�rrVrrM)	r�rNrsrrrtrOrIr]s	         rSrAz FancyURLopener.redirect_internalzs����� � ��Z�(�F�F�
�g�
�
��U�^�F�F��F�
���
�
�
����S��3�.��7�7���F�#�#���?�">�>�>��F�G�"�F��O�P�#�R�)�)�
)�
�y�y�� � � rTc�6�|�||||||��S)z*Error 301 -- also relocated (permanently).�r`�r�rNrsrrrtrOs       rSrazFancyURLopener.http_error_301�� ���"�"�3��G�V�W�d�K�K�KrTc�6�|�||||||��S)z;Error 303 -- also relocated (essentially identical to 302).rDrEs       rSrbzFancyURLopener.http_error_303�rFrTc�l�|�|�||||||��S|�|||||��S)z1Error 307 -- relocated, but turn POST into error.)r`rrEs       rSrczFancyURLopener.http_error_307��A���<��&�&�s�B����$�O�O�O��*�*�3��G�V�W�M�M�MrTc�l�|�|�||||||��S|�|||||��S)z1Error 308 -- relocated, but turn POST into error.)rarrEs       rSrdzFancyURLopener.http_error_308�rIrTFc�*�d|vrt�||||||��|d}tjd|��}	|	st�||||||��|	���\}
}|
���dkrt�||||||��|st�||||||��d|jzdz}|�t||��||��St||��|||��S)z_Error 401 -- authentication required.
        This function supports Basic authentication only.r��![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"r��retry_�_basic_auth�r9rr��matchr�r�r�r��
r�rNrsrrrtrOr-�stuffrPrVr�ris
             rSr�zFancyURLopener.http_error_401�sN���W�,�,��(�(��s�B�)0�&�'�
C�
C�
C��*�+����?��G�G���	C��(�(��s�B�)0�&�'�
C�
C�
C������
����<�<�>�>�W�$�$��(�(��s�B�)0�&�'�
C�
C�
C��	��(�(��s�B����
�
�
��$�)�#�m�3���<�%�7�4��%�%�c�5�1�1�1�%�7�4��%�%�c�5�$�7�7�7rTc�*�d|vrt�||||||��|d}tjd|��}	|	st�||||||��|	���\}
}|
���dkrt�||||||��|st�||||||��d|jzdz}|�t||��||��St||��|||��S)zeError 407 -- proxy authentication required.
        This function supports Basic authentication only.r�rLr��retry_proxy_rNrOrQs
             rSr�zFancyURLopener.http_error_407�sN�� �w�.�.��(�(��s�B�)0�&�'�
C�
C�
C��,�-����?��G�G���	C��(�(��s�B�)0�&�'�
C�
C�
C������
����<�<�>�>�W�$�$��(�(��s�B�)0�&�'�
C�
C�
C��	��(�(��s�B����
�
�
���	�)�M�9���<�%�7�4��%�%�c�5�1�1�1�%�7�4��%�%�c�5�$�7�7�7rTc���t|��\}}d|z|z}|jd}t|��\}}	t|	��\}	}
|	�d��dz}|	|d�}	|�|	||��\}}
|s|
sdSt|d����dt|
d����d|	��}	d|	z|
z|jd<|�|�|��S|�||��S)N�http://rrgr_r�r�r{�r
rxrr��get_user_passwdr
rM�r�rNr�rOr�r�rIrhr�r��
proxyselectorr�ror�s              rS�retry_proxy_http_basic_authz*FancyURLopener.retry_proxy_http_basic_auth�s��#�C�����h��T�!�H�,����V�$��'��.�.����#-�i�#8�#8� �	�=��N�N�3���!�#���a�b�b�M�	��+�+�I�u�a�@�@���f��,��,���"'��2�"6�"6�"6�"6�"6�"'��R�"8�"8�"8�"8�"8�)�)�E�	�(�9�4�}�D���V���<��9�9�V�$�$�$��9�9�V�T�*�*�*rTc���t|��\}}d|z|z}|jd}t|��\}}	t|	��\}	}
|	�d��dz}|	|d�}	|�|	||��\}}
|s|
sdSt|d����dt|
d����d|	��}	d|	z|
z|jd<|�|�|��S|�||��S)N�https://r�rgr_r�r�r{rWrYs              rS�retry_proxy_https_basic_authz+FancyURLopener.retry_proxy_https_basic_auth�s��#�C�����h��d�"�X�-����W�%��'��.�.����#-�i�#8�#8� �	�=��N�N�3���!�#���a�b�b�M�	��+�+�I�u�a�@�@���f��,��,���"'��2�"6�"6�"6�"6�"6�"'��R�"8�"8�"8�"8�"8�)�)�E�	� *�Y� 6�� F���W���<��9�9�V�$�$�$��9�9�V�T�*�*�*rTc�d�t|��\}}|�d��dz}||d�}|�|||��\}}|s|sdSt|d����dt|d����d|��}d|z|z}	|�|�|	��S|�|	|��S)Nrgr_r�r�r{rV�r
r�rXr
rM�
r�rNr�rOr�r�r�ror�rIs
          rSr�z$FancyURLopener.retry_http_basic_auth	s���#�C�����h��I�I�c�N�N�Q����A�B�B�x���+�+�D�%��;�;���f��,��,���"�4�b�1�1�1�1�1�"�6��3�3�3�3�3�T�T�;���T�!�H�,���<��9�9�V�$�$�$��9�9�V�T�*�*�*rTc�d�t|��\}}|�d��dz}||d�}|�|||��\}}|s|sdSt|d����dt|d����d|��}d|z|z}	|�|�|	��S|�|	|��S)Nrgr_r�r�r{r]r`ras
          rS�retry_https_basic_authz%FancyURLopener.retry_https_basic_auth	s���#�C�����h��I�I�c�N�N�Q����A�B�B�x���+�+�D�%��;�;���f��,��,���"�4�b�1�1�1�1�1�"�6��3�3�3�3�3�T�T�;���d�"�X�-���<��9�9�V�$�$�$��9�9�V�T�*�*�*rTrc���|dz|���z}||jvr|r	|j|=n
|j|S|�||��\}}|s|r||f|j|<||fS)Nrg)r�r;�prompt_user_passwd)r�r�r�r�r�ror�s       rSrXzFancyURLopener.get_user_passwd	s����c�k�D�J�J�L�L�(���$�/�!�!��
,��O�C�(�(���s�+�+��.�.�t�U�;�;���f��@�6�@�4��.�4�?�3�/��V�|�rTc	��ddl}	td|�d|�d���}|�d|�d|�d|�d���}||fS#t$rt��YdSwxYw)	z#Override this in a GUI environment!rNzEnter username for z at z: zEnter password for z in r�)�getpass�input�KeyboardInterrupt�print)r�r�r�rgror�s      rSrez!FancyURLopener.prompt_user_passwd)	s�������	��5�E�E�E�4�4�4�H�I�I�D��_�_�_����u�u�u�d�d�d�&$�%�%�F���<��� �	�	�	��G�G�G��:�:�	���s�8?�A�ArV)NFrZ)r�r�r�r5r�rr`rArarbrcrdr�r�r[r^r�rcrXrer�rTrSr:r:[sj������I�I����?�?�?�����$!�!�!�8L�L�L�L�L�L�L�L�N�N�N�N�N�N�N�N�FJ��8�8�8�8�2FJ��8�8�8�8�2+�+�+�+�$+�+�+�+�$+�+�+�+�+�+�+�+�	�	�	�	�
�
�
�
�
rTr:c�F�t�tjd��atS)z8Return the IP address of the magic hostname 'localhost'.Nr�)�
_localhostrr�r�rTrSr�r�9	s �����)�+�6�6�
��rTc�
�t�v	ttjtj����d��an<#tj$r*ttjd��d��aYnwxYwtS)z,Return the IP addresses of the current host.Nr;r�)�	_thishostr�rr�r�r�r�rTrSr%r%A	s�����	G��f�5�f�6H�6J�6J�K�K�A�N�O�O�I�I����	G�	G�	G��f�5�k�B�B�1�E�F�F�I�I�I�	G�����s�8A�6A;�:A;c�4�t�ddl}|jatS)z1Return the set of errors raised by the FTP class.Nr)�
_ftperrorsr�r�)r�s rSr,r,L	s!�����
�
�
��&�
��rTc�F�t�tjd��atS)z%Return an empty email Message object.Nr�)�
_noheadersr�r�r�rTrS�	noheadersrsU	s �����.�r�2�2�
��rTc�B�eZdZdZ		dd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
dS)r�z;Class used by open_ftp() for cache of open FTP connections.NTc���||_||_||_||_||_||_d|_||_	|���dS#|�	���xYwr�)
ror�r�r�r�rP�refcount�	keepalive�initr�)r�ror�r�r�r�rPr�s        rSr�zftpwrapper.__init__b	si����	������	���	���	������
�#���	��I�I�K�K�K�K�K��	��J�J�L�L�L����s�A�A'c�V�ddl}d|_|���|_|j�|j|j|j��|j�|j	|j
��d�|j��}|j�
|��dS)NrrQ)r��busy�FTPrP�connectr�r�rP�loginror�r�r��cwd)r�r��_targets   rSrxzftpwrapper.initr	s����
�
�
���	��:�:�<�<���������D�I�t�|�<�<�<�����t�y�$�+�.�.�.��(�(�4�9�%�%������W�����rTc�D�ddl}|���|dvrd}d}nd|z}d}	|j�|��n>#|j$r1|���|j�|��YnwxYwd}|rk|si	d|z}|j�|��\}}nE#|j$r8}t|��dd�dkrtd	|����|�Yd}~nd}~wwxYw|s�|j�d��|r�|j�
��}			|j�|��n%#|j$r}td
|z��|�d}~wwxYw	|j�|	��n#|j�|	��wxYwd|z}nd}|j�|��\}}d|_t|�d
��|j��}
|xjdz
c_|���|
|fS)Nr)r'r�zTYPE Ar_zTYPE zRETR r��550r*z
ftp error: %rzLIST �LISTr�)r��endtransferrP�voidcmdr�rx�ntransfercmd�
error_permrr�pwdr~rzr�makefile�
file_closervr�)r�rXr�r��cmd�isdirr�r�rTr��ftpobjs           rSr�zftpwrapper.retrfile{	s����
�
�
��������:���X�s�q�u�u��d�N�c�A�E�	"��H���S�!�!�!�!��� �	"�	"�	"��I�I�K�K�K��H���S�!�!�!�!�!�	"�������	G��	G�
G���n�� $�� 5� 5�c� :� :�
��g�g���$�
G�
G�
G��v�;�;�r��r�?�e�+�+�"�#9��#9�#9�:�:��F�,�+�+�+�+�����
G�����	7��H���X�&�&�&��
��h�l�l�n�n��&�M�����T�*�*�*�*��!�,�M�M�M�&���'?�@�@�f�L�����M����+��H�L�L��%�%�%�%��D�H�L�L��%�%�%�%������n����� �H�1�1�#�6�6�M�D�'���	��d�m�m�D�1�1�4�?�C�C���
�
���
�
��
�
������ � sS�A�8B�?B�
"B-�-
C/�7.C*�*C/�+E�F�
E(�E#�#E(�(F�F#c��|jsdSd|_	|j���dS#t��$rYdSwxYwr�)rzrP�voidrespr,r�s rSr�zftpwrapper.endtransfer�	s]���y�	��F���	�	��H����������{�{�	�	�	��D�D�	���s�-�A�Ac�V�d|_|jdkr|���dSdS)NFr)rwrv�
real_closer�s rSr�zftpwrapper.close�	s4������=�A����O�O�������rTc��|���|xjdzc_|jdkr|js|���dSdSdS)Nr_r)r�rvrwr�r�s rSr�zftpwrapper.file_close�	s\���������
�
���
�
��=�A���d�n���O�O���������rTc��|���	|j���dS#t��$rYdSwxYwrV)r�rPr�r,r�s rSr�zftpwrapper.real_close�	sW��������	��H�N�N��������{�{�	�	�	��D�D�	���s�1�A�A)NT)r�r�r�r5r�rxr�r�r�r�r�r�rTrSr�r�_	s�������E�E�?C� ����� ���*!�*!�*!�X������
�������rTr�c���i}tj���D]6\}}|���}|r|dd�dkr
|||dd�<�7dtjvr|�dd��tj���D]U\}}|dd�dkrB|���}|r|||dd�<�7|�|dd�d���V|S)aReturn a dictionary of scheme -> proxy server URL mappings.

    Scan the environment for variables named <scheme>_proxy;
    this seems to be the standard convention.  If you need a
    different way, you can pass a proxies dictionary to the
    [Fancy]URLopener constructor.

    i����N�_proxy�REQUEST_METHODr)rd�environr�r�r�)rxrir�s   rS�getproxies_environmentr��	s	���G��z�'�'�)�)�'�'���e��z�z�|�|���	'�T�"�#�#�Y�(�*�*�!&�G�D��"��I���
�2�:�%�%����F�D�!�!�!��z�'�'�)�)�-�-���e�����9�� � ��:�:�<�<�D��
-�%*���S�b�S�	�"�"����D��"��I�t�,�,�,���NrTc���|�t��}	|d}n#t$rYdSwxYw|dkrdS|���}t|��\}}|�d��D]�}|���}|rj|�d��}|���}||ks||krdSd|z}|�|��s|�|��rdS��dS)z�Test if proxies should not be used for a particular host.

    Checks the proxy dict for the value of no_proxy, which should
    be a list of comma separated DNS suffixes, or '*' for all hosts.

    N�noF�*Tr�.)r�rr�rr�r��lstripr�)r�rx�no_proxy�hostonlyr�ris      rS�proxy_bypass_environmentr��	s����(�*�*����4�=���������u�u������3����t��:�:�<�<�D���%�%�N�H�d����s�#�#�	�	���z�z�|�|���	��;�;�s�#�#�D��:�:�<�<�D��4���4�4�<�<��t�t���:�D�� � ��&�&�
�$�-�-��*=�*=�
��t�t���5s��
)�)c�x�ddlm}ddlm}m}t	|��\}}d�}d|vr
|drdSd}	t||����}n#|$rYnwxYw|�d	d
��D]�}	|	s�tjd|	��}
|
��|��||
�	d����}|
�	d
��}|�/d|
�	d���
d��dzz}nt|dd���}|dks|dkr��d|z
}||z	||z	krdS��|||	��rdS��dS)aj
    Return True iff this host shouldn't be accessed using a proxy

    This function uses the MacOSX framework SystemConfiguration
    to fetch the proxy information.

    proxy_settings come from _scproxy._get_proxy_settings or get mocked ie:
    { 'exclude_simple': bool,
      'exceptions': ['foo.bar', '*.bar.com', '127.0.0.1', '10.1', '10.0/16']
    }
    r��fnmatch)�AddressValueError�IPv4Addressc��|�d��}ttt|����}t	|��dkr|gd�zdd�}|ddz|ddzz|dd	zz|d
zS)Nr�r:)rrrrr�r_rr;r�r�)r�r�r�rlrn)�ipAddrr�s  rS�ip2numz,_proxy_bypass_macosx_sysconf.<locals>.ip2num
s�����S�!�!���S��e�_�_�%�%���u�:�:��?�?��\�\�\�)�2�A�2�.�E��a��B��5��8�r�>�2�e�A�h�!�m�D�u�Q�x�O�OrTr��exclude_simpleTN�
exceptionsr�z(\d+(?:\.\d+)*)(/\d+)?r_r;r�� F)r��	ipaddressr�r�rrlr�r�rP�group�count)
r��proxy_settingsr�r�r�r�r�r��hostIPr�rJr��masks
             rS�_proxy_bypass_macosx_sysconfr�
s��� ������8�8�8�8�8�8�8�8���%�%�N�H�d�P�P�P��$����*�+�	��4�
�F�
��[�[��*�*�+�+�����
�
�
���
���� �#�#�L�"�5�5������h��H�.��6�6���=�V�/��6�!�'�'�!�*�*�%�%�D��7�7�1�:�:�D��|��A�G�G�A�J�J�,�,�S�1�1�A�5�6����4����8�}�}���a�x�x�4�"�9�9����9�D��$��D�D�L�1�1��t�t�2��W�T�5�
!�
!�	��4�4�	��5s�A�A�Ac���ddlm}t|��\}}|�d��}|D]3}|���}|dkrd|vrdS�$|||��rdS�4dS)a
Return True if the host should bypass the proxy server.

    The proxy override list is obtained from the Windows
    Internet settings proxy override registry value.

    An example of a proxy override value is:
    "www.example.com;*.example.net; 192.168.0.1"
    rr�r/z<local>r�TF)r�rr�r�)r��overrider�r��proxy_overrider�s      rS�_proxy_bypass_winreg_overrider�G
s��� ����������G�D�!��^�^�C�(�(�N������z�z�|�|���9����$����t�t��
�W�T�4�
 �
 �	��4�4�	��5rT�darwin)�_get_proxy_settings�_get_proxiesc�>�t��}t||��SrV)r�r�)r�r�s  rS�proxy_bypass_macosx_sysconfr�b
s��,�.�.��+�D�.�A�A�ArTc��t��S)z�Return a dictionary of scheme -> proxy server URL mappings.

        This function uses the MacOSX framework SystemConfiguration
        to fetch the proxy information.
        )r�r�rTrS�getproxies_macosx_sysconfr�f
s���~�~�rTc�`�t��}|rt||��St|��S)z�Return True, if host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or from the MacOSX framework SystemConfiguration.

        )r�r�r��r�rxs  rSrrp
s5��)�*�*���	5�+�D�'�:�:�:�.�t�4�4�4rTc�:�t��p
t��SrV)r�r�r�rTrSr6r6}
s��%�'�'�F�+D�+F�+F�FrTc�*�i}	ddl}n#t$r|cYSwxYw	|�|jd��}|�|d��d}|�rt|�|d��d��}d|vrd|vrd�|��}|�d��D]J}|�dd	��\}}tj	d
|��s|dvrd|z}n|d
krd|z}|||<�K|�
d
��rPtjdd|d
��}|�
d��p||d<|�
d��p||d<|���n#tttf$rYnwxYw|S)zxReturn a dictionary of scheme -> proxy server URL mappings.

        Win32 uses the registry to store proxies.

        rN�;Software\Microsoft\Windows\CurrentVersion\Internet Settings�ProxyEnable�ProxyServerrrr/zhttp={0};https={0};ftp={0}r_z
(?:[^/:]+)://)rr�rPrV�sockszsocks://z	^socks://z	socks4://rr�)�winreg�ImportError�OpenKey�HKEY_CURRENT_USER�QueryValueExrr�r�r�rPr�r��Closer}rDr�)rxr��internetSettings�proxyEnable�proxyServer�pr��addresss        rS�getproxies_registryr��
s����	��M�M�M�M���	�	�	��N�N�N�	����"	�%�~�~�f�.F�N� P� P�� �-�-�.>�/<�>�>�>?�A�K��
G�!�&�"5�"5�6F�7D�#F�#F�FG�#I�J�J���k�)�)�c��.D�.D�">�"E�"E�k�"R�"R�K�$�*�*�3�/�/�
0�
0�A�()����Q���%�H�g��8�O�W�=�=�;�#�'?�?�?�&/�'�&9�G�G�%��0�0�&0�7�&:�G�(/�G�H�%�%��;�;�w�'�'�G� �f�\�;���@P�Q�Q�G�&-�k�k�&�&9�&9�&D�W�G�F�O�'.�{�{�7�';�';�'F�w�G�G�$��"�"�$�$�$�$����Y�/�	�	�	�
�D�		����
�s�	���EE6�6F�Fc�:�t��p
t��S)z�Return a dictionary of scheme -> proxy server URL mappings.

        Returns settings gathered from the environment, if specified,
        or the registry.

        )r�r�r�rTrSr6r6�
s��&�'�'�@�+>�+@�+@�@rTc�B�	ddl}n#t$rYdSwxYw	|�|jd��}|�|d��d}t|�|d��d��}n#t$rYdSwxYw|r|sdSt||��S)NrFr�r��
ProxyOverride)r�r�r�r�r�rr}r�)r�r�r�r��
proxyOverrides     rS�proxy_bypass_registryr��
s���	��M�M�M�M���	�	�	��5�5�	����		�%�~�~�f�.F�N� P� P�� �-�-�.>�/<�>�>�>?�A�K��� 3� 3�4D�5D�!F�!F�FG�!I�J�J�M�M���	�	�	��5�5�	�����	�-�	��5�,�T�=�A�A�As��
��A A:�:
B�Bc�`�t��}|rt||��St|��S)z�Return True, if host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or the registry.

        )r�r�r�r�s  rSrr�
s5��)�*�*���	/�+�D�'�:�:�:�(��.�.�.rTr8rV)r5r�r�r�r�http.clientrr�rd�	posixpathr�rrXrrrgrarA�urllib.errorrrr�urllib.parserrrr	r
rrr
rrrrrrrrrr�urllib.responserrrFrEr��__all__�version_infor�rLrr1r2rjr7r8r��ASCIIr�r�rrr3rr0rrrqr r!r"r#r$r%r&�urandomrr'r(r)r2r*r�rrKrkrr/r�r�r+r�r,r-r.r+ri�
nturl2pathr5r4r�r9r:rlr�rnr%rpr,rrrsr�r�r�r�r��platform�_scproxyr�r�r�r�rr6r�r�r�rTrS�<module>r�s�	��C�C�f�
�
�
�
�
�
�
�������������	�	�	�	�	�	�	�	�����	�	�	�	�
�
�
�
�
�
�
�
�
�
�
�
�����������������C�B�B�B�B�B�B�B�B�B�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�
5�4�4�4�4�4�4�4���J�J�J��I�I�������I�I�I�����
����$��(��!��,�,��
���F�$B�M+��4�5�$�M+�M+�M+�M+�M+�^�����=�=�=�=�~����r�z�(�B�H�-�-����� k"�k"�k"�k"�k"�k"�k"�k"�ZI+�I+�I+�I+�I+�I+�I+�I+�^"�"�"�H8�8�8�8�8�8�8�8�&#�#�#�#�#��#�#�#�";�;�;�;�;�k�;�;�;�n2�n2�n2�n2�n2�+�n2�n2�n2�b,�,�,�B)>�)>�)>�)>�)>�;�)>�)>�)>�V=*�=*�=*�=*�=*�=*�=*�=*�@G�G�G�G�G�o�G�G�G�3�3�3�3�3�#B�3�3�3�>k#�k#�k#�k#�k#�k#�k#�k#�^�����3�[���������4�k���� �z��O�O�O�O�O�O�O�O�d�����K�)B����$
�
�
�
�
�[�*C�
�
�
�s�s�s�s�s�+�s�s�s�l3�3�3�3�3�%�3�3�3��7�4�;�)�*�*�#�8�8�8�8�8�*�8�8�8��N�N�>�"�"�"�#�#�#�#�#�+�#�#�#�$6�6�6�6�6�[�6�6�6�
���)*�)*�)*�V11�11�11�11�11�+�11�11�11�f���7,�7,�7,�7,�7,��7,�7,�7,�r3�3�3�3�3�j�3�3�3�j:�:�:�:�:�+�:�:�:�B���7�d�?�?�5�5�5�5�5�5�5�5�5�!�!�!�
�����z+�z+�z+�z+�z+�z+�z+�z+�z
X�X�X�X�X�Y�X�X�X�z�
����
�	�����
�����
����a�a�a�a�a�a�a�a�H���> � � � �J<�<�<�@���0�<�8���:�:�:�:�:�:�:�:�B�B�B����5�5�5�G�G�G�G�G��W��_�_�/�/�/�bA�A�A�B�B�B�(/�/�/�/�/�(�J�+�L�L�Ls�>B�B�B

Zerion Mini Shell 1.0