
    (ph9                         S r SrSr/ rSrSrSSKr/ SQrS r	S	 r
\S
:X  a+  SSKr " S S\R                  5      r\R                  " 5         gg)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                     U n[        U 5      n[         HP  u  p4X#:  a    U$ X#:  d  M  X$::  d  M  SR                  U R                  S5       Vs/ s H  nSU-  PM
     sn5      n  U$    U$ s  snf )N utf-8z%%%2X)ordescape_rangejoinencode)cretvalilowhighos         C/var/www/html/venv/lib/python3.13/site-packages/httplib2/iri2uri.pyr   r   0   sw    FAA!	7 M 8	WW188G3DE3Dagk3DEFFM " M Fs   A*
c                 Z   [        U [        5      (       a  [        R                  R	                  U 5      u  pp4nUR                  S5      R                  S5      n[        R                  R                  XX4U45      n SR                  U  Vs/ s H  n[        U5      PM     sn5      n U $ s  snf )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   )	
isinstancestrurllibparseurlsplitr   decode
urlunsplitr
   )urischeme	authoritypathqueryfragmentr   s          r   iri2urir"   <   s     #s5;\\5J5J35O2D$$V,33G<	 ll%%v$x&PQgg#.#Qvay#./J /s   
B(__main__c                        \ rS rSrS rS rSrg)TestN   c                 T    / SQnU H  nU R                  U[        U5      5        M      g)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_urisTest.test_urisO   s)    	I !  gcl3 !    c                    U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S	[        S
5      5        U R                  S	[        [        S
5      5      5        U R                  S	[        S
R                  S5      5      5        g)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_iriTest.test_iri^   s    .89 7?@ 2:; \7<+@A/KL / STU /GNNwWr-    N)__name__
__module____qualname____firstlineno__r+   r0   __static_attributes__r2   r-   r   r%   r%   N   s    	4	r-   r%   )__doc__
__author____copyright____contributors____version____license__urllib.parser   r	   r   r"   r3   unittestTestCaser%   mainr2   r-   r   <module>rB      sg    0
.  0	 z,x   ,\ MMOc r-   