a
    Xh&                     @  s  d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ	 ej
rrddlmZ ddlmZ ddlmZ dd	lmZ G d
d deZG dd deZeejdef eedf f ZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZ e Z!G dd deZ"G dd deZ#G dd  d eZ$G d!d" d"eZ%G d#d$ d$e%eZ&G d%d& d&e%Z'G d'd( d(e'eZ(G d)d* d*e(Z)G d+d, d,eZ*G d-d. d.eZ+G d/d0 d0eZ,G d1d2 d2e-eZ.G d3d4 d4e.Z/G d5d6 d6e.Z0G d7d8 d8eZ1G d9d: d:eZ2G d;d< d<e2Z3G d=d> d>e2Z4G d?d@ d@e2Z5G dAdB dBe2Z6G dCdD dDeZ7G dEdF dFe e-Z8G dGdH dHeZ9G dIdJ dJee	ZG dKdL dLee	Z:G dMdN dNeZ;G dOdP dPe<e0Z=G dQdR dRe-Z>G dSdT dTeZ?G dUdV dVeZ@dS )W    )annotationsN)MessageDefect)IncompleteRead   )HTTPConnection)ConnectionPool)HTTPResponse)Retryc                   @  s   e Zd ZdZdS )	HTTPErrorz#Base exception used by this module.N__name__
__module____qualname____doc__ r   r   U/var/www/viveiro_nova_floresta/venv/lib/python3.9/site-packages/urllib3/exceptions.pyr
      s   r
   c                   @  s   e Zd ZdZdS )HTTPWarningz!Base warning used by this module.Nr   r   r   r   r   r      s   r   .c                      s8   e Zd ZdZdddd fddZdd	d
