HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/httpx/__pycache__/_utils.cpython-310.pyc
o

���g] �@s�ddlmZddlZddlZddlZddlZddlmZddlm	Z	ej
r+ddlmZd+dd�Z
d,dd�Zd-d.dd�Zd-d/dd�Zd0dd�Zd1dd�Zd2d!d"�ZGd#d$�d$�Zd3d'd(�Zd3d)d*�ZdS)4�)�annotationsN)�
getproxies�)�
PrimitiveData��URL�valuer�return�strcCs,|durdS|durdS|durdSt|�S)z�
    Coerce a primitive data type into a string value.

    Note that we prefer JSON-style 'true'/'false' for boolean values here.
    T�trueF�falseN�)r
�r�r�7/usr/local/lib/python3.10/dist-packages/httpx/_utils.py�primitive_value_to_strsr�dict[str, str | None]cCs�t�}i}dD]}|�|�r"||}d|vr|nd|��||�d�<qdd�|�dd��d�D�}|D]C}|d	kr=iS|rvd|vrHd
||<q3t|�rTd
|d|��<q3t|�rad
|d|�d
�<q3|��dkrod
|d|��<q3d
|d|��<q3|S)z+Gets proxy information from the environment)�http�https�allz://zhttp://cSsg|]}|���qSr)�strip)�.0�hostrrr�
<listcomp>/sz+get_environment_proxies.<locals>.<listcomp>�nor
�,�*Nzall://zall://[�]�	localhostzall://*)r�get�split�is_ipv4_hostname�is_ipv6_hostname�lower)�
proxy_info�mounts�scheme�hostname�no_proxy_hostsrrr�get_environment_proxiess0
��
�r)�utf-8�str | bytes�encoding�bytescCst|t�r
|�|�S|S�N��
isinstancer
�encode�rr,rrr�to_bytesO�r3cCst|t�r|S|�|�Sr.)r0r
�decoder2rrr�to_strSr4r6�
match_type_of�
typing.AnyStrcCst|t�r|S|��Sr.r/)rr7rrr�to_bytes_or_strW�r9cCs0|d|dkrdkrnn|dd�S|S)Nr����"rrrrrr�unquote[s0r=�stream�
typing.Any�
int | NonecCsrz
|��}t�|�j}W|Sttfy8z|��}|�dtj�}|�|�WY|Sttfy7YYdSww)zs
    Given a file-like stream object, return its length in number of bytes
    without reading it into memory.
    rN)	�fileno�os�fstat�st_size�AttributeError�OSError�tell�seek�SEEK_END)r>�fd�length�offsetrrr�peek_filelike_length_s
����rMc@sPeZdZdZddd�Zddd�Zeddd��Zddd�Zddd�Z	ddd�Z
dS)�
URLPatterna�
    A utility class currently used for making lookups against proxy keys...

    # Wildcard matching...
    >>> pattern = URLPattern("all://")
    >>> pattern.matches(httpx.URL("http://example.com"))
    True

    # Witch scheme matching...
    >>> pattern = URLPattern("https://")
    >>> pattern.matches(httpx.URL("https://example.com"))
    True
    >>> pattern.matches(httpx.URL("http://example.com"))
    False

    # With domain matching...
    >>> pattern = URLPattern("https://example.com")
    >>> pattern.matches(httpx.URL("https://example.com"))
    True
    >>> pattern.matches(httpx.URL("http://example.com"))
    False
    >>> pattern.matches(httpx.URL("https://other.com"))
    False

    # Wildcard scheme, with domain matching...
    >>> pattern = URLPattern("all://example.com")
    >>> pattern.matches(httpx.URL("https://example.com"))
    True
    >>> pattern.matches(httpx.URL("http://example.com"))
    True
    >>> pattern.matches(httpx.URL("https://other.com"))
    False

    # With port matching...
    >>> pattern = URLPattern("https://example.com:1234")
    >>> pattern.matches(httpx.URL("https://example.com:1234"))
    True
    >>> pattern.matches(httpx.URL("https://example.com"))
    False
    �patternr
r	�NonecCsddlm}|rd|vrtd|�d|�d���||�}||_|jdkr%dn|j|_|jd	kr0dn|j|_|j|_|jr@|jd	krEd|_dS|j�d
�rat	�
|jdd��}t	�d|�d
��|_dS|j�d	�r}t	�
|jdd��}t	�d|�d
��|_dSt	�
|j�}t	�d|�d
��|_dS)Nrr�:zUProxy keys should use proper URL forms rather than plain scheme strings. Instead of "z", use "z://"rr
rz*.�z^.+\.�$z^(.+\.)?�^)�_urlsr�
ValueErrorrOr&r�port�
host_regex�
startswith�re�escape�compile)�selfrOr�url�domainrrr�__init__�s0���
zURLPattern.__init__�otherr�boolcCsV|jr|j|jkrdS|jr|jdur|j�|j�sdS|jdur)|j|jkr)dSdS)NFT)r&rrX�matchrW�r]rarrr�matches�s�
�zURLPattern.matches�tuple[int, int, int]cCs4|jdurdnd}t|j�}t|j�}|||fS)z�
        The priority allows URLPattern instances to be sortable, so that
        we can match from most specific to least specific.
        Nrr)rW�lenrr&)r]�
port_priority�
host_priority�scheme_priorityrrr�priority�s
zURLPattern.priority�intcCs
t|j�Sr.)�hashrO)r]rrr�__hash__�s
zURLPattern.__hash__cCs|j|jkSr.)rkrdrrr�__lt__�szURLPattern.__lt__r?cCst|t�o
|j|jkSr.)r0rNrOrdrrr�__eq__�r:zURLPattern.__eq__N)rOr
r	rP)rarr	rb)r	rf)r	rl)rarNr	rb)rar?r	rb)�__name__�
__module__�__qualname__�__doc__r`re�propertyrkrnrorprrrrrNxs
)



rNr'rbcC�0z
t�|�d�d�WdStyYdSw�N�/rFT)�	ipaddress�IPv4Addressr �	Exception�r'rrrr!����r!cCrvrw)ry�IPv6Addressr r{r|rrrr"�r}r")rrr	r
)r	r)r*)rr+r,r
r	r-)rr+r,r
r	r
)rr
r7r8r	r8)rr
r	r
)r>r?r	r@)r'r
r	rb)�
__future__rryrBrZ�typing�urllib.requestr�_typesr�
TYPE_CHECKINGrUrrr)r3r6r9r=rMrNr!r"rrrr�<module>s&

1



m