
)Ί]c           @  s  d  Z  d d l m Z d d l Z d d l Z d d l Z e j d d k Z e j d d k Z e r e	 e
 f Z e e f Z n e	 f Z e f Z e e e  e e g  Z e rd d l Z d d l Z y d d l Z Wn e k
 r n Xd d l m Z y d d l Z Wn e k
 r0d d l Z n Xy d d l  Z! Wn e k
 r`d d l! Z! n Xd d l" m# Z$ d d l% Z& d d l' Z( d d l) Z) n d d l Z d d l Z y d d l Z Wn e k
 rn Xd d	 l m Z d d l Z d d l! Z! d d
 l* m$ Z$ d d l& Z& d d l( Z( d d l+ Z) d   Z, d   Z- d   Z. d   Z/ d   Z0 d d  Z2 d d  Z3 d   Z4 d   Z5 d   Z6 d   Z7 d   Z8 d   Z9 e re: Z; e j< Z= e> Z> d d l? Z? e? j@ ZA d d lB mC ZD n1 e; Z; e j= Z= d   Z> e	 j@ ZA d d lB mD ZD d   ZE e rd   ZF d   ZG d   ZH d   ZI e jJ d   ZK e jJ d!  ZL e jJ d"  ZM nQ d#   ZF d$   ZG d%   ZH d&   ZI e jJ d'  ZK e jJ d(  ZL e jJ d)  ZM eN d* k rn  d S(+   s   
spyder.py3compat
----------------

Transitional module providing compatibility functions intended to help
migrating from Python 2 to Python 3.

This module should be fully compatible with:
    * Python >=v2.6
    * Python 3
i(   t   print_functionNi    t   2t   3(   t   maxint(   t	   DictMixin(   t   maxsize(   t   MutableMappingc         C  s6   t  r t |   t t g k St |   t t g k Sd S(   s   Return True if `obj` is type text string, False if it is anything else,
    like an instance of a class that extends the basestring class.N(   t   PY2t   typet   strt   unicodet   bytes(   t   obj(    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   is_type_text_stringX   s    c         C  s$   t  r t |  t  St |  t  Sd S(   s   Return True if `obj` is a text string, False if it is anything else,
    like binary data (Python 3) or QString (Python 2, PyQt API #1)N(   R   t
   isinstancet
   basestringR	   (   R   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   is_text_stringb   s    c         C  s$   t  r t |  t  St |  t  Sd S(   sE   Return True if `obj` is a binary string, False if it is anything elseN(   R   R   R	   R   (   R   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   is_binary_stringl   s    c         C  s   t  |   p t |   S(   s   Return True if `obj` is a text or binary Python string object,
    False if it is anything else, like a QString (Python 2, PyQt API #1)(   R   R   (   R   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt	   is_stringu   s    c         C  s$   t  r t |  t  St |  t  Sd S(   s   Return True if `obj` is unicodeN(   R   R   R
   R	   (   R   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt
   is_unicodez   s    c         C  sf   t  r, | d k r t |   St |  |  Sn6 | d k rB t |   St |  t  rU |  St |  |  Sd S(   s&   Convert `obj` to (unicode) text stringN(   R   t   NoneR
   R	   R   (   R   t   encoding(    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   to_text_string   s    

c         C  sO   t  r, | d k r t |   S|  j |  Sn t |  | d k rD d n |  Sd S(   sC   Convert `obj` to binary string (bytes in Python 3, str in Python 2)s   utf-8N(   R   R   R	   t   encodeR   (   R   R   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   to_binary_string   s
    
c         C  s   t  r |  j S|  j Sd S(   s   Return function code objectN(   R   t	   func_codet   __code__(   t   func(    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   get_func_code   s    c         C  s   t  r |  j S|  j Sd S(   s   Return function nameN(   R   t	   func_namet   __name__(   R   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   get_func_name   s    c         C  s   t  r |  j S|  j Sd S(   s'   Return function default argument valuesN(   R   t   func_defaultst   __defaults__(   R   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   get_func_defaults   s    c         C  s   t  r |  j S|  j Sd S(   s   Return method function objectN(   R   t   im_funct   __func__(   R   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   get_meth_func   s    c         C  s   t  r |  j S|  j Sd S(   s   Return method class instanceN(   R   t   im_selft   __self__(   R   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   get_meth_class_inst   s    c         C  s   t  r |  j S|  j j Sd S(   s   Return method classN(   R   t   im_classR'   t	   __class__(   R   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   get_meth_class   s    (   t   izip_longestc         C  s   |  | k |  | k  S(   N(    (   t   at   b(    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   cmp   s    (   t   zip_longestc         C  s"   t  t |  j   j    j    S(   sD   Convert QByteArray object to str in a way compatible with Python 2/3(   R	   R   t   toHext   datat   decode(   t   qba(    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   qbytearray_to_str   s    c         K  s   t  |  j |    S(   N(   t   itert   keys(   t   dt   kw(    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   iterkeys   s    c         K  s   t  |  j |    S(   N(   R6   t   values(   R8   R9   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt
   itervalues   s    c         K  s   t  |  j |    S(   N(   R6   t   items(   R8   R9   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt	   iteritems  s    c         K  s   t  |  j |    S(   N(   R6   t   lists(   R8   R9   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt	   iterlists  s    R7   R;   R=   c         K  s   |  j  |   S(   N(   R:   (   R8   R9   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyR:     s    c         K  s   |  j  |   S(   N(   R<   (   R8   R9   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyR<     s    c         K  s   |  j  |   S(   N(   R>   (   R8   R9   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyR>     s    c         K  s   |  j  |   S(   N(   R@   (   R8   R9   (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyR@     s    t   viewkeyst
   viewvaluest	   viewitemst   __main__(O   t   __doc__t
   __future__R    t   operatort   ost   syst   versionR   t   PY3R	   R
   t
   TEXT_TYPESt   intt   longt	   INT_TYPESt   tuplet   listt   floatt   complext   NUMERIC_TYPESt   __builtin__t   builtinst   ConfigParsert   configparsert   _winregt   winregt   ImportErrorR   R   t	   CStringIOt   iot   StringIOt   cPicklet   picklet   UserDictR   R   t   threadt   _threadt   reprt   reprlibt   Queuet   collectionst   queueR   R   R   R   R   R   R   R   R   R   R"   R%   R(   R+   t	   raw_inputt   inputt   getcwdut   getcwdR/   t   stringt   lowert	   str_lowert	   itertoolsR,   R0   R5   R:   R<   R>   R@   t   methodcallerRA   RB   RC   R   (    (    (    s7   lib/python2.7/site-packages/spyder_kernels/py3compat.pyt   <module>   s   			
	
																													