dZ  ZS )	PoolErrorz/Base exception for errors caused within a pool.r   strNone)poolmessagereturnc                   s&   || _ || _t | d|  d S Nz: )r   _messagesuper__init__)selfr   r   	__class__r   r   r       s    zPoolError.__init___TYPE_REDUCE_RESULTr   c                 C  s   | j d | jffS Nr   r   r   r   r   r   
__reduce__%   s    zPoolError.__reduce__r   r   r   r   r   r%   __classcell__r   r   r   r   r      s   r   c                      s:   e Zd ZdZddddd fddZdd	d
dZ  ZS )RequestErrorz8Base exception for PoolErrors that have associated URLs.r   r   r   )r   urlr   r   c                   s   || _ t || d S r"   )r)   r   r   )r   r   r)   r   r   r   r   r   -   s    zRequestError.__init__r    r!   c                 C  s   | j d | j| jffS r"   )r   r)   r   r$   r   r   r   r%   1   s    zRequestError.__reduce__r&   r   r   r   r   r(   *   s   r(   c                   @  s   e Zd ZdZdS )SSLErrorz9Raised when SSL certificate fails in an HTTPS connection.Nr   r   r   r   r   r*   6   s   r*   c                      s4   e Zd ZU dZded< dddd fddZ  ZS )	
ProxyErrorz,Raised when the connection to a proxy fails.	Exceptionoriginal_errorr   r   )r   errorr   c                   s   t  || || _d S r"   )r   r   r-   )r   r   r.   r   r   r   r   @   s    zProxyError.__init__)r   r   r   r   __annotations__r   r'   r   r   r   r   r+   :   s   
r+   c                   @  s   e Zd ZdZdS )DecodeErrorz;Raised when automatic decoding based on Content-Type fails.Nr   r   r   r   r   r0   E   s   r0   c                   @  s   e Zd ZdZdS )ProtocolErrorz>Raised when something unexpected happens mid-request/response.Nr   r   r   r   r   r1   I   s   r1   c                      s<   e Zd ZdZdddddd fdd	Zd
dddZ  ZS )MaxRetryErrora  Raised when the maximum number of retries is exceeded.

    :param pool: The connection pool
    :type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool`
    :param str url: The requested Url
    :param reason: The underlying error
    :type reason: :class:`Exception`

    Nr   r   zException | Noner   )r   r)   reasonr   c                   s,   || _ d| d|d}t ||| d S )NzMax retries exceeded with url: z (Caused by ))r3   r   r   )r   r   r)   r3   r   r   r   r   r   _   s    zMaxRetryError.__init__r    r!   c                 C  s   | j d | j| jffS r"   )r   r)   r3   r$   r   r   r   r%   h   s    zMaxRetryError.__reduce__)Nr&   r   r   r   r   r2   T   s    	r2   c                      s.   e Zd ZdZd
ddddd fdd	Z  ZS )HostChangedErrorz?Raised when an existing pool gets a request for a foreign host.   r   r   zRetry | intr   )r   r)   retriesr   c                   s$   d| }t  ||| || _d S )Nz'Tried to open a foreign host with url: )r   r   r7   )r   r   r)   r7   r   r   r   r   r   p   s    
zHostChangedError.__init__)r6   r   r   r   r   r   r'   r   r   r   r   r5   m   s    r5   c                   @  s   e Zd ZdZdS )TimeoutStateErrorz1Raised when passing an invalid state to a timeoutNr   r   r   r   r   r9   x   s   r9   c                   @  s   e Zd ZdZdS )TimeoutErrorzRaised when a socket timeout error occurs.

    Catching this error will catch both :exc:`ReadTimeoutErrors
    <ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`.
    Nr   r   r   r   r   r:   |   s   r:   c                   @  s   e Zd ZdZdS )ReadTimeoutErrorzFRaised when a socket timeout occurs while receiving data from a serverNr   r   r   r   r   r;      s   r;   c                   @  s   e Zd ZdZdS )ConnectTimeoutErrorz@Raised when a socket timeout occurs while connecting to a serverNr   r   r   r   r   r<      s   r<   c                      sJ   e Zd ZdZdddd fddZdd	d
dZedd	ddZ  ZS )NewConnectionErrorzHRaised when we fail to establish a new connection. Usually ECONNREFUSED.r   r   r   )connr   r   c                   s&   || _ || _t | d|  d S r   )r>   r   r   r   )r   r>   r   r   r   r   r      s    zNewConnectionError.__init__r    r!   c                 C  s   | j d | jffS r"   r#   r$   r   r   r   r%      s    zNewConnectionError.__reduce__c                 C  s   t jdtdd | jS )Nz\The 'pool' property is deprecated and will be removed in urllib3 v2.1.0. Use 'conn' instead.   )
stacklevel)warningswarnDeprecationWarningr>   r$   r   r   r   r      s    zNewConnectionError.pool)	r   r   r   r   r   r%   propertyr   r'   r   r   r   r   r=      s
   r=   c                      s8   e Zd ZdZdddd fddZdd	d
dZ  ZS )NameResolutionErrorz'Raised when host name resolution fails.r   r   zsocket.gaierror)hostr>   r3   c                   s0   d| d| d}|| _ || _t || d S )NzFailed to resolve 'z' (r4   )_host_reasonr   r   )r   rF   r>   r3   r   r   r   r   r      s    zNameResolutionError.__init__r    r!   c                 C  s   | j | jd | jffS r"   )r   rG   rH   r$   r   r   r   r%      s    zNameResolutionError.__reduce__r&   r   r   r   r   rE      s   rE   c                   @  s   e Zd ZdZdS )EmptyPoolErrorzCRaised when a pool runs out of connections and no more are allowed.Nr   r   r   r   r   rI      s   rI   c                   @  s   e Zd ZdZdS )FullPoolErrorzGRaised when we try to add a connection to a full pool in blocking mode.Nr   r   r   r   r   rJ      s   rJ   c                   @  s   e Zd ZdZdS )ClosedPoolErrorzCRaised when a request enters a pool after the pool has been closed.Nr   r   r   r   r   rK      s   rK   c                   @  s   e Zd ZdZdS )LocationValueErrorz<Raised when there is something wrong with a given URL input.Nr   r   r   r   r   rL      s   rL   c                      s(   e Zd ZdZddd fddZ  ZS )LocationParseErrorz=Raised when get_host or similar fails to parse the URL input.r   r   )locationr   c                   s    d| }t  | || _d S )NzFailed to parse: )r   r   rN   )r   rN   r   r   r   r   r      s    
zLocationParseError.__init__r8   r   r   r   r   rM      s   rM   c                      s&   e Zd ZdZdd fddZ  ZS )URLSchemeUnknownz2Raised when a URL input has an unsupported scheme.r   )schemec                   s    d| }t  | || _d S )NzNot supported URL scheme )r   r   rP   r   rP   r   r   r   r   r      s    
zURLSchemeUnknown.__init__r8   r   r   r   r   rO      s   rO   c                   @  s   e Zd ZdZdZdZdS )ResponseErrorzDUsed as a container for an error reason supplied in a MaxRetryError.ztoo many error responsesz&too many {status_code} error responsesN)r   r   r   r   GENERIC_ERRORSPECIFIC_ERRORr   r   r   r   rR      s   rR   c                   @  s   e Zd ZdZdS )SecurityWarningz0Warned when performing security reducing actionsNr   r   r   r   r   rU      s   rU   c                   @  s   e Zd ZdZdS )InsecureRequestWarningz/Warned when making an unverified HTTPS request.Nr   r   r   r   r   rV      s   rV   c                   @  s   e Zd ZdZdS )NotOpenSSLWarningz)Warned when using unsupported SSL libraryNr   r   r   r   r   rW      s   rW   c                   @  s   e Zd ZdZdS )SystemTimeWarningz0Warned when system time is suspected to be wrongNr   r   r   r   r   rX      s   rX   c                   @  s   e Zd ZdZdS )InsecurePlatformWarningzIWarned when certain TLS/SSL configuration is not available on a platform.Nr   r   r   r   r   rY      s   rY   c                   @  s   e Zd ZdZdS )DependencyWarningzc
    Warned when an attempt is made to import a module with missing optional
    dependencies.
    Nr   r   r   r   r   rZ      s   rZ   c                   @  s   e Zd ZdZdS )ResponseNotChunkedz;Response needs to be chunked in order to read it as chunks.Nr   r   r   r   r   r[      s   r[   c                   @  s   e Zd ZdZdS )BodyNotHttplibCompatiblez
    Body should be :class:`http.client.HTTPResponse` like
    (have an fp attribute which returns raw chunks) for read_chunked().
    Nr   r   r   r   r   r\      s   r\   c                   @  sB   e Zd ZU dZded< ded< ddddddZd	d
ddZdS )r   z
    Response length doesn't match expected Content-Length

    Subclass of :class:`http.client.IncompleteRead` to allow int value
    for ``partial`` to avoid creating large objects on streamed reads.
    intpartialexpectedr   )r^   r_   r   c                 C  s   || _ || _d S r"   r^   r_   )r   r^   r_   r   r   r   r     s    zIncompleteRead.__init__r   r!   c                 C  s   d| j | jf S )Nz/IncompleteRead(%i bytes read, %i more expected)r`   r$   r   r   r   __repr__  s    zIncompleteRead.__repr__N)r   r   r   r   r/   r   ra   r   r   r   r   r     s
   
