o
    }j6h9  ã                   @   sj   d Z dZdZg ZdZdZddlZg d¢Zdd	„ Z	d
d„ Z
edkr3ddlZG dd„ dejƒZe ¡  dS dS )zConverts an IRI to a URI.z!Joe Gregorio (joe@bitworking.org)zCopyright 2006, Joe Gregorioz1.0.0ÚMITé    N))é    iÿ×  )i à  iÿø  )i ù  iÏý  )iðý  iïÿ  )i   iýÿ )i   iýÿ )i   iýÿ )i   iýÿ )i   iýÿ )i   iýÿ )i   iýÿ )i   iýÿ )i  	 iýÿ	 )i  
 iýÿ
 )i   iýÿ )i   iýÿ )i   iýÿ )i  iýÿ )i   iýÿ )i   iýÿ c                 C   s\   | }t | ƒ}tD ]#\}}||k r |S ||kr+||kr+d dd„ |  d¡D ƒ¡} |S q|S )NÚ c                 S   s   g | ]}d | ‘qS )z%%%2X© )Ú.0Úor   r   ú_/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/httplib2/iri2uri.pyÚ
<listcomp>7   ó    zencode.<locals>.<listcomp>úutf-8)ÚordÚescape_rangeÚjoinÚencode)ÚcÚretvalÚiÚlowÚhighr   r   r   r   0   s   ý€ r   c                 C   s^   t | tƒr-tj | ¡\}}}}}| d¡ d¡}tj |||||f¡} d dd„ | D ƒ¡} | S )zžConvert an IRI to a URI. Note that IRIs must be
    passed in a unicode strings. That is, do not utf-8 encode
    the IRI before passing it into the function.Úidnar   r   c                 S   s   g | ]}t |ƒ‘qS r   )r   )r   r   r   r   r   r	   G   r
   ziri2uri.<locals>.<listcomp>)	Ú
isinstanceÚstrÚurllibÚparseÚurlsplitr   ÚdecodeÚ
urlunsplitr   )ÚuriÚschemeÚ	authorityÚpathÚqueryÚfragmentr   r   r   Úiri2uri<   s   
r#   Ú__main__c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚTestc                 C   s&   g d¢}|D ]
}|   |t|ƒ¡ qdS )z6Test that URIs are invariant under the transformation.)z"ftp://ftp.is.co.za/rfc/rfc1808.txtz#http://www.ietf.org/rfc/rfc2396.txtz)ldap://[2001:db8::7]/c=GB?objectClass?onezmailto:John.Doe@example.comz&news:comp.infosystems.www.servers.unixztel:+1-816-555-1212ztelnet://192.0.2.16:80/z3urn:oasis:names:specification:docbook:dtd:xml:4.1.2N)ÚassertEqualr#   )ÚselfÚ	invariantr   r   r   r   Ú	test_urisO   s   
ÿzTest.test_urisc                 C   s~   |   dtdƒ¡ |   dtdƒ¡ |   dtdƒ¡ |   dtdƒ¡ |   d	td
ƒ¡ |   d	ttd
ƒƒ¡ |  d	td
 d¡ƒ¡ dS )zFTest that the right type of escaping is done for each part of the URI.zhttp://xn--o3h.com/%E2%98%84u   http://â˜„.com/â˜„z%http://bitworking.org/?fred=%E2%98%84u   http://bitworking.org/?fred=â˜„z http://bitworking.org/#%E2%98%84u   http://bitworking.org/#â˜„z
#%E2%98%84u   #â˜„z/fred?bar=%E2%98%9A#%E2%98%84u   /fred?bar=â˜š#â˜„r   N)r&   r#   ÚassertNotEqualr   )r'   r   r   r   Útest_iri^   s6   þþþþ
þÿþzTest.test_iriN)Ú__name__Ú
__module__Ú__qualname__r)   r+   r   r   r   r   r%   N   s    r%   )Ú__doc__Ú
__author__Ú__copyright__Ú__contributors__Ú__version__Ú__license__Úurllib.parser   r   r   r#   r,   ÚunittestÚTestCaser%   Úmainr   r   r   r   Ú<module>   s   .Ï