ó
s
\c           @   s¬  d  d l  m Z d d l Z d d l Z d d l Z d d l Z d  d l m Z d Z d Z	 e j
 d  Z e j d d	 k r e Z e Z n  d
 e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d   Z d   Z d   Z d   Z d   Z d   Z e d  Z d   Z d   Z d   Z  d   Z! e d  Z" d   Z# d   Z$ d    Z% e& e d!  Z' e e e e d"  Z( e e e d#  Z) d S($   i   (   t   idnadatai’’’’N(   t   intranges_containi	   s   xn--u   [.ćļ¼ļ½”]i    i   t	   IDNAErrorc           B   s   e  Z d  Z RS(   s7    Base exception for all IDNA-encoding related problems (   t   __name__t
   __module__t   __doc__(    (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyR      s   t   IDNABidiErrorc           B   s   e  Z d  Z RS(   s=    Exception when bidirectional requirements are not satisfied (   R   R   R   (    (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyR      s   t   InvalidCodepointc           B   s   e  Z d  Z RS(   s>    Exception when a disallowed or unallocated codepoint is used (   R   R   R   (    (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyR      s   t   InvalidCodepointContextc           B   s   e  Z d  Z RS(   sE    Exception when the codepoint is not valid in the context it is used (   R   R   R   (    (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyR      s   c         C   sL   t  j t |    } | d k rH t  j t |    sH t d   qH n  | S(   Ni    s    Unknown character in unicodedata(   t   unicodedatat	   combiningt   unichrt   namet
   ValueError(   t   cpt   v(    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   _combining_class$   s
    c         C   s   t  t |   t j |  S(   N(   R   t   ordR    t   scripts(   R   t   script(    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt
   _is_script+   s    c         C   s   |  j  d  S(   Nt   punycode(   t   encode(   t   s(    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt	   _punycode.   s    c         C   s   d j  |   S(   Ns	   U+{0:04X}(   t   format(   R   (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   _unot1   s    c         C   s   t  |   d k r t St S(   Ni?   (   t   lent   Falset   True(   t   label(    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   valid_label_length5   s    c         C   s&   t  |   | r d n d k r" t St S(   Niž   iż   (   R   R   R   (   R   t   trailing_dot(    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   valid_string_length<   s    c   	      C   s  t  } xn t |  d  D]] \ } } t j |  } | d k r^ t d j t |   |    n  | d k r t } q q W| r | r t St j |  d  } | d k r± t } n0 | d k rĘ t  } n t d	 j t |      t  } t  } x
t |  d  D]ł \ } } t j |  } | rØ| d k rBt d j |    n  | d k rWt } n | d k rlt  } n  | d k rö| s| } q„| | k r„t d   q„qöqż | d k rĢt d j |    n  | d k rįt } qż | d k rż t  } qż qż W| st d   n  t S(   Ni   t    s3   Unknown directionality in label {0} at position {1}t   Rt   ALt   ANi    t   Ls>   First codepoint in label {0} must be directionality L, R or ALt   ENt   ESt   CSt   ETt   ONt   BNt   NSMsH   Invalid direction for codepoint at position {0} in a right-to-left labels2   Can not mix numeral types in a right-to-left labelsH   Invalid direction for codepoint at position {0} in a left-to-right labels0   Label ends with illegal codepoint directionality(   R#   R$   R%   (   R#   R$   (
   R#   R$   R%   R'   R(   R)   R*   R+   R,   R-   (   R#   R$   R'   R%   (   R%   R'   (   R&   R'   R(   R)   R*   R+   R,   R-   (   R&   R'   (   R   t	   enumerateR	   t   bidirectionalR   R   t   reprR   (	   R   t	   check_ltrt
   bidi_labelt   idxR   t	   directiont   rtlt   valid_endingt   number_type(    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt
   check_bidiC   sP    !						c         C   s0   t  j |  d  d d k r, t d   n  t S(   Ni    t   Ms0   Label begins with an illegal combining character(   R	   t   categoryR   R   (   R   (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   check_initial_combiner   s    c         C   sU   |  d d !d k r" t  d   n  |  d d k sB |  d d k rQ t  d   n  t S(	   Ni   i   s   --s4   Label has disallowed hyphens in 3rd and 4th positioni    t   -i’’’’s)   Label must not start or end with a hyphen(   R   R   (   R   (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   check_hyphen_ok   s
     c         C   s+   t  j d |   |  k r' t d   n  d  S(   Nt   NFCs%   Label must be in Normalization Form C(   R	   t	   normalizeR   (   R   (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt	   check_nfc   s    c         C   s±  t  |  |  } | d k rf| d k rO t t  |  | d   t k rO t Sn  t } xz t | d d d  D]b } t j j t  |  |   } | t  d  k r¦ ql n  | t  d  t  d  g k rl t } Pql ql W| sÜ t St } x} t | d t	 |    D]b } t j j t  |  |   } | t  d  k r6qü n  | t  d  t  d  g k rü t } Pqü qü W| S| d	 k r©| d k r„t t  |  | d   t k r„t Sn  t St Sd  S(
   Ni   i    i   i’’’’t   TR&   t   DR#   i   (
   R   R   t   _virama_combining_classR   R   t   rangeR    t   joining_typest   getR   (   R   t   post   cp_valuet   okt   it   joining_type(    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   valid_contextj   s<       c         C   s!  t  |  |  } | d k r d | k  o= t |   d k  n r} t  |  | d  d k r} t  |  | d  d k r} t Sn  t S| d k rĪ | t |   d k  rŹ t |   d k rŹ t |  | d d  St S| d k sę | d k r| d k rt |  | d d	  St S| d
 k roxQ |  D]I } | d k r6qn  t | d  sct | d  sct | d  rt SqWt Sd | k od k n rĘx4 |  D], } d t  |  k oµd k n rt SqWt Sd | k oŻd k n rx4 |  D], } d t  |  k od k n rét SqéWt Sd  S(   Ni·   i    i   il   iu  t   Greekió  iō  t   Hebrewiū0  u   ć»t   Hiraganat   Katakanat   Hani`  ii  iš  ił  (   R   R   R   R   R   (   R   RG   t	   exceptionRH   R   (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   valid_contextoĮ   s>    &4(-""c         C   sÓ  t  |  t t f  r' |  j d  }  n  t |   d k rH t d   n  t |   t |   t |   x\t	 |   D]N\ } } t
 |  } t | t j d  r§ qs qs t | t j d  r@yA t |  |  sż t d j t |  | d t |      n  WqĮt k
 r<t d j t |  | d t |      qĮXqs t | t j d	  rt |  |  sĮt d
 j t |  | d t |      qĮqs t d j t |  | d t |      qs Wt |   d  S(   Ns   utf-8i    s   Empty Labelt   PVALIDt   CONTEXTJs-   Joiner {0} not allowed at position {1} in {2}i   s?   Unknown codepoint adjacent to joiner {0} at position {1} in {2}t   CONTEXTOs0   Codepoint {0} not allowed at position {1} in {2}s0   Codepoint {0} at position {1} of {2} not allowed(   t
   isinstancet   bytest	   bytearrayt   decodeR   R   R@   R=   R;   R.   R   R   R    t   codepoint_classesRL   R   R   R   R0   R   RS   R   R8   (   R   RG   R   RH   (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   check_labelź   s0    


	)	)1/c         C   sŻ   yi |  j  d  }  y t |   Wn& t k
 rH t d j |     n Xt |   sd t d   n  |  SWn t k
 r| n X|  s t d   n  t |   }  t |   t |   }  t	 |  }  t |   sŁ t d   n  |  S(   Nt   asciis$   The label {0} is not a valid A-labels   Label too longs   No Input(
   R   t   ulabelR   R   R   t   UnicodeEncodeErrort   unicodeR\   R   t   _alabel_prefix(   R   (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   alabel
  s(    

c         C   s¬   t  |  t t f  sJ y |  j d  }  WqJ t k
 rF t |   |  SXn  |  j   }  |  j t  rx |  t	 t  }  n t |   |  j
 d  S|  j
 d  }  t |   |  S(   NR]   R   (   RW   RX   RY   R   R_   R\   t   lowert
   startswithRa   R   RZ   (   R   (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyR^   &  s    


c         C   s”  d d l  m  } d } yHx1t |   D]#\ } } t |  } | | d k  rS | n t j | | d f  d } | d }	 t |  d k r | d n d }
 |	 d k sŚ |	 d	 k r» | sŚ |	 d
 k rē | rē |
 d k rē | | 7} q& |
 d k	 r1|	 d k s$|	 d
 k r| s$|	 d	 k r1| r1| |
 7} q& |	 d k r& t    q& q& Wt j	 d |  SWn< t k
 rt
 d j t |  | d t |      n Xd S(   sB   Re-map the characters in the string according to UTS46 processing.i   (   t	   uts46datau    i   t   Zi   i   t   VRB   t   3R9   t   IR>   s0   Codepoint {0} not allowed at position {1} in {2}N(   Re   R.   R   t   bisectt   bisect_leftR   t   Nonet
   IndexErrorR	   R?   R   R   R   R0   (   t   domaint
   std3_rulest   transitionalRe   t   outputRG   t   chart
   code_pointt   uts46rowt   statust   replacement(    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   uts46_remap;  s0    
"c   	      C   s@  t  |  t t f  r' |  j d  }  n  | rB t |  | |  }  n  t } g  } | rf |  j d  } n t j |   } | s | d g k r t d   n  | d d k rŗ | d =t	 } n  x< | D]4 } t
 |  }  |  ré | j |   qĮ t d   qĮ W| r| j d  n  d j |  }  t |  |  s<t d   n  |  S(   NR]   t   .R"   s   Empty domaini’’’’s   Empty labels   Domain too long(   RW   RX   RY   RZ   Rw   R   t   splitt   _unicode_dots_reR   R   Rb   t   appendt   joinR!   (	   R   t   strictt   uts46Ro   Rp   R    t   resultt   labelsR   (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyR   W  s2    	c         C   s  t  |  t t f  r' |  j d  }  n  | rB t |  | t  }  n  t } g  } | sf t j |   } n |  j d  } | s | d g k r t d   n  | d s“ | d =t	 } n  x< | D]4 } t
 |  }  |  rć | j |   q» t d   q» W| r	| j d  n  d j |  S(   NR]   u   .R"   s   Empty domaini’’’’s   Empty labelu    (   RW   RX   RY   RZ   Rw   R   Rz   Ry   R   R   R^   R{   R|   (   R   R}   R~   Ro   R    R   R   R   (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyRZ   v  s,    
	(*   R"   R    Rj   R	   t   ret   syst	   intrangesR   RC   Ra   t   compileRz   t   version_infot   strR`   t   chrR   t   UnicodeErrorR   R   R   R   R   R   R   R   R   R!   R   R8   R;   R=   R@   RL   RS   R\   Rb   R^   R   Rw   R   RZ   (    (    (    s>   /data/av2000/b2b/venv/lib/python2.7/site-packages/idna/core.pyt   <module>   sB   							<					,)	 		