r   c                   @  s0   e Zd ZdZddddddZdd	d
dZdS )InvalidChunkLengthz+Invalid chunk length in a chunked response.r   bytesr   )responselengthr   c                 C  s"   |  | _|j| _|| _|| _d S r"   )tellr^   length_remainingr_   rd   re   )r   rd   re   r   r   r   r     s    
zInvalidChunkLength.__init__r   r!   c                 C  s   d| j | jf S )Nz0InvalidChunkLength(got length %r, %i bytes read))re   r^   r$   r   r   r   ra   $  s    zInvalidChunkLength.__repr__N)r   r   r   r   r   ra   r   r   r   r   rb     s   rb   c                   @  s   e Zd ZdZdS )InvalidHeaderz(The header provided was somehow invalid.Nr   r   r   r   r   rh   +  s   rh   c                      s(   e Zd ZdZddd fddZ  ZS )ProxySchemeUnknownz1ProxyManager does not support the supplied schemez
str | Noner   )rP   r   c                   s6   |dkrd }|d u rd}nd| d}t  | d S )N	localhostz>Proxy URL had no scheme, should start with http:// or https://z!Proxy URL had unsupported scheme z , should use http:// or https://r   r   rQ   r   r   r   r   4  s    zProxySchemeUnknown.__init__r8   r   r   r   r   ri   /  s   ri   c                   @  s   e Zd ZdZdS )ProxySchemeUnsupportedz=Fetching HTTPS resources through HTTPS proxies is unsupportedNr   r   r   r   r   rl   @  s   rl   c                      s*   e Zd ZdZdddd fddZ  ZS )HeaderParsingErrorzNRaised by assert_header_parsing, but we convert it to a log.warning statement.zlist[MessageDefect]zbytes | str | Noner   )defectsunparsed_datar   c                   s"   |pd d|}t  | d S )NUnknownz, unparsed data: rk   )r   rn   ro   r   r   r   r   r   G  s    zHeaderParsingError.__init__r8   r   r   r   r   rm   D  s   rm   c                   @  s   e Zd ZdZdS )UnrewindableBodyErrorz9urllib3 encountered an error when trying to rewind a bodyNr   r   r   r   r   rq   N  s   rq   )A
__future__r   sockettypingrA   Zemail.errorsr   http.clientr   httplib_IncompleteReadTYPE_CHECKING
connectionr   connectionpoolr   rd   r   Z
util.retryr	   r,   r
   Warningr   tupleCallableobjectr    r   r(   r*   r+   r0   r1   ConnectionErrorr2   r5   r9   r:   r;   r<   r=   rE   rI   rJ   rK   
ValueErrorrL   rM   rO   rR   rU   rV   rW   rX   rY   rZ   r[   r\   rb   rh   AssertionErrorri   rl   rm   rq   r   r   r   r   <module>   sd   


