Ñò
#8Zc           @   s  d  Z  d d k Z d „  Z d „  Z d „  Z d „  Z d „  Z d Z d	 „  Z d
 „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d e i f d „  ƒ  YZ d e i f d „  ƒ  YZ d e i f d „  ƒ  YZ d e e i f d „  ƒ  YZ d e e i f d „  ƒ  YZ d „  Z d S(   sX    Codec for the Punicode encoding, as specified in RFC 3492

Written by Martin v. Löwis.
iÿÿÿÿNc         C   s}   g  } h  } x< |  D]4 } t  | ƒ d j  o | i | ƒ q d | | <q W| i ƒ  } | i ƒ  d i | ƒ i d ƒ | f S(   s    3.1 Basic code point segregationi€   i   t    t   ascii(   t   ordt   appendt   keyst   sortt   joint   encode(   t   strt   baset   extendedt   c(    (    s(   /usr/lib/python2.6/encodings/punycode.pyt	   segregate   s     
c         C   s<   d } x/ |  D]' } t  | ƒ | j  o | d 7} q q W| S(   s@   Return the length of str, considering only characters below max.i    i   (   R   (   R   t   maxt   resR   (    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   selective_len   s     c         C   ss   t  |  ƒ } x` | d 7} | | j o d S|  | } | | j o | d | f S| | j  o | d 7} q q d S(   s  Return a pair (index, pos), indicating the next occurrence of
    char in str. index is the position of the character considering
    only ordinals up to and including char, and pos is the position in
    the full string. index/pos is the starting position in the full
    string.i   iÿÿÿÿN(   iÿÿÿÿiÿÿÿÿ(   t   len(   R   t   chart   indext   post   lR   (    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   selective_find    s    

c         C   sÂ   d } g  } d } x© | D]¡ } d } } t  | ƒ } t |  | ƒ }	 |	 d | | }
 x[ t |  | | | ƒ \ } } | d j o Pn |
 | | 7}
 | i |
 d ƒ | } d }
 qY | } q W| S(   s   3.2 Insertion unsort codingi€   iÿÿÿÿi   i    (   R   R   R   R   (   R   R
   t   oldchart   resultt   oldindexR   R   R   R   t   curlent   delta(    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   insertion_unsort2   s&     
	
c         C   s:   d |  d | } | d j  o d S| d j o d S| S(   Ni$   i   i   (    (   t   jt   biasR   (    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   TH   s      t$   abcdefghijklmnopqrstuvwxyz0123456789c         C   s…   g  } d } xr t  | | ƒ } |  | j  o | i t |  ƒ | S| i t | |  | d | ƒ |  | d | }  | d 7} q d S(   s(   3.3 Generalized variable-length integersi    i$   i   N(   R   R   t   digits(   t   NR   R   R   t   t(    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   generate_generalized_integerP   s    !c         C   sv   | o |  d }  n |  d }  |  |  | 7}  d } x& |  d j o |  d }  | d 7} q6 W| d |  |  d } | S(   Ni¼  i   i    iÇ  i#   i$   i&   (    (   R   t   firstt   numcharst	   divisionsR   (    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   adapt]   s    
 
c         C   sr   g  } d } xV t  | ƒ D]H \ } } t | | ƒ } | i | ƒ t | | d j |  | d ƒ } q Wd i | ƒ S(   s   3.4 Bias adaptationiH   i    i   R    (   t	   enumerateR#   t   extendR'   R   (   t   baselent   deltasR   R   t   pointsR   t   s(    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   generate_integersl   s     $c         C   s]   t  |  ƒ \ } } | i d ƒ } t |  | ƒ } t t | ƒ | ƒ } | o | d | S| S(   NR   t   -(   R   R   R   R.   R   (   t   textR	   R
   R+   (    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   punycode_encodew   s    c   
      C   sI  d } d } d } x0y t  |  | ƒ } Wn8 t j
 o, | d j o t d ‚ n | d d f SX| d 7} d | j o
 d j n o | d } n\ d | j o
 d j n o | d	 } n0 | d j o t d
 |  | ƒ ‚ n | d f St | | ƒ }	 | | | 7} | |	 j  o | | f S| d |	 } | d 7} q d S(   s(   3.3 Generalized variable-length integersi    i   t   stricts   incomplete punicode stringiA   iZ   i0   i9   i   s    Invalid extended code point '%s'i$   N(   R   t
   IndexErrort   UnicodeErrort   NoneR   (
   R
   t   extposR   t   errorsR   t   wR   R   t   digitR"   (    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   decode_generalized_number‚   s2    

c   	      C   s  d } d } d } d } xú | t  | ƒ j  oæ t | | | | ƒ \ } } | d
 j o |  S| | d 7} | | t  |  ƒ d 7} | d j o. | d j o t d | ‚ n t d	 ƒ } n | t  |  ƒ d } |  |  t | ƒ |  | }  t | | d j t  |  ƒ ƒ } | } q W|  S(   s   3.2 Insertion unsort codingi€   iÿÿÿÿiH   i    i   iÿÿ R2   s   Invalid character U+%xt   ?N(   R   R:   R5   R4   R   t   unichrR'   (	   R	   R
   R7   R   R   R   R6   t   newposR   (    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   insertion_sort    s*     	c         C   sr   |  i  d ƒ } | d j o d } |  } n |  |  } |  | d } t | d | ƒ } | i ƒ  } t | | | ƒ S(   NR/   iÿÿÿÿR    i   R   (   t   rfindt   unicodet   upperR>   (   R0   R7   R   R	   R
   (    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   punycode_decode¹   s    

t   Codecc           B   s    e  Z d  d „ Z d  d „ Z RS(   R2   c         C   s   t  | ƒ } | t | ƒ f S(   N(   R1   R   (   t   selft   inputR7   R   (    (    s(   /usr/lib/python2.6/encodings/punycode.pyR   É   s    c         C   s=   | d j o t  d | ‚ n t | | ƒ } | t | ƒ f S(   NR2   t   replacet   ignores   Unsupported error handling (   s   stricts   replaces   ignore(   R4   RB   R   (   RD   RE   R7   R   (    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   decodeÍ   s    (   t   __name__t
   __module__R   RH   (    (    (    s(   /usr/lib/python2.6/encodings/punycode.pyRC   Ç   s   t   IncrementalEncoderc           B   s   e  Z e d  „ Z RS(   c         C   s
   t  | ƒ S(   N(   R1   (   RD   RE   t   final(    (    s(   /usr/lib/python2.6/encodings/punycode.pyR   Ô   s    (   RI   RJ   t   FalseR   (    (    (    s(   /usr/lib/python2.6/encodings/punycode.pyRK   Ó   s   t   IncrementalDecoderc           B   s   e  Z e d  „ Z RS(   c         C   s4   |  i  d j o t d |  i  ‚ n t | |  i  ƒ S(   NR2   RF   RG   s   Unsupported error handling (   s   stricts   replaces   ignore(   R7   R4   RB   (   RD   RE   RL   (    (    s(   /usr/lib/python2.6/encodings/punycode.pyRH   Ø   s    (   RI   RJ   RM   RH   (    (    (    s(   /usr/lib/python2.6/encodings/punycode.pyRN   ×   s   t   StreamWriterc           B   s   e  Z RS(    (   RI   RJ   (    (    (    s(   /usr/lib/python2.6/encodings/punycode.pyRO   Ý   s   t   StreamReaderc           B   s   e  Z RS(    (   RI   RJ   (    (    (    s(   /usr/lib/python2.6/encodings/punycode.pyRP   à   s   c           C   s@   t  i d d d t ƒ  i d t ƒ  i d t d t d t d t ƒ S(	   Nt   namet   punycodeR   RH   t   incrementalencodert   incrementaldecodert   streamwritert   streamreader(	   t   codecst	   CodecInfoRC   R   RH   RK   RN   RO   RP   (    (    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   getregentryå   s    	(   t   __doc__RW   R   R   R   R   R   R    R#   R'   R.   R1   R:   R>   RB   RC   RK   RN   RO   RP   RY   (    (    (    s(   /usr/lib/python2.6/encodings/punycode.pyt   <module>   s(   												