o
    Eem;                     @  s~  d dl mZ d dlZd dlZddlmZ ddlmZ dZe	dZ
e	d	Ze	d
ejejB ZdZdZdjeedZeedZg dZdZdddd eD  d Zde d Zde d e d ZdZe	dZe	de d Ze	de d Ze	de d Ze	dedd  d Ze	d e d! Z d"eeef Z!e	e!ejejB Z"e#d#Z$e#d$Z%e$e%B d%hB Z&e&d&d'hB Z'e'd(hB  Z(Z)G d)d* d*e*d*d+ej+e, fd,ej+e, fd-ej+e, fd.ej+e- fd/ej+e, fd0ej+e, fd1ej+e, fgZ.ej/dMd7d8Z0ej/dNd:d8Z0dOd<d8Z0dPd=d>Z1ej/dQd?d@Z2ej/dRdAd@Z2dSdBd@Z2dTdEdFZ3dUdHdIZ4dVdKdLZ5dS )W    )annotationsN   )LocationParseError   )to_str)httphttpsNz%[a-fA-F0-9]{2}z^(?:[a-zA-Z][a-zA-Z0-9+-]*:|/)zS^(?:([a-zA-Z][a-zA-Z0-9+.-]*):)?(?://([^\\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$z(?:[0-9]{1,3}\.){3}[0-9]{1,3}z[0-9A-Fa-f]{1,4}z(?:{hex}:{hex}|{ipv4}))hexipv4)r	   ls32)	z(?:%(hex)s:){6}%(ls32)sz::(?:%(hex)s:){5}%(ls32)sz%(?:%(hex)s)?::(?:%(hex)s:){4}%(ls32)sz2(?:(?:%(hex)s:)?%(hex)s)?::(?:%(hex)s:){3}%(ls32)sz6(?:(?:%(hex)s:){0,2}%(hex)s)?::(?:%(hex)s:){2}%(ls32)sz/(?:(?:%(hex)s:){0,3}%(hex)s)?::%(hex)s:%(ls32)sz'(?:(?:%(hex)s:){0,4}%(hex)s)?::%(ls32)sz&(?:(?:%(hex)s:){0,5}%(hex)s)?::%(hex)sz(?:(?:%(hex)s:){0,6}%(hex)s)?::zCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._\-~z(?:|c                 C  s   g | ]}|t  qS  )_subs).0xr   r   Q/var/www/bmteknikk.ddns.net/venv/lib/python3.10/site-packages/urllib3/util/url.py
<listcomp>4       r   )z(?:%25|%)(?:[z]|%[a-fA-F0-9]{2})+z\[z)?\]z!(?:[^\[\]%:/?#]|%[a-fA-F0-9]{2})*z!^(/[^?#]*)(?:\?([^#]*))?(?:#.*)?$^$(z)\]$z)^(%s|%s|%s)(?::0*?(|0|[1-9][0-9]{0,4}))?$zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~z!$&'()*+,;=:@/?c                      s   e Zd ZdZ							dd fddZedddZedddZedddZedddZ	edddZ
dddZ  ZS ) Urlz
    Data structure for representing an HTTP URL. Used as a return value for
    :func:`parse_url`. Both the scheme and host are normalized as they are
    both case-insensitive according to RFC 3986.
    Nscheme
str | Noneauthhostport
int | Nonepathqueryfragmentc              
     s@   |r| dsd| }|d ur| }t | |||||||S )Nr   )
startswithlowersuper__new__)clsr   r    r!   r"   r$   r%   r&   	__class__r   r   r*   d   s
   
zUrl.__new__returnc                 C     | j S )z@For backwards-compatibility with urlparse. We're nice like that.)r!   selfr   r   r   hostnamet   s   zUrl.hostnamestrc                 C  s&   | j pd}| jdur|d| j 7 }|S )z)Absolute path including the query string.r   Nr   )r$   r%   )r1   urir   r   r   request_uriy   s   

