ó
Xé?_c           @   s™  d  Z  d d l Z d d l Z d d l Z d d l Z e j dA k r° e Z e Z	 e
 Z e Z e e
 f Z d d „ Z d d „ Z d d „ Z d d	 l m Z d d
 l m Z n€ e Z e
 Z	 e Z e	 Z e Z d d „ Z d d „ Z d d „ Z y d d	 l m Z Wn! e k
 r)d d	 l m Z n Xe Z d „  Z y d d l m Z Wn! e k
 rpd d l m Z n Xd d „ Z y
 e Z Wn e k
 r£d „  Z n Xy
 e  Z  Wn e k
 rÊd „  Z  n Xy\ d d l! m" Z" m# Z# d d l! m$ Z$ m% Z% d d l& m' Z' m( Z( d d l& m) Z) m* Z* Wns e k
 rœd d l+ m" Z" d d l, m# Z# m( Z( d d l, m$ Z$ m% Z% d d l, m' Z' d d l- m) Z) m* Z* n Xy d d l m. Z/ Wn! e k
 rÔd d l0 m. Z/ n Xy e1 j2 d „  Z2 d „  Z3 Wn# e4 k
 rd „  Z2 d „  Z3 n Xy e1 j5 d  „  Z5 d! „  Z6 Wn# e4 k
 rZd" „  Z5 d# „  Z6 n Xy e1 j7 d$ „  Z7 d% „  Z8 Wn# e4 k
 rd& „  Z7 d' „  Z8 n Xy d d l9 Z9 Wn e k
 rÍd d l: Z9 n XyV d d( l; m< Z< m= Z= d d) l> m? Z? m@ Z@ mA ZA d d* l> mB ZB d d+ lC mD ZD Wnc e k
 r‰d d( lE m< Z< m= Z= d d) lF m? Z? m@ Z@ mA ZA d d* lF mB ZB d d+ lG mD ZD n Xe rÁy d d, lF mH ZH Wqïe k
 r½d ZH qïXn. y d d, l> mH ZH Wn e k
 rîd ZH n Xy
 eJ ZJ Wn e k
 reK ZJ n Xd d l Z eL e jM d- ƒ rFd. „  ZN d/ „  ZO n d0 „  ZN d1 „  ZO y  d d2 lP mQ ZQ d d3 „ ZR Wn! e k
 r›d d2 lS mQ ZR n Xy  d d l! m' ZT d4 d5 „ ZU Wn- e k
 rëd d l, m' ZT d4 d6 „ ZU n Xzš y. d d lV ZW eW jX ƒ  jY ZZ eW j[ ƒ  j\ Z] Wne e k
 r„e j dB k rid d lW ZW eW jX ƒ  jY ZZ eW j[ ƒ  j\ Z] q…d ZW d9 „  ZZ d: „  Z] n XWd eW r¡e r¡d; „  Z^ n e] Z^ Xy d d l_ Z` Wn e k
 r×d d l` Z` n Xd d la Za d< „  Zb y d d= lc md Ze Wn! e k
 r$d d= lf md Ze n Xy
 eg Zg Wn e k
 rKd> „  Zg n Xe j dC k rpe jh Zh e ji Zi n e jj Zh e jk Zi d? dD d@ „  ƒ  YZl d S(E   sí  Compatibility code for using CherryPy with various versions of Python.

CherryPy 3.2 is compatible with Python versions 2.3+. This module provides a
useful abstraction over the differences between Python versions, sometimes by
preferring a newer idiom, sometimes an older one, and sometimes a custom one.

In particular, Python 2 uses str and '' for byte strings, while Python 3
uses str and '' for unicode strings. We will call each of these the 'native
string' type for each version. Because of this major difference, this module
provides new 'bytestr', 'unicodestr', and 'nativestr' attributes, as well as
two functions: 'ntob', which translates native strings (of type 'str') into
byte strings regardless of Python version, and 'ntou', which translates native
strings to unicode strings. This also provides a 'BytesIO' name for dealing
specifically with bytes, and a 'StringIO' name for dealing with native strings.
It also provides a 'base64_decode' function with native strings as input and
output.
iÿÿÿÿNi   i    s
   ISO-8859-1c         C   s   t  |  ƒ |  j | ƒ S(   sW   Return the given native string as a byte string in the given
        encoding.
        (   t   assert_nativet   encode(   t   nt   encoding(    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   ntob   s    
c         C   s   t  |  ƒ |  S(   s\   Return the given native string as a unicode string with the given
        encoding.
        (   R    (   R   R   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   ntou&   s    
c         C   s    t  |  t ƒ r |  j | ƒ S|  S(   sA   Return the given string as a native string in the given encoding.(   t
   isinstancet   bytest   decode(   R   R   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   tonative.   s    (   t   StringIO(   t   BytesIOc         C   s   t  |  ƒ |  S(   sW   Return the given native string as a byte string in the given
        encoding.
        (   R    (   R   R   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   @   s    
c         C   sH   t  |  ƒ | d k r; t t j d d „  |  j d ƒ ƒ ƒ S|  j | ƒ S(   s\   Return the given native string as a unicode string with the given
        encoding.
        t   escapes   \\u([0-9a-zA-Z]{4})c         S   s   t  t |  j d ƒ d ƒ ƒ S(   Ni   i   (   t   unichrt   intt   group(   t   m(    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   <lambda>W   s    s
   ISO-8859-1(   R    t   unicodet   ret   subR   (   R   R   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   J   s    
	c         C   s    t  |  t ƒ r |  j | ƒ S|  S(   sA   Return the given string as a native string in the given encoding.(   R   R   R   (   R   R   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR	   ]   s    c         C   s/   t  |  t ƒ s+ t d t |  ƒ j ƒ ‚ n  d  S(   Ns   n must be a native str (got %s)(   R   t	   nativestrt	   TypeErrort   typet   __name__(   R   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR    m   s    (   t   decodebytes(   t   decodestringc         C   sT   t  |  t ƒ r! |  j | ƒ } n |  } t | ƒ } t t k rL | j | ƒ S| Sd S(   s=   Return the native string base64-decoded (as a native string).N(   R   t
   unicodestrR   t   _base64_decodebytesR   R   (   R   R   t   b(    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   base64_decode{   s    c         C   s   |  }  |  j  ƒ  |  S(   N(   t   sort(   t   i(    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   sorted‹   s    
c         c   s6   t  |  ƒ } x# | d k r1 | d 8} |  | Vq Wd  S(   Ni    i   (   t   len(   t   xR    (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   reversed“   s    
(   t   urljoint	   urlencode(   t   quotet
   quote_plus(   t   unquotet   urlopen(   t   parse_http_listt   parse_keqv_list(   R%   (   R&   R*   (   R)   (   t   localc         C   s
   |  j  ƒ  S(   N(   t	   iteritems(   t   d(    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   ¯   s    c         C   s
   |  j  ƒ  S(   N(   t   items(   R/   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   °   s    c         C   s
   |  j  ƒ  S(   N(   R0   (   R/   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   ³   s    c         C   s   t  |  j ƒ  ƒ S(   N(   t   listR0   (   R/   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   ´   s    c         C   s
   |  j  ƒ  S(   N(   t   iterkeys(   R/   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   ¹   s    c         C   s
   |  j  ƒ  S(   N(   t   keys(   R/   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   º   s    c         C   s
   |  j  ƒ  S(   N(   R3   (   R/   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   ½   s    c         C   s   t  |  j ƒ  ƒ S(   N(   R1   R3   (   R/   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   ¾   s    c         C   s
   |  j  ƒ  S(   N(   t
   itervalues(   R/   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   Ã   s    c         C   s
   |  j  ƒ  S(   N(   t   values(   R/   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   Ä   s    c         C   s
   |  j  ƒ  S(   N(   R5   (   R/   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   Ç   s    c         C   s   t  |  j ƒ  ƒ S(   N(   R1   R5   (   R/   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR   È   s    (   t   SimpleCookiet   CookieError(   t   BadStatusLinet   HTTPConnectiont   IncompleteRead(   t   NotConnected(   t   BaseHTTPRequestHandler(   t   HTTPSConnectiont   daemonc         C   s   |  j  S(   N(   R>   (   t   t(    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt
   get_daemonö   s    c         C   s   | |  _  d  S(   N(   R>   (   R?   t   val(    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt
   set_daemonù   s    c         C   s
   |  j  ƒ  S(   N(   t   isDaemon(   R?   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyR@   ü   s    c         C   s   |  j  | ƒ d  S(   N(   t	   setDaemon(   R?   RA   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyRB   ÿ   s    (   t
   formatdatec         C   s   t  |  d t ƒS(   Nt   usegmt(   RE   t   True(   t   timeval(    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   HTTPDate  s    t   strictc         C   s"   t  |  j d d ƒ d | d | ƒS(   Nt   +t    R   t   errors(   t   parse_unquotet   replace(   t   atomR   RM   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt
   unquote_qs  s    c         C   s"   t  |  j d d ƒ ƒ j | | ƒ S(   NRK   RL   (   RN   RO   R   (   RP   R   RM   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyRQ     s    i   i   c         C   s   t  d ƒ ‚ d  S(   Ns   No JSON library is available(   t
   ValueError(   t   s(    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   json_decode)  s    c         C   s   t  d ƒ ‚ d  S(   Ns   No JSON library is available(   RR   (   RS   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   _json_encode,  s    c         c   s)   x" t  |  ƒ D] } | j d ƒ Vq Wd  S(   Nt   utf8(   RU   R   (   t   valuet   chunk(    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   json_encode2  s    c           C   s   t  j t j d ƒ ƒ j d ƒ S(   Ni   t   ascii(   t   binasciit   hexlifyt   ost   urandomR   (    (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   random20B  s    (   t	   get_identc         C   s
   |  j  ƒ  S(   N(   t   next(   R    (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyRa   O  s    t   SetDaemonPropertyc           B   s;   e  Z d  „  Z d „  Z e j d k  r9 e e e ƒ Z n  RS(   c         C   s
   |  j  ƒ  S(   N(   RC   (   t   self(    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   __get_daemon`  s    c         C   s   |  j  | ƒ d  S(   N(   RD   (   Rc   R>   (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   __set_daemonc  s    i   i   (   i   i   (   R   t
   __module__t   _SetDaemonProperty__get_daemont   _SetDaemonProperty__set_daemont   syst   version_infot   propertyR>   (    (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyRb   ^  s   		(   i   i    (   i   i   (   i   i   (    (m   t   __doc__R]   R   Ri   t	   threadingRj   RG   t   py3kR   t   bytestrt   strR   R   t
   basestringR   R   R	   t   ioR
   R   t   FalseR   t	   cStringIOt   ImportErrorR    t   base64R   R   R   R   R!   t	   NameErrorR$   t   urllib.parseR%   R&   R'   R(   t   urllib.requestR)   R*   R+   R,   t   urlparset   urllibt   urllib2R-   t   threadlocalt   cherrypy._cpthreadinglocalt   dictR.   t	   copyitemst   AttributeErrorR2   t   copykeysR4   t
   copyvaluest   builtinst   __builtin__t   CookieR6   R7   t   httplibR8   R9   R:   R;   t   BaseHTTPServerR<   t   http.cookiest   http.clientt   http.serverR=   t   Nonet   xranget   ranget   hasattrt   ThreadR@   RB   t   email.utilsRE   RI   t   rfc822RN   RQ   t
   simplejsont   jsont   JSONDecoderR   RT   t   JSONEncodert
   iterencodeRU   RY   t   cPicklet   pickleR[   R_   t   _threadR`   t   get_thread_identt   threadRa   t   Timert   Eventt   _Timert   _EventRb   (    (    (    sy   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpcompat.pyt   <module>   s<  
	

						


			 		
			