ó
âYc           @   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__(    (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/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   (    (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/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   (    (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/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   (    (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyR      s   c         C   s   t  j t |    S(   N(   t   unicodedatat	   combiningt   unichr(   t   cp(    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt   _combining_class$   s    c         C   s   t  t |   t j |  S(   N(   R   t   ordR    t   scripts(   R   t   script(    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt
   _is_script'   s    c         C   s   |  j  d  S(   Nt   punycode(   t   encode(   t   s(    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt	   _punycode*   s    c         C   s   d j  |   S(   Ns	   U+{0:04X}(   t   format(   R   (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt   _unot-   s    c         C   s   t  |   d k r t St S(   Ni?   (   t   lent   Falset   True(   t   label(    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt   valid_label_length1   s    c         C   s&   t  |   | r d n d k r" t St S(   Niţ   iý   (   R   R   R   (   R   t   trailing_dot(    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt   valid_string_length8   s    c   	      C   s  t  } xo t |  d  D]^ \ } } t j |  } | d k r^ t d j t |   |    n  | d k r t } Pq 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 rCt d j |    n  | d k rXt } n | d k rm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(    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt
   check_bidi?   sR    !						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   (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/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   (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/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   (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt	   check_nfc   s    c         C   s  t  |  |  } | d k r6| d k rO t t  |  | d   t k rO t Sn  t } xb t | d d d  D]J } t j j t  |  |   } | d k r  ql n  | d
 k rl t } Pql ql W| sÄ t St } xe t | d t	 |    D]J } t j j t  |  |   } | d k rqä n  | d k rä t } Pqä qä W| S| d	 k ry| d k rut t  |  | d   t k rut Sn  t St Sd  S(   Ni   i    i   i˙˙˙˙t   TR#   t   DR    i   (   R#   R?   (   R    R?   (
   R   R   t   _virama_combining_classR   R   t   rangeR    t   joining_typest   getR   (   R   t   post   cp_valuet   okt   it   joining_type(    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/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 rrxT |  D]L } | d k r6qn  t | d  rt | d  r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   RD   t	   exceptionRE   R   (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt   valid_contextož   s>    &4(0""c         C   s  t  |  t t f  r' |  j d  }  n  t |   d k rH t d   n  t |   t |   t |   xt	 |   D]\ } } t
 |  } t | t j d  r§ qs qs t | t j d  rý t |  |  s~t d j t |  | d t |      q~qs t | t j d  rS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   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:   R8   R+   R   R   R    t   codepoint_classesRI   R   R   R   R-   RP   R   R5   (   R   RD   R   RE   (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt   check_labelç   s&    


11/c         C   sÓ   y_ |  j  d  }  y t |   Wn t d j |     n Xt |   sZ t d   n  |  SWn t k
 rr 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   UnicodeErrort   unicodeRY   R   t   _alabel_prefix(   R   (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/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(   NRZ   R   (   RT   RU   RV   R   R\   RY   t   lowert
   startswithR^   R   RW   (   R   (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyR[     s    


c         C   s  d d l  m  } d } yFx/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	 r/|	 d k s"|	 d
 k r| s"|	 d	 k r/| r/| |
 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   VR?   t   3R6   t   IR;   s0   Codepoint {0} not allowed at position {1} in {2}N(   Rb   R+   R   t   bisectt   bisect_leftR   t   Nonet
   IndexErrorR	   R<   R   R   R   R-   (   t   domaint
   std3_rulest   transitionalRb   t   outputRD   t   chart
   code_pointt   uts46rowt   statust   replacement(    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt   uts46_remap3  s0    
"c   	      C   s4  t  |  t t f  r' |  j d  }  n  | rB t |  | |  }  n  t } g  } | rf |  j d  } n t j |   } x | r | d r | d =qx W| sŠ t d   n  | d d k rÉ | d =t	 } n  x! | D] } | j
 t |   qĐ W| r| j
 d  n  d j |  }  t |  |  s0t d   n  |  S(   NRZ   t   .i    s   Empty domaini˙˙˙˙R   s   Domain too long(   RT   RU   RV   RW   Rt   R   t   splitt   _unicode_dots_reR   R   t   appendR_   t   joinR   (	   R   t   strictt   uts46Rl   Rm   R   t   resultt   labelsR   (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyR   O  s0    	c         C   s
  t  |  t t f  r' |  j d  }  n  | rB t |  | t  }  n  t } g  } | sf t j |   } n |  j d  } x | r | d r | d =qx W| sŠ t d   n  | d sĂ | d =t	 } n  x! | D] } | j
 t |   qĘ W| rý | j
 d  n  d j |  S(   NRZ   u   .i    s   Empty domaini˙˙˙˙u    (   RT   RU   RV   RW   Rt   R   Rw   Rv   R   R   Rx   R[   Ry   (   R   Rz   R{   Rl   R   R|   R}   R   (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyRW   l  s*    
	(*   R   R    Rg   R	   t   ret   syst	   intrangesR   R@   R^   t   compileRw   t   version_infot   strR]   t   chrR   R\   R   R   R   R   R   R   R   R   R   R   R   R5   R8   R:   R=   RI   RP   RY   R_   R[   R   Rt   R   RW   (    (    (    sT   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/idna/core.pyt   <module>   sB   							=					,)			