zUrl.request_uric                 C  s.   | j }| j}|du s|du r|S | d| S )z
        Authority component as defined in RFC 3986 3.2.
        This includes userinfo (auth), host and port.

        i.e.
            userinfo@host:port
        Nr   )r    netloc)r1   userinfor6   r   r   r   	authority   s
   	zUrl.authorityc                 C  s,   | j du rdS | jr| j  d| j S | j S )z
        Network location including host and port.

        If you need the equivalent of urllib.parse's ``netloc``,
        use the ``authority`` property instead.
        Nr   )r!   r"   r0   r   r   r   r6      s
   
z
Url.netlocc           	      C  s   | \}}}}}}}d}|dur||d 7 }|dur||d 7 }|dur'||7 }|dur3|dt | 7 }|dur;||7 }|durE|d| 7 }|durO|d| 7 }|S )a2  
        Convert self into a url

        This function should more or less round-trip with :func:`.parse_url`. The
        returned url may not be exactly the same as the url inputted to
        :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls
        with a blank port will have : removed).

        Example:

        .. code-block:: python

            import urllib3

            U = urllib3.util.parse_url("https://google.com/mail/")

            print(U.url)
            # "https://google.com/mail/"

            print( urllib3.util.Url("https", "username:password",
                                    "host.com", 80, "/path", "query", "fragment"
                                    ).url
                )
            # "https://username:password@host.com:80/path?query#fragment"
         Nz://r   r   r   #)r3   )	r1   r   r    r!   r"   r$   r%   r&   urlr   r   r   r;      s"   zUrl.urlc                 C  r/   N)r;   r0   r   r   r   __str__   s   zUrl.__str__)NNNNNNN)r   r   r    r   r!   r   r"   r#   r$   r   r%   r   r&   r   )r.   r   )r.   r3   )__name__
__module____qualname____doc__r*   propertyr2   r5   r8   r6   r;   r=   __classcell__r   r   r,   r   r   P   s*    	/r   r   r    r!   r"   r$   r%   r&   	componentr3   allowed_charstyping.Container[str]r.   c                 C     d S r<   r   rD   rE   r   r   r   _encode_invalid_chars      rI   Nonec                 C  rG   r<   r   rH   r   r   r   rI      rJ   r   c           	      C  s   | du r| S t | } tdd | \} }| dd}||dk}t }tdt|D ]7}|||d  }t|}|r?|dksI|d	k rN|	 |v rN||7 }q+|
dt|d
d  d
   q+|	 S )zfPercent-encodes a URI component without reapplying
    onto an already percent-encoded component.
    Nc                 S  s   |  d S )Nr   )groupupper)matchr   r   r   <lambda>   s    z'_encode_invalid_chars.<locals>.<lambda>zutf-8surrogatepass   %r   r      r   )r   _PERCENT_REsubnencodecount	bytearrayrangelenorddecodeextendr	   zfillrM   )	rD   rE   percent_encodings	uri_bytesis_percent_encodedencoded_componentibytebyte_ordr   r   r   rI      s$   *c                 C  s   |  d}g }|D ]}|dkrq	|dkr|| q	|r |  q	| dr2|r,|d r2|dd | dr<|d d|S )Nr   .z..r   r9   )z/.z/..)splitappendpopr'   insertendswithjoin)r$   segmentsoutputsegmentr   r   r   _remove_path_dot_segments  s   



ro   c                 C  rG   r<   r   r!   r   r   r   r   _normalize_host%     rq   c                 C  rG   r<   r   rp   r   r   r   rq   *  rr   c                 C  s   | rh|t v rht| }|rSt| }|rO|d\}}| || }|dr1|dkr1|dd  }n|dd  }t|t}| d | 	  d| | |d   S | 	 S t
| shtddd | dD d	S | S )
Nr   z%25   %   .c                 S  s   g | ]}t |qS r   )_idna_encode)r   labelr   r   r   r   F  r   z#_normalize_host.<locals>.<listcomp>re   ascii)_NORMALIZABLE_SCHEMES_IPV6_ADDRZ_RErN   _ZONE_ID_REsearchspanr'   rI   _UNRESERVED_CHARSr(   _IPV4_REr   rk   rf   )r!   r   is_ipv6rN   startendzone_idr   r   r   rq   /  s(   


