AlkantarClanX12

Your IP : 18.118.193.28


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

�

c��fw���<�	ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZmZmZddlmZmZmZmZmZmZmZmZmZmZm 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.dej/dd	�zZ0da1de
j2fddddd
�d�Z3d�Z4gZ5dfd
�Z6d�Z7e	j8de	j9��Z:d�Z;Gd�d��Z<Gd�d��Z=d�Z>Gd�d��Z?Gd�de?��Z@Gd�de?��ZAGd�de?��ZBd�ZCGd�d e?��ZDGd!�d"��ZEGd#�d$eE��ZFGd%�d&eF��ZGGd'�d(��ZHGd)�d*eHe?��ZIGd+�d,eHe?��ZJejKZLGd-�d.��ZMGd/�d0e?eM��ZNGd1�d2e?eM��ZOGd3�d4e?��ZPGd5�d6eP��ZQeRejSd7��r#Gd8�d9eP��ZTe.�Ud9��Gd:�d;e?��ZVGd<�d=e?��ZWd>�ZXd?�ZYGd@�dAe?��ZZdB�Z[GdC�dDe?��Z\GdE�dFe\��Z]GdG�dHe?��Z^dIZ_ej`dJkr	ddKlambZbmcZcndL�ZbdM�ZciZdGdN�dO��ZeGdP�dQee��ZfdagdR�ZhdaidS�ZjdakdT�ZldamdU�ZnGdV�dW��ZodX�ZpdgdY�ZqdZ�Zrd[�Zsejtd\krdd]lumvZvmwZwd^�Zxd_�Zyd`�Zzda�Z{dSej`dJkrdb�Z|dc�Z{dd�Z}de�ZzdSepZ{eqZzdS)h�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)	NrzJcafile, 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�s4��0�d����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�N�	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
}|�|��|
dz
}
|r
||
|
|���T	ddd��n#1swxYwYddd��n#1swxYwY|dkr||krt%d||fz|	���|	S)
N�file�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=�=E9�AE9�B
E"�E9�"E&	�&E9�)E&	�*E9�9E=�E=c��	tD]'}	tj|���#t$rY�$wxYwtdd�=trdadSdSrV)rjrd�unlink�OSErrorrL)�	temp_files rSr8r8su��:�#���	�	��I�i� � � � ���	�	�	��D�	����	�q�q�q���������s�!�
.�.z:\d+$c���	|j}t|��d}|dkr|�dd��}t�d|d��}|���S)Nr_��Host)�full_urlr�
get_header�_cut_port_re�sub�lower)�requestrN�hosts   rS�request_hostr�-sf����
�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)N�POST�GETr�)rO�getattr)r��default_methods  rS�
get_methodzRequest.get_method~s'��A�#'�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�r	rOrvr�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)N�HTTPSConnection)rr r/r*rrr,r+r0r.r�r�clientrkrK�setrr��
issubclass�add�remover�)r�rR�default_classes�skip�klass�check�hs       rSr3r39s|����
�
�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��eZdZ	dZd�ZeZdS)r0i�c��|j|j|���}}}d|cxkrdks!n|j�d|||||��}|S)N���,r)�code�msgrcr)r�)r�r�r�r3r4r�s      rS�
http_responsez HTTPErrorProcessor.http_responsetsg��"�-���x�}�}���4�c���t�!�!�!�!�c�!�!�!�!��{�(�(����4��d�<�<�H��rTN)r�r�r�r,r5�https_responser�rTrSr0r0ps,������'��M�	�	�	�#�N�N�NrTr0c��eZdZd�ZdS)rc�2�t|j||||���rV)rr�)r�r	rsr3r4r�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)N)�-�.�/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�r	rsr3r4rt�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�r	rsr3r4rtrI�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)NrQ�//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�r	rhr��	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)	Nr_rr;rQ�Pi�rz%s:%d)rrr�)
r�rNr��partsrVrjrer��port�dports
          rSr�zHTTPPasswordMgr.reduce_uri\s���N���
