HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/pip/_vendor/requests/__pycache__/utils.cpython-37.pyc
B

L��g���@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZddlmZddlmZddlmZmZmZmZdd	lmZmZmZmZmZmZdd
lm Z!ddlm"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*dd
l+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1dZ2e�3�Z4ddd�Z5d�6e�7dedd�d��Z8ej9dk�rvdd�Z:dd�Z"dd�Z;dd �Z<dtd"d#�Z=d$d%�Z>d&d'�Z?ej@d(d)��ZAd*d+�ZBd,d-�ZCd.d/�ZDd0d1�ZEdud2d3�ZFd4d5�ZGd6d7�ZHd8d9�ZId:d;�ZJd<d=�ZKd>d?�ZLd@dA�ZMdBdC�ZNeOdD�ZPdEdF�ZQdGdH�ZRdIdJ�ZSdKdL�ZTdMdN�ZUdOdP�ZVej@dQdR��ZWdSdT�ZXdvdUdV�ZYdWdX�ZZdwdYdZ�Z[dxd\d]�Z\d^d_�Z]d`da�Z^db�_dc�Z`e`ddZae`deZbdfdg�Zcdhdi�Zddjdk�Zedldm�Zfdndo�Zgdpdq�Zhdrds�ZidS)yz�
requests.utils
~~~~~~~~~~~~~~

This module provides utility functions that are used within Requests
that are also useful for external consumption.
�N)�OrderedDict)�make_headers�	parse_url�)�certs)�__version__)�_HEADER_VALIDATORS_BYTE�_HEADER_VALIDATORS_STR�HEADER_VALIDATORS�to_native_string)�Mapping�
basestring�bytes�
getproxies�getproxies_environment�
integer_types)�parse_http_list)�proxy_bypass�proxy_bypass_environment�quote�str�unquote�urlparse�
urlunparse)�cookiejar_from_dict)�FileModeWarning�
InvalidHeader�
InvalidURL�UnrewindableBodyError)�CaseInsensitiveDict)z.netrc�_netrc�Pi�)�http�httpsz, z,\s*T)�accept_encodingzaccept-encoding�win32c	Cs�yddl}Wntk
r dSXy6|�|jd�}t|�|d�d�}|�|d�d}Wnttfk
rpdSX|rz|s~dS|�d�}xX|D]P}|dkr�d|kr�d	S|�	dd
�}|�	dd�}|�	d
d�}t
�||t
j�r�d	Sq�WdS)NrFz;Software\Microsoft\Windows\CurrentVersion\Internet SettingsZProxyEnableZ
ProxyOverride�;z<local>�.Tz\.�*z.*�?)
�winreg�ImportError�OpenKey�HKEY_CURRENT_USER�int�QueryValueEx�OSError�
ValueError�split�replace�re�match�I)�hostr*ZinternetSettingsZproxyEnableZ
proxyOverride�test�r9�>/tmp/pip-unpacked-wheel-hv55ucu3/pip/_vendor/requests/utils.py�proxy_bypass_registryLs2

r;cCst�rt|�St|�SdS)z�Return True, if the host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or the registry.
        N)rrr;)r7r9r9r:rpsrcCst|d�r|��}|S)z/Returns an internal sequence dictionary update.�items)�hasattrr<)�dr9r9r:�dict_to_sequence|s
r?c	Cs0d}d}t|d�rt|�}nft|d�r.|j}nTt|d�r�y|��}Wntjtfk
r^Yn$Xt�|�j}d|j	kr�t
�dt�t|d��ry|�
�}Wn tk
r�|dk	r�|}YnZXt|d��r|dk�ry&|�dd	�|�
�}|�|p�d�Wntk
�rd}YnX|dk�r"d}td||�S)
Nr�__len__�len�fileno�ba%Requests has determined the content-length for this request using the binary size of the file: however, the file has been opened in text mode (i.e. without the 'b' flag in the mode). This may lead to an incorrect content-length. In Requests 3.0, support will be removed for files in text mode.�tell�seek�)r=rArB�io�UnsupportedOperation�AttributeError�os�fstat�st_size�mode�warnings�warnrrDr0rE�max)�o�total_length�current_positionrBr9r9r:�	super_len�s@







