o ™­³_9ã@sjdZdZdZgZdZdZddlZgd¢Zdd „Z d d „Z e d kr3ddl Z Gd d„de j ƒZe  ¡dSdS)zConverts an IRI to a URI.z!Joe Gregorio (joe@bitworking.org)zCopyright 2006, Joe Gregorioz1.0.0ÚMITéN))é iÿ×)iàiÿø)iùiÏý)iðýiïÿ)iiýÿ)iiýÿ)iiýÿ)iiýÿ)iiýÿ)iiýÿ)iiýÿ)iiýÿ)i iýÿ )i iýÿ )i iýÿ )i iýÿ )i iýÿ )iiýÿ)iiýÿ)iiýÿcCs\|}t|ƒ}tD]#\}}||kr|S||kr+||kr+d dd„| d¡Dƒ¡}|Sq|S)NÚcSsg|]}d|‘qS)z%%%2X©)Ú.0Úorrú2/usr/lib/python3/dist-packages/httplib2/iri2uri.pyÚ 7ózencode..úutf-8)ÚordÚ escape_rangeÚjoinÚencode)ÚcÚretvalÚiÚlowÚhighrrrr0s ý€rcCs^t|tƒr-tj |¡\}}}}}| d¡ d¡}tj |||||f¡}d dd„|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 rcSsg|]}t|ƒ‘qSr)r)rrrrrr Gr ziri2uri..) Ú isinstanceÚstrÚurllibÚparseÚurlsplitrÚdecodeÚ urlunsplitr)ÚuriÚschemeÚ authorityÚpathÚqueryÚfragmentrrrÚiri2uri<s r#Ú__main__c@seZdZdd„Zdd„ZdS)ÚTestcCs&gd¢}|D] }| |t|ƒ¡qdS)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Ú invariantrrrrÚ test_urisOs ÿzTest.test_uriscCs~| dtdƒ¡| dtdƒ¡| dtdƒ¡| dtdƒ¡| d td ƒ¡| d ttd ƒƒ¡| d td  d ¡ƒ¡d S) 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=☚#☄r N)r&r#ÚassertNotEqualr)r'rrrÚtest_iri^s6þþþþ þÿþz Test.test_iriN)Ú__name__Ú __module__Ú __qualname__r)r+rrrrr%Ns r%)Ú__doc__Ú __author__Ú __copyright__Ú__contributors__Ú __version__Ú __license__Ú urllib.parserr rr#r,ÚunittestÚTestCaser%ÚmainrrrrÚs  .Ï