�
����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)NTrFr_r\rQ)r�)r��base�test�prefixs    rSr�zHTTPPasswordMgr.is_suburissl��	��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�r	rt�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�r	r�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�r	ror��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�r1r2TF)r�r�r3r�r�)r�r	r�s   rSr5z&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�r5�
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�r	rsr3r4rtrNr�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�r	rsr3r4rtrjr�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�r	rtr�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�r	r��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�r	r�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��eZdZ	dZdZd�ZdS)r(r���c��t|j��d}|�d|||��}|���|S)Nr_r�)rr�r�r��r�r	rsr3r4rtr��retrys        rSr�z$HTTPDigestAuthHandler.http_error_401�sL�����%�%�a�(���*�*�+=�+/��g�?�?����� � � ��rTN)r�r�r�r�r,r�r�rTrSr(r(�s4�������"�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�rOr4�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)Nr?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_chunked)r�rrP�set_debuglevelr5rr��updatertr�r��
set_tunnelr�r�r�rOr�r}�getresponser��sockr�rN�reasonr4)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	D9�8E/�9
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�r	s  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   rSr5z!HTTPCookieProcessor.http_response�s����&�&�x��9�9�9��rTrV)r�r�r�r�r�r5r�r6r�rTrSrrvsL������#�#�#�#�������!�M�"�N�N�NrTrc��eZdZd�ZdS)r/c�4�|j}td|z���)Nzunknown url type: %s)r�r)r�r	r�s   rSrzUnknownHandler.unknown_open�s���x���-��4�5�5�5rTN)r�r�r�rr�rTrSr/r/�s#������6�6�6�6�6rTr/c��	i}|D]B}|�dd��\}}|ddkr|ddkr
|dd�}|||<�C|S)N�=r_rr�r\)r�)�l�parsed�eltrDrEs     rSr�r��sf��H�
�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)Nr�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�r	rNs   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�r	r�r�r�r�ror�r4re�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�r	rNrVrO�	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|��SrV)r��pathnames rSr5r5�s��	C��x� � � rTc�"�	t|��SrV)r
r�s rSr4r4�s��	B��X���rTc��eZdZ	dZdezZdd�Zd�Zd�Zd�Z	d�Z
dd�Zdd	�Zdd
�Z
dd�Zd�Zdd
�Zdd�Zd�Zerd�Zdd�Zd�Zd�Zd�Zdd�ZdS)r9Nr�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�x509r4s    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�|��dSrV)r�rk)r�r�s  rS�	addheaderzURLopener.addheader�s#��	5�����t�$�$�$�$�$rTc�0�	tt|����}t|d���}|jr:||jvr1|j|\}}t	|d��}t|||��St
|��\}}|sd}||jvr6|j|}t
|��\}}	t|	��\}
}|
|f}nd}d|z}||_	|�
dd��}t||��r|dkr/|r|�|||��S|�
||��S	|�t||��|��St||��||��S#tt f$r�t"$r}
t#d	|
��|
�d}
~
wwxYw)
Nz%/:=&?~#+!$,;'@()*[]|�rSr�rX�open_�-r�r�zsocket error)r	rr
r�rMrrrxr
r�rHr��open_unknown_proxy�open_unknownr�rrr})r�rrOrprtrs�urltyperNrh�	proxyhostr�r�rir4s              rSrMzURLopener.open�s���D���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�J�	t|��\}}tdd|���)N�	url errorzunknown url type�rr})r�rrOr�rNs     rSr�zURLopener.open_unknowns)��=��w�'�'�	��c��k�#5�t�<�<�<rTc�P�	t|��\}}tdd|z|���)Nr�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)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 B9�9
C�C� C J �BI1�J �1J�J � J6c�>�	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)Nrz://z
http errorr?r|zBasic %sr/r�r�r�rJr@zContent-Typer�r�rMz$http protocol error: bad status liner1r2�http:)rrr
rrrr�rr}r�r�r�r�r�r�rRrr�
BadStatusLiner�statusrr4�
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�$H:c�P�	|�tjj||��SrV)rrrr;�r�rNrOs   rS�	open_httpzURLopener.open_http�s"�� ��&�&�t�{�'A�3��M�M�MrTc���	d|z}t||��r6t||��}|�||||||��}	n|||||||��}	|	r|	S|�|||||��S)Nz
http_error_%d)r�r�r)
r�rNrs�errcode�errmsgrtrOrir�rvs
          rSrzURLopener.http_error�s���	E�
