ó
8úMc           @   sÌ   d  Z  d Z d Z g  Z d Z d Z d Z d d l Z d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ dA dB dC dD dE dF dG dH g Z d0 „  Z	 d1 „  Z
 e d2 k rÈ d d l Z d3 e j f d4 „  ƒ  YZ e j ƒ  n  d S(I   s%   
iri2uri

Converts an IRI to a URI.

s!   Joe Gregorio (joe@bitworking.org)s   Copyright 2006, Joe Gregorios   1.0.0t   MITt   
iÿÿÿÿNi    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  |  ƒ } xu t D]m \ } } | | k  r5 Pn  | | k r | | k r d j g  |  j d ƒ D] } d t  | ƒ ^ qc ƒ } Pq q W| S(   Nt    s   utf-8s   %%%2X(   t   ordt   escape_ranget   joint   encode(   t   ct   retvalt   it   lowt   hight   o(    (    s4   /usr/lib/python2.7/dist-packages/httplib2/iri2uri.pyR   5   s    5c         C   s‰   t  |  t ƒ r… t j |  ƒ \ } } } } } | j d ƒ } t j | | | | | f ƒ }  d j g  |  D] } t | ƒ ^ qg ƒ }  n  |  S(   sŸ   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.t   idnaR   (   t
   isinstancet   unicodet   urlparset   urlsplitR   t
   urlunsplitR   (   t   urit   schemet	   authorityt   patht   queryt   fragmentR   (    (    s4   /usr/lib/python2.7/dist-packages/httplib2/iri2uri.pyt   iri2uriA   s    +t   __main__t   Testc           B   s   e  Z d  „  Z d „  Z RS(   c         C   sI   d d d d d d d d g } x$ | D] } |  j  | t | ƒ ƒ q% Wd	 S(
   s6   Test that URIs are invariant under the transformation.u"   ftp://ftp.is.co.za/rfc/rfc1808.txtu#   http://www.ietf.org/rfc/rfc2396.txtu)   ldap://[2001:db8::7]/c=GB?objectClass?oneu   mailto:John.Doe@example.comu&   news:comp.infosystems.www.servers.unixu   tel:+1-816-555-1212u   telnet://192.0.2.16:80/u3   urn:oasis:names:specification:docbook:dtd:xml:4.1.2N(   t   assertEqualR   (   t   selft	   invariantR   (    (    s4   /usr/lib/python2.7/dist-packages/httplib2/iri2uri.pyt	   test_urisT   s    	c         C   s­   |  j  d t d ƒ ƒ |  j  d t d ƒ ƒ |  j  d t d ƒ ƒ |  j  d t d ƒ ƒ |  j  d	 t d
 ƒ ƒ |  j  d	 t t d
 ƒ ƒ ƒ |  j d	 t d
 j d ƒ ƒ ƒ d S(   sG    Test that the right type of escaping is done for each part of the URI.s   http://xn--o3h.com/%E2%98%84u   http://â˜„.com/â˜„s%   http://bitworking.org/?fred=%E2%98%84u   http://bitworking.org/?fred=â˜„s    http://bitworking.org/#%E2%98%84u   http://bitworking.org/#â˜„s
   #%E2%98%84u   #â˜„s   /fred?bar=%E2%98%9A#%E2%98%84u   /fred?bar=â˜š#â˜„s   utf-8N(   R   R   t   assertNotEqualR   (   R   (    (    s4   /usr/lib/python2.7/dist-packages/httplib2/iri2uri.pyt   test_irib   s    (   t   __name__t
   __module__R   R!   (    (    (    s4   /usr/lib/python2.7/dist-packages/httplib2/iri2uri.pyR   R   s   	(   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   iýÿ (   t   __doc__t
   __author__t   __copyright__t   __contributors__t   __version__t   __license__t   __history__R   R   R   R   R"   t   unittestt   TestCaseR   t   main(    (    (    s4   /usr/lib/python2.7/dist-packages/httplib2/iri2uri.pyt   <module>   sB   			