&
namebytesc                 C  sv   |   s4zdd l}W n ty   tdd w z|j|  dddW S  |jy3   td|  dd w |  dS )Nr   z-Unable to parse URL without the 'idna' moduleT)strict
std3_ruleszName 'z' is not a valid IDNA labelrx   )isasciiidnaImportErrorr   rU   r(   	IDNAError)r   r   r   r   r   rv   L  s(   
rv   targetc                 C  sT   t | }|st| d| \}}t|t}|dur(t|t}|d| 7 }|S )zPercent-encodes a request target so that there are no invalid characters

    Pre-condition for this function is that 'target' must start with '/'.
    If that is the case then _TARGET_RE will always produce a match.
    z is not a valid request URINr   )
_TARGET_RErN   r   groupsrI   _PATH_CHARS_QUERY_CHARS)r   rN   r$   r%   encoded_targetr   r   r   _encode_target_  s   


r   r;   c              
   C  s  | st  S | }t| sd|  } zt|  \}}}}}|du p&| tv }|r-| }|rT|d\}}	}
|p:d}t	|
 \}}|rM|rMt
|t}|dkrSd}nd\}}}|durtt|}d|  krndksst|  t| nd}t||}|r|rt|}t
|t}|r|rt
|t}|r|rt
|t}W n ttfy } zt||d}~ww |s|dus|durd}nd}t |||||||dS )	a  
    Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is
    performed to parse incomplete urls. Fields not provided will be None.
    This parser is RFC 3986 and RFC 6874 compliant.

    The parser logic and helper functions are based heavily on
    work done in the ``rfc3986`` module.

    :param str url: URL to parse into a :class:`.Url` namedtuple.

    Partly backwards-compatible with :mod:`urllib.parse`.

    Example:

    .. code-block:: python

        import urllib3

        print( urllib3.util.parse_url('http://google.com/mail/'))
        # Url(scheme='http', host='google.com', port=None, path='/mail/', ...)

        print( urllib3.util.parse_url('google.com:80'))
        # Url(scheme=None, host='google.com', port=80, path=None, ...)

        print( urllib3.util.parse_url('/foo?bar'))
        # Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...)
    z//Nr   r9   )NNNr   i  )r   r    r!   r"   r$   r%   r&   )r   
_SCHEME_REr|   _URI_RErN   r   r(   ry   
rpartition_HOST_PORT_RErI   _USERINFO_CHARSintr   rq   ro   r   r   _FRAGMENT_CHARS
ValueErrorAttributeError)r;   
source_urlr   r8   r$   r%   r&   normalize_urir    _	host_portr!   r"   port_inter   r   r   	parse_urlq  sl   







r   )rD   r3   rE   rF   r.   r3   )rD   rK   rE   rF   r.   rK   )rD   r   rE   rF   r.   r   )r$   r3   r.   r3   )r!   rK   r   r   r.   rK   )r!   r3   r   r   r.   r3   )r!   r   r   r   r.   r   )r   r3   r.   r   )r   r3   r.   r3   )r;   r3   r.   r   )6
__future__r   retyping
exceptionsr   utilr   ry   compilerS   r   UNICODEDOTALLr   	_IPV4_PAT_HEX_PATformat	_LS32_PATr   _variations_UNRESERVED_PATrk   	_IPV6_PAT_ZONE_ID_PAT_IPV6_ADDRZ_PAT_REG_NAME_PATr   r   _IPV6_RErz   _BRACELESS_IPV6_ADDRZ_REr{   _HOST_PORT_PATr   setr~   _SUB_DELIM_CHARSr   r   r   r   
NamedTupleOptionalr3   r   r   overloadrI   ro   rq   rv   r   r   r   r   r   r   <module>   s    


	


 

$