��(���4����	%��T�4�(�(�F��|����R��&�'�B�B������R��&�'�4�H�H���$�f�}��&�&�s�B����I�I�IrTc�R�	|���t||||d���rV)r�r�r�rNrsrrrts      rSrzURLopener.http_error_default�s(��L�
���
�
�
���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||��SrV)rrrs   rS�
open_httpszURLopener.open_https�s ��%��*�*�4�+A�3��M�M�MrTc��	t|t��std���|dd�dkr=|dd�dkr/|dd����dkrt	d���|�|��S)	NzEfile error: proxy support for file protocol currently not implementedr;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�P�	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
�dkrt/d|z���t!t#|d	��||
��Std
���)NrTr�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/|��\}}|���d
kr|dvr|���}�E|j|�||��\}}|�d|z��d}d}|r|d
|zz
}|�|dkr|d|zz
}t9j|��}t=||d|z��S#t?��$r}td|����|�d}~wwxYw)NzCftp error: proxy support for ftp protocol currently not implementedrr�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�sH����#�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
�
K3�K.�.K3c
���	t|t��std���	|�dd��\}}n#t$rtdd���wxYw|sd}|�d��}|dkr$d	||d�vr||dzd�}|d|�}nd
}g}|�dtj	dtj
tj������z��|�d
|z��|dkr;tj|�
d�����d��}nt|��}|�dt!|��z��|�d
��|�|��d�|��}t%j|��}t)j|��}t-|||��S)NzEdata error: proxy support for data protocol currently not implementedrr_z
data errorzbad data URLr��;rrrr�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��semirRr4rt�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�r�r�r�r�r�r�r�r�rMr�r�rrrrrrErrr!r�r,r6r�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��eZdZ	d�Zd�Zdd�Zd�Zdd�Zdd�Zdd�Z	dd	�Z
		dd�Z		dd�Zdd