rTFc	Cs>tj�d�}|dk	r|f}ndd�tD�}y�ddlm}m}d}xD|D]<}ytj�|�}Wntk
rndSXtj�	|�rF|}PqFW|dkr�dSt
|�}	d}
t|t�r�|
�
d�}
|	j�|
�d}y6||��|�}|r�|dr�dnd	}
||
|d
fSWn"|tfk
�r|�r�YnXWnttfk
�r8YnXdS)z;Returns the Requests tuple auth for a given url from netrc.ZNETRCNcss|]}d|��VqdS)z~/Nr9)�.0�fr9r9r:�	<genexpr>�sz!get_netrc_auth.<locals>.<genexpr>r)�NetrcParseError�netrc�:�asciirrF)rJ�environ�get�NETRC_FILESrYrX�path�
expanduser�KeyError�existsr�
isinstancer�decode�netlocr2�authenticatorsr0r+rI)�url�raise_errorsZ
netrc_fileZnetrc_locationsrXrY�
netrc_pathrV�loc�ri�splitstrr7r �login_ir9r9r:�get_netrc_auth�s@


rncCsBt|dd�}|r>t|t�r>|ddkr>|ddkr>tj�|�SdS)z0Tries to guess the filename of the given object.�nameNr�<����>)�getattrrcr
rJr_�basename)�objror9r9r:�guess_filenames&rvc	Cs�tj�|�r|Stj�|�\}}x8|rXtj�|�sXtj�|�\}}|sHPd�||g�}q"Wt�|�sh|St�|�}||��kr�|St	�
�}tj�||�d�d�}tj�|�s�t|��}|�|�
|��WdQRX|S)z�Replace nonexistent paths that look like they refer to a member of a zip
    archive with the location of an extracted copy of the target, or else
    just return the provided path unchanged.
    �/rqN)rJr_rbr2�join�zipfile�
is_zipfile�ZipFile�namelist�tempfile�
gettempdir�atomic_open�write�read)r_�archive�member�prefix�zip_file�tmp�extracted_pathZfile_handlerr9r9r:�extract_zipped_pathss&


r�c	csltjtj�|�d�\}}y.t�|d��}|VWdQRXt�||�Wn tk
rft�|��YnXdS)z-Write a file to the disk in an atomic fashion)�dir�wbN)	r}�mkstemprJr_�dirname�fdopenr3�
BaseException�remove)�filenameZtmp_descriptorZtmp_nameZtmp_handlerr9r9r:r,s
rcCs.|dkrdSt|ttttf�r&td��t|�S)aTake an object and test to see if it can be represented as a
    dictionary. Unless it can not be represented as such, return an
    OrderedDict, e.g.,

    ::

        >>> from_key_val_list([('key', 'val')])
        OrderedDict([('key', 'val')])
        >>> from_key_val_list('string')
        Traceback (most recent call last):
        ...
        ValueError: cannot encode objects that are not 2-tuples
        >>> from_key_val_list({'key': 'val'})
        OrderedDict([('key', 'val')])

    :rtype: OrderedDict
    Nz+cannot encode objects that are not 2-tuples)rcrr�boolr.r1r)�valuer9r9r:�from_key_val_list9s
r�cCs@|dkrdSt|ttttf�r&td��t|t�r8|��}t|�S)a�Take an object and test to see if it can be represented as a
    dictionary. If it can be, return a list of tuples, e.g.,

    ::

        >>> to_key_val_list([('key', 'val')])
        [('key', 'val')]
        >>> to_key_val_list({'key': 'val'})
        [('key', 'val')]
        >>> to_key_val_list('string')
        Traceback (most recent call last):
        ...
        ValueError: cannot encode objects that are not 2-tuples

    :rtype: list
    Nz+cannot encode objects that are not 2-tuples)	rcrrr�r.r1rr<�list)r�r9r9r:�to_key_val_listTs
