
    &g9                         d Z dZdZg ZdZdZddlZg dZd Z	d	 Z
ed
k    r(ddlZ G d dej                  Z ej                     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                     | }t          |           }t          D ]M\  }}||k     r nA||k    r:||k    r4d                    d |                     d          D                       } nN|S )N c                     g | ]}d |z  S )z%%%2X ).0os     B/var/www/api/venv/lib/python3.11/site-packages/httplib2/iri2uri.py
<listcomp>zencode.<locals>.<listcomp>7   s    EEEagkEEE    utf-8)ordescape_rangejoinencode)cretvalilowhighs        r   r   r   0   s{    FAA!  	Ts77E88T		WWEE188G3D3DEEEFFFEMr   c                 P   t          | t                    rt          j                            |           \  }}}}}|                    d                              d          }t          j                            |||||f          } d                    d | D                       } | S )zConvert 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                 ,    g | ]}t          |          S r   )r   )r	   r   s     r   r   ziri2uri.<locals>.<listcomp>G   s    ...Qvayy...r   )	
isinstancestrurllibparseurlsplitr   decode
urlunsplitr   )urischeme	authoritypathqueryfragments         r   iri2urir(   <   s     #s 05;\5J5J35O5O2D%$$V,,33G<<	 l%%vy$x&PQQgg..#...//Jr   __main__c                       e Zd Zd Zd ZdS )Testc                 ^    g d}|D ]%}|                      |t          |                     &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"   s      r   	test_uriszTest.test_urisO   sM    	 	 	I ! 4 4  gcll33334 4r   c                 0   |                      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.   s    r   test_irizTest.test_iri^   s8   .899   7?@@   2:;;   \7<+@+@AAA/KLL   / STTUU   /GNNwWW     r   N)__name__
__module____qualname__r0   r3   r   r   r   r+   r+   N   s2        	4 	4 	4	 	 	 	 	r   r+   )__doc__
__author____copyright____contributors____version____license__urllib.parser   r   r   r(   r4   unittestTestCaser+   mainr   r   r   <module>rA      s     0
.       0	 	 	   zOOO, , , , ,x  , , ,\ HMOOOOOc r   