�Z
dd�Zdd�Zdd�Zdd�Zd�ZdS)r: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)Nr)rrs      rSrz!FancyURLopener.http_error_defaultds��A��"�g�w��}�g�>�>�>rTNc��	|xjdz
c_	|jrE|j|jkr5t|d��r|j}n|j}|||dd|��d|_S|�||||||��}|d|_S#d|_wxYw)Nr_�http_error_500r'z)Internal Server Error: Redirect Recursionr)r;r<r�r?r�redirect_internal)	r�rNrsrrrtrOr�rvs	         rSr`zFancyURLopener.http_error_302hs���3��
�
�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�	Bc�$�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	         rSr@z 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�8�	|�||||||��SrV�r`�r�rNrsrrrtrOs       rSrazFancyURLopener.http_error_301�s#��8��"�"�3��G�V�W�d�K�K�KrTc�8�	|�||||||��SrVrCrDs       rSrbzFancyURLopener.http_error_303�s#��I��"�"�3��G�V�W�d�K�K�KrTc�n�	|�|�||||||��S|�|||||��SrV)r`rrDs       rSrczFancyURLopener.http_error_307��D��?��<��&�&�s�B����$�O�O�O��*�*�3��G�V�W�M�M�MrTc�n�	|�|�||||||��S|�|||||��SrV)rarrDs       rSrdzFancyURLopener.http_error_308�rGrTFc�,�	d|vrt�||||||��|d}tjd|��}	|	st�||||||��|	���\}
}|
���dkrt�||||||��|st�||||||��d|jzdz}|�t||��||��St||��|||��S)Nr��![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"r��retry_�_basic_auth�r9rr��matchr�r�r�r��
r�rNrsrrrtrOr-�stuffrNrVr�ris
             rSr�zFancyURLopener.http_error_401�sQ��	=��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)Nr�rJr��retry_proxy_rLrMrOs
             rSr�zFancyURLopener.http_error_407�sQ��	=��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{rUrWs              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{rT�r
r�rVr
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^r_s
          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       rSrVzFancyURLopener.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)NrzEnter username for z at z: zEnter password for z in r�)�getpass�input�KeyboardInterrupt�print)r�r�r�reror�s      rSrcz!FancyURLopener.prompt_user_passwd)	s���1�����	��5�E�E�E�4�4�4�H�I�I�D��_�_�_����u�u�u�d�d�d�&$�%�%�F���<��� �	�	�	��G�G�G��:�:�	���s�8A�A�ArV)NFrZ)r�r�r�r�rr`r@rarbrcrdr�r�rYr\r�rarVrcr�rTrSr:r:[sg������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�H�	t�tjd��atS)Nr�)�
_localhostrr�r�rTrSr�r�9	s!��B����)�+�6�6�
��rTc��	t�v	ttjtj����d��an<#tj$r*ttjd��d��aYnwxYwtS)Nr;r�)�	_thishostr�rr�r�r�r�rTrSr$r$A	s���6���	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�6�	t�ddl}|jatSr�)�
_ftperrorsr�r�)r�s rSr+r+L	s"��;����
�
�
��&�
��rTc�H�	t�tjd��atSr�)�
_noheadersr�r�r�rTrS�	noheadersrqU	s!��/����.�r�2�2�
��rTc�@�eZdZ			d
d�Zd�Zd�Zd�Zd�Zd�Zd	�Z	dS)r�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   rSrvzftpwrapper.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�rv�ntransfercmd�
error_permrr�pwdr|rxr�makefile�
file_closertr�)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�)rxrP�voidrespr+r�s rSr�zftpwrapper.endtransfer�	s]���y�	��F���	�	��H����������{�{�	�	�	��D�D�	���s�-�A�Ac�V�d|_|jdkr|���dSdS)NFr)rurt�
real_closer�s rSr�zftpwrapper.close�	s4������=�A����O�O�������rTc��|���|xjdzc_|jdkr|js|���dSdSdS)Nr_r)r�rtrur�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�r�rvr�r�r�r�r�r�rTrSr�r�_	s�������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)Ni�����_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)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�z�	ddlm}ddlm}m}t	|��\}}d�}d|vr
|drdSd}	t||����}n#|$rYnwxYw|�dd	��D]�}	|	s�tjd
|	��}
|
��|��||
�	d����}|
�	d��}|�/d
|
�	d���
d��dzz}nt|dd���}|dks|dkr��d|z
}||z	||z	krdS��|||	��rdS��dS)Nr��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_simpleT�
exceptionsr�z(\d+(?:\.\d+)*)(/\d+)?r_r;r�� F)r��	ipaddressr�r�rrlr�r�rN�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)Nrr�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��SrV)r�r�rTrS�getproxies_macosx_sysconfr�f
s��	�
�~�~�rTc�b�	t��}|rt||��St|��SrV)r�r�r��r�rxs  rSrrp
s:��	�)�*�*���	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|d
vrd|z}n|dkrd
|z}|||<�K|�
d��rPtjdd|d��}|�
d��p||d<|�
d��p||d<|���n#tttf$rYnwxYw|S)Nr�;Software\Microsoft\Windows\CurrentVersion\Internet Settings�ProxyEnable�ProxyServerrrr.zhttp={0};https={0};ftp={0}r_z
(?:[^/:]+)://)rr�rPrT�sockszsocks://z	^socks://z	socks4://rr�)�winreg�ImportError�OpenKey�HKEY_CURRENT_USER�QueryValueExrr�r�r�rNr�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�
���EE7�7F�Fc�<�	t��p
t��SrV)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�b�	t��}|rt||��St|��SrV)r�r�r�r�s  rSrr�
s:��	�)�*�*���	/�+�D�'�:�:�:�(��.�.�.rTr7rV)~r�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:rjr�rlr$rnr+rprqr�r�r�r�r��platform�_scproxyr�r�r�r�rr6r�r�r�rTrS�<module>r�s�	��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