r�cCs\g}xRt|�D]F}|dd�|dd�kr6dkrJnnt|dd��}|�|�qW|S)aParse 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.  Quotes are removed automatically after parsing.

    It basically works like :func:`parse_set_header` just that items
    may appear multiple times and case sensitivity is preserved.

    The return value is a standard :class:`list`:

    >>> parse_list_header('token, "quoted value"')
    ['token', 'quoted value']

    To create a header from the :class:`list` again, use the
    :func:`dump_header` function.

    :param value: a string with a list header.
    :return: :class:`list`
    :rtype: list
    Nrrq�")�_parse_list_header�unquote_header_value�append)r��result�itemr9r9r:�parse_list_headerrs(r�cCs|i}xrt|�D]f}d|kr$d||<q|�dd�\}}|dd�|dd�krXdkrlnnt|dd��}|||<qW|S)a^Parse lists of key, value pairs as described by RFC 2068 Section 2 and
    convert them into a python dict:

    >>> d = parse_dict_header('foo="is a fish", bar="as well"')
    >>> type(d) is dict
    True
    >>> sorted(d.items())
    [('bar', 'as well'), ('foo', 'is a fish')]

    If there is no value for a key it will be `None`:

    >>> parse_dict_header('key_without_value')
    {'key_without_value': None}

    To create a header from the :class:`dict` again, use the
    :func:`dump_header` function.

    :param value: a string with a dict header.
    :return: :class:`dict`
    :rtype: dict
    �=Nrrqr�)r�r2r�)r�r�r�ror9r9r:�parse_dict_header�s(r�cCs\|rX|d|dkr dkrXnn4|dd�}|rD|dd�dkrX|�dd��d	d�S|S)
z�Unquotes a header value.  (Reversal of :func:`quote_header_value`).
    This does not use the real unquoting but what browsers are actually
    using for quoting.

    :param value: the header value to unquote.
    :rtype: str
    rrqr�rNrFz\\�\z\")r3)r��is_filenamer9r9r:r��s
$r�cCs"i}x|D]}|j||j<q
W|S)z�Returns a key/value dictionary from a CookieJar.

    :param cj: CookieJar object to extract cookies from.
    :rtype: dict
    )r�ro)�cj�cookie_dict�cookier9r9r:�dict_from_cookiejar�s
r�cCs
t||�S)z�Returns a CookieJar from a key/value dictionary.

    :param cj: CookieJar to insert cookies into.
    :param cookie_dict: Dict of key/values to insert into CookieJar.
    :rtype: CookieJar
    )r)r�r�r9r9r:�add_dict_to_cookiejar�sr�cCsTt�dt�tjdtjd�}tjdtjd�}t�d�}|�|�|�|�|�|�S)zlReturns encodings from given content string.

    :param content: bytestring to extract encodings from.
    z�In requests 3.0, get_encodings_from_content will be removed. For more information, please see the discussion on issue #2266. (This warning should only appear once.)z!<meta.*?charset=["\']*(.+?)["\'>])�flagsz+<meta.*?content=["\']*;?charset=(.+?)["\'>]z$^<\?xml.*?encoding=["\']*(.+?)["\'>])rNrO�DeprecationWarningr4�compiler6�findall)�content�
