o
    	hE                     @  s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZ zddlZdZW n ey9   d	ZY nw d
dlmZ eeddZeeZG dd deZdd Zdd ZeZ		dddZdddZdddZdd ZdS )zURL Utilities.    )annotations)Mapping)partial)
NamedTuple)	parse_qslquoteunquoteurlparseNTF   )
get_logger )safec                   @  sJ   e Zd ZU dZded< ded< ded< ded< ded< ded	< d
ed< dS )urlpartsz*Named tuple representing parts of the URL.strschemehostnameintportusernamepasswordpathr   queryN)__name__
__module____qualname____doc____annotations__ r   r   Q/var/www/html/optinet_system/venv/lib/python3.10/site-packages/kombu/utils/url.pyr      s   
 r   c           
   	   C  s   t | \}}}}}}}|rTdd | D }|D ];}	|	dkr)||	  dk||	< n|	dkr@t||	 ||	< ||	 du r@td d|vrHi |d< ||	 |d |	< ||	= qtd
||||||d	|S )z%Parse URL into mapping of components.c                 S  s   g | ]	}| d r|qS )ssl_)
startswith).0keyr   r   r   
<listcomp>(   s    zparse_url.<locals>.<listcomp>ssl_check_hostnamefalsessl_cert_reqsNz%Defaulting to insecure SSL behaviour.ssl)	transportr   r   useridr   virtual_hostr   )
_parse_urlkeyslowerparse_ssl_cert_reqsloggerwarningdict)
urlr   hostr   userr   r   r   r,   r"   r   r   r   	parse_url#   s(   
r5   c              
   C  s   t | j}| t|d d }t d| }|jpd}|r(|d dkr(|dd n|}t|t|jp1dp4d|jt|jp;dp>dt|j	pCdpFdt|pJdpMdt
t|jS )z5Parse URL into :class:`urlparts` tuple of components.   Nzhttp://r   r   /   )r	   r   lenr   r   r   r   r   r   r   r1   r   r   )r2   r   
schemelesspartsr   r   r   r   url_to_parts<   s   

 r<   **c	           
      C  s   |  dg}	|s
|r2|r|	 t| |r-|r$|	|rd|gndg n	|	dt|g |	 d |	 |r:t|nd |rF|	d|g |	d|g ddd |	D S )z"Generate URL from component parts.://:@r   r7   c                 s  s    | ]	}|rt |V  qd S )N)r   )r!   partr   r   r   	<genexpr>e   s    zas_url.<locals>.<genexpr>)append	safequoteextendjoin)
r   r3   r   r4   r   r   r   sanitizemaskr;   r   r   r   as_urlS   s   
rI   c                 C  s   t t| d|dS )z)Return copy of URL with password removed.T)rG   rH   )rI   r+   r2   rH   r   r   r   sanitize_urlh   s   rK   c                 C  s    t | trd| v rt| |S | S )z-Sanitize url, or do nothing if url undefined.r>   )
isinstancer   rK   rJ   r   r   r   maybe_sanitize_urln   s   
rM   c                 C  s.   t rtjtjtjtjtjtjd}||  S dS )zMGiven the query parameter for ssl_cert_reqs, return the SSL constant or None.)CERT_REQUIREDCERT_OPTIONAL	CERT_NONErequiredoptionalnoneN)ssl_availabler'   rN   rO   rP   )query_valuequery_value_to_constantr   r   r   r.   v   s   r.   )NNNNNNFr=   )r=   )r   
__future__r   collections.abcr   	functoolsr   typingr   urllib.parser   r   r   r	   r'   rT   ImportErrorlogr   rD   r   r/   r   r5   r<   r+   rI   rK   rM   r.   r   r   r   r   <module>   s2    


