Zճc9dZdZdZgZdZdZddlZgdZdZ d Z e d k(r+ddl Z Gd d e jZe jyy) zConverts an IRI to a URI.z!Joe Gregorio (joe@bitworking.org)zCopyright 2006, Joe Gregorioz1.0.0MITN))i)ii)ii)ii)ii)ii)ii)ii)ii)ii)ii)ii)i i )i i )i i )i i )i i )ii)ii)iic|}t|}tD]L\}}||kr|S||k\s||ksdj|jdDcgc]}d|z c}}|S|Scc}w)Nutf-8z%%%2X)ord escape_rangejoinencode)cretvalilowhighos 2/usr/lib/python3/dist-packages/httplib2/iri2uri.pyr r 0s~ F AA! T s7  M 8T WW188G3DEagkEFF  M  MFs A% cRt|trtjj |\}}}}}|j dj d}tjj|||||f}dj|Dcgc] }t |c}}|Scc}w)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.idnarr) isinstancestrurllibparseurlsplitr decode urlunsplitr )urischeme authoritypathqueryfragmentr s riri2urir"<s#s5;\\5J5J35O2D%$$V,33G< ll%%vy$x&PQgg#.Qvay./ J/s B$__main__ceZdZdZdZy)TestcPgd}|D]}|j|t|y)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?onezmailto:John.Doe@example.comz&news:comp.infosystems.www.servers.unixztel:+1-816-555-1212ztelnet://192.0.2.16:80/z3urn:oasis:names:specification:docbook:dtd:xml:4.1.2N) assertEqualr")self invariantrs r test_uriszTest.test_urisOs. I! 4  gcl3 4c|jdtd|jdtd|jdtd|jdtd|jd td |jd ttd |jd td jd y ) zFTest that the right type of escaping is done for each part of the URI.zhttp://xn--o3h.com/%E2%98%84uhttp://☄.com/☄z%http://bitworking.org/?fred=%E2%98%84uhttp://bitworking.org/?fred=☄z http://bitworking.org/#%E2%98%84uhttp://bitworking.org/#☄z #%E2%98%84u#☄z/fred?bar=%E2%98%9A#%E2%98%84u/fred?bar=☚#☄rN)r'r"assertNotEqualr )r(s rtest_iriz Test.test_iri^s   .89    7?@    2:;    \7<+@ A   /KL    / STU    /GNNwW r+N)__name__ __module__ __qualname__r*r.r+rr%r%Ns  4 r+r%)__doc__ __author__ __copyright____contributors__ __version__ __license__ urllib.parserr r r"r/unittestTestCaser%mainr2r+rr=si 0 .    0   z,x  ,\HMMOcr+