o �J�h] �@s�ddlmZddlZddlZddlZddlZddlmZddlm Z ej r+ddl m Z d+d d �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�JC:\pinokio\api\whisper-webui.git\app\env\lib\site-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)Z proxy_info�mounts�scheme�hostnameZno_proxy_hostsrrr�get_environment_proxiess0  ��  �r'�utf-8� str | bytes�encoding�bytescCst|t�r |�|�S|S�N�� isinstancer �encode�rr*rrr�to_bytesO�r1cCst|t�r|S|�|�Sr,)r.r �decoder0rrr�to_strSr2r4� match_type_of� typing.AnyStrcCst|t�r|S|��Sr,r-)rr5rrr�to_bytes_or_strW�r7cCs0|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 ����rKc@sPeZdZdZddd�Zdd d �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 � |jd d��}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� ValueErrorrMr%r�port� host_regex� startswith�re�escape�compile)�selfrMr�url�domainrrr�__init__�s0  ���    zURLPattern.__init__�otherr�boolcCsV|jr |j|jkr dS|jr|jdur|j�|j�sdS|jdur)|j|jkr)dSdS)NFT)r%rrV�matchrU�r[r_rrr�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)rU�lenrr%)r[Z port_priorityZ host_priorityZscheme_priorityrrr�priority�s   zURLPattern.priority�intcCs t|j�Sr,)�hashrM)r[rrr�__hash__�s zURLPattern.__hash__cCs |j|jkSr,)rfrbrrr�__lt__�s zURLPattern.__lt__r=cCst|t�o |j|jkSr,)r.rLrMrbrrr�__eq__�r8zURLPattern.__eq__N)rMr r rN)r_rr r`)r rd)r rg)r_rLr r`)r_r=r r`) �__name__� __module__� __qualname__�__doc__r^rc�propertyrfrirjrkrrrrrLxs )   rLr&r`cC�0z t�|�d�d�WdStyYdSw�N�/rFT)� ipaddress� IPv4Addressr � Exception�r&rrrr!��  ��r!cCrqrr)rt� IPv6Addressr rvrwrrrr"�rxr")rrr r )r r)r()rr)r*r r r+)rr)r*r r r )rr r5r6r r6)rr r r )r<r=r r>)r&r r r`)� __future__rrtr@rX�typing�urllib.requestr�_typesr� TYPE_CHECKINGrSrrr'r1r4r7r;rKrLr!r"rrrr�<module>s&       1     m
Memory