charset_re�	pragma_re�xml_rer9r9r:�get_encodings_from_content�s
r�c
Cs�|�d�}|d��|dd�}}i}d}xh|D]`}|��}|r2|d}}|�d�}	|	dkr�|d|	��|�}||	dd��|�}|||��<q2W||fS)	z�Returns content type and parameters from given header

    :param header: string
    :return: tuple containing content type and dictionary of
         parameters
    r&rrNz"' Tr�rq)r2�strip�find�lower)
�header�tokens�content_type�params�params_dict�items_to_strip�param�keyr��index_of_equalsr9r9r:�_parse_content_type_headers



r�cCsP|�d�}|sdSt|�\}}d|kr4|d�d�Sd|kr@dSd|krLdSdS)	z}Returns encodings from given HTTP Header Dict.

    :param headers: dictionary to extract encoding from.
    :rtype: str
    zcontent-typeN�charsetz'"�textz
ISO-8859-1zapplication/jsonzutf-8)r]r�r�)�headersr�r�r9r9r:�get_encoding_from_headerss
r�ccsh|jdkr|EdHdSt�|j�dd�}x |D]}|�|�}|r0|Vq0W|jddd�}|rd|VdS)zStream decodes an iterator.Nr3)�errors�T)�final)�encoding�codecs�getincrementaldecoderrd)�iterator�r�decoder�chunk�rvr9r9r:�stream_decode_response_unicode3s




r�ccsLd}|dks|dkrt|�}x*|t|�krF||||�V||7}qWdS)z Iterate over slices of a string.rN)rA)�string�slice_length�posr9r9r:�iter_slicesDsr�cCsvt�dt�g}t|j�}|rJyt|j|�Stk
rH|�|�YnXyt|j|dd�St	k
rp|jSXdS)z�Returns the requested content back in unicode.

    :param r: Response object to get unicode content from.

    Tried:

    1. charset from content-type
    2. fall back and replace all unicode characters

    :rtype: str
    z�In requests 3.0, get_unicode_from_response will be removed. For more information, please see the discussion on issue #2266. (This warning should only appear once.)r3)r�N)
rNrOr�r�r�rr��UnicodeErrorr��	TypeError)r��tried_encodingsr�r9r9r:�get_unicode_from_responseNs
r�zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~c	Cs�|�d�}x�tdt|��D]�}||dd�}t|�dkr�|��r�ytt|d��}Wn$tk
rxtd|�d���YnX|tkr�|||dd�||<q�d||��||<qd||��||<qWd	�	|�S)
z�Un-escape any percent-escape sequences in a URI that are unreserved
    characters. This leaves all reserved, illegal and non-ASCII bytes encoded.

    :rtype: str
    �%rrrF�z"Invalid percent-escape sequence: '�'N�)
r2�rangerA�isalnum�chrr.r1r�UNRESERVED_SETrx)�uri�parts�i�h�cr9r9r:�unquote_unreserved{s
r�cCs:d}d}ytt|�|d�Stk
r4t||d�SXdS)z�Re-quote the given URI.

    This function passes the given URI through an unquote/quote cycle to
    ensure that it is fully and consistently quoted.

    :rtype: str
    z!#$%&'()*+,/:;=?@[]~z!#$&'()*+,/:;=?@[]~)�safeN)rr�r)r��safe_with_percent�safe_without_percentr9r9r:�requote_uri�sr�cCslt�dt�|��d}|�d�\}}t�dt�tt|����d}t�dt�|��d|@}||@||@kS)z�This function allows you to check if an IP belongs to a network subnet

    Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24
             returns False if ip = 192.168.1.1 and net = 192.168.100.0/24

    :rtype: bool
    z=Lrrw)�struct�unpack�socket�	inet_atonr2�dotted_netmaskr.)�ip�net�ipaddr�netaddr�bits�netmask�networkr9r9r:�address_in_network�s
r�cCs&ddd|>dA}t�t�d|��S)z�Converts mask from /xx format to xxx.xxx.xxx.xxx

    Example: if mask is 24 function returns 255.255.255.0

    :rtype: str
    l��r� z>I)r��	inet_ntoar��pack)�maskr�r9r9r:r��sr�cCs(yt�|�Wntk
r"dSXdS)z
    :rtype: bool
    FT)r�r�r0)�	string_ipr9r9r:�is_ipv4_address�s
r�cCs�|�d�dkr~yt|�d�d�}Wntk
r8dSX|dksJ|dkrNdSyt�|�d�d�Wq�tk
rzdSXndSdS)zV
    Very simple check of the cidr format in no_proxy variable.

    :rtype: bool
    rwrFr�rT)�countr.r2r1r�r�r0)�string_networkr�r9r9r:�
is_valid_cidr�sr�c	csT|dk	}|r"tj�|�}|tj|<z
dVWd|rN|dkrDtj|=n
|tj|<XdS)z�Set the environment variable 'env_name' to 'value'

    Save previous value, yield, and then restore the previous value stored in
    the environment variable 'env_name'.

    If 'value' is None, do nothingN)rJr\r])�env_namer��
value_changed�	old_valuer9r9r:�set_environ�s


r�c	
Cs,dd�}|}|dkr|d�}t|�}|jdkr2dS|r�dd�|�dd	��d
�D�}t|j�r�xz|D],}t|�r�t|j|�r�dSqb|j|krbdSqbWnD|j}|jr�|d|j��7}x&|D]}|j�|�s�|�|�r�dSq�Wt	d|��6yt
|j�}Wn ttj
fk
�rd}YnXWdQRX|�r(dSdS)
zL
    Returns whether we should bypass proxies or not.

    :rtype: bool
    cSstj�|�ptj�|���S)N)rJr\r]�upper)r�r9r9r:�	get_proxysz(should_bypass_proxies.<locals>.get_proxyN�no_proxyTcss|]}|r|VqdS)Nr9)rUr7r9r9r:rWsz(should_bypass_proxies.<locals>.<genexpr>� r��,�:F)r�hostnamer3r2r�r�r��port�endswithr�rr�r��gaierror)	rgrr�no_proxy_arg�parsed�proxy_ip�host_with_portr7�bypassr9r9r:�should_bypass_proxies�s<





rcCst||d�riSt�SdS)zA
    Return a dict of environment proxies.

    :rtype: dict
    )rN)rr)rgrr9r9r:�get_environ_proxies8srcCsv|pi}t|�}|jdkr.|�|j|�d��S|jd|j|jd|jdg}d}x|D]}||krX||}PqXW|S)z�Select a proxy for the url, if applicable.

    :param url: The url being for the request
    :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
    N�allz://zall://)rrr]�scheme)rg�proxies�urlparts�
proxy_keys�proxy�	proxy_keyr9r9r:�select_proxyDs

rc	Cst|dk	r|ni}|j}t|�j}|�d�}|��}|rpt||d�spt||d�}|�||�d��}|rp|�||�|S)a�This method takes proxy information from a request and configuration
    input to resolve a mapping of target proxies. This will consider settings
    such a NO_PROXY to strip proxy configurations.

    :param request: Request or PreparedRequest
    :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
    :param trust_env: Boolean declaring whether to trust environment configs

    :rtype: dict
    Nr)rr)rgrrr]�copyrr�
setdefault)	�requestr�	trust_envrgrr�new_proxies�environ_proxiesrr9r9r:�resolve_proxies^s

r�python-requestscCs|�dt��S)zO
    Return a string representing the default user agent.

    :rtype: str
    rw)r)ror9r9r:�default_user_agentysr!cCstt�tddd��S)z9
    :rtype: requests.structures.CaseInsensitiveDict
    z*/*z
keep-alive)z
User-AgentzAccept-Encoding�Accept�
Connection)rr!�DEFAULT_ACCEPT_ENCODINGr9r9r9r:�default_headers�s
r%c	
Cs�g}d}|�|�}|s|Sx�t�d|�D]�}y|�dd�\}}Wntk
r^|d}}YnXd|�d�i}xP|�d�D]B}y|�d�\}}Wntk
r�PYnX|�|�||�|�<qzW|�|�q(W|S)	z�Return a list of parsed link headers proxies.

    i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"

    :rtype: list
    z '"z, *<r&rr�rgz<> '"r�)r�r4r2r1r�)	r��links�
replace_chars�valrgr��linkr�r�r9r9r:�parse_header_links�s&
r*�r[rF�cCs�|dd�}|tjtjfkr dS|dd�tjkr6dS|dd�tjtjfkrRdS|�t�}|dkrhd	S|dkr�|ddd�tkr�d
S|ddd�tkr�dS|dkr�|dd�t	kr�d
S|dd�t	kr�dSdS)z
    :rtype: str
    N�zutf-32r,z	utf-8-sigrFzutf-16rzutf-8z	utf-16-berz	utf-16-lez	utf-32-bez	utf-32-le)
r��BOM_UTF32_LE�BOM_UTF32_BE�BOM_UTF8�BOM_UTF16_LE�BOM_UTF16_BEr��_null�_null2�_null3)�data�sample�	nullcountr9r9r:�guess_json_utf�s*
r9cCslt|�}|\}}}}}}}	|j}
|
s.||
}
}|r@d�||
g�}
|dkrL|}|dkrXd}t||
|d||	f�S)z�Given a URL that may or may not have a scheme, prepend the given scheme.
    Does not replace a present scheme with the one provided as an argument.

    :rtype: str
    �@Nr�)rrerxr)rg�
new_schemerr�authr7rr_�query�fragmentrer9r9r:�prepend_scheme_if_needed�s
r?c	CsBt|�}yt|j�t|j�f}Wnttfk
r<d}YnX|S)z{Given a url with authentication components, extract them into a tuple of
    username,password.

    :rtype: (str,str)
    )r�r�)rr�username�passwordrIr�)rgrr<r9r9r:�get_auth_from_url�s
rBcCs$|\}}t||d�t||d�dS)z�Verifies that header parts don't contain leading whitespace
    reserved characters, or return characters.

    :param header: tuple, in the format (name, value).
    rrN)�_validate_header_part)r�ror�r9r9r:�check_header_validitysrDcCsxt|t�rt|}n2t|t�r(t|}ntd|�d|�dt|�����|�|�st|dkr\dnd}td|�d|����dS)	Nz
Header part (z) from z# must be of type str or bytes, not rror�zSInvalid leading whitespace, reserved character(s), or returncharacter(s) in header z: )rcrr	rrr�typer5)r�Zheader_partZheader_validator_indexZ	validatorZheader_kindr9r9r:rCs




rCcCsFt|�\}}}}}}|s"||}}|�dd�d}t|||||df�S)zW
    Given a url remove the fragment and the authentication part.

    :rtype: str
    r:rrqr�)r�rsplitr)rgrrer_r�r=r>r9r9r:�
urldefragauth&s

rGcCs\t|jdd�}|dk	rPt|jt�rPy||j�WqXtk
rLtd��YqXXntd��dS)zfMove file pointer back to its recorded starting position
    so it can be read again on redirect.
    rENz;An error occurred when rewinding request body for redirect.z+Unable to rewind request body for redirect.)rs�bodyrc�_body_positionrr0r)�prepared_request�	body_seekr9r9r:�rewind_body7s

rL)F)F)N)T)r )j�__doc__r��
contextlibrGrJr4r�r��sysr}rNry�collectionsr�pip._vendor.urllib3.utilrrr�rr�_internal_utilsrr	r
r�compatrr
rrrrrr�rrrrrrr�cookiesr�
exceptionsrrrr�
structuresrr^�where�DEFAULT_CA_BUNDLE_PATH�
DEFAULT_PORTSrxr2r$�platformr;r?rTrnrvr��contextmanagerrr�r�r�r�r�r�r�r�r�r�r�r�r��	frozensetr�r�r�r�r�r�r�r�rrrrr!r%r*�encoder3r4r5r9r?rBrDrCrGrLr9r9r9r:�<module>s� $	
$	B
9%
 #

(<


	&