ó
ÐEe]c           @` s¯  d  Z  d d l m Z m Z m Z d d d d d d d	 d
 d d d d d d d d d d d d d g Z d d l Z y d d l m Z m	 Z	 Wn e
 k
 rª d Z Z	 n Xe j d d k r-d d l Z e Z e f Z e Z e Z e Z d „  Z d „  Z d „  Z d „  Z d d  „ Z d! „  Z d" Z n] e Z e Z e Z e Z e e f Z e Z e Z d# Z d$ „  Z d% „  Z d d& „ Z d' „  Z d( „  Z d) „  Z d* „  Z d+ „  Z d e  f d, „  ƒ  YZ! e j d d k rùe j d- d. k rùd d/ „ Z" n d d0 „ Z" d d l# Z# e j d1  d8 k r0e# j$ Z% n e# j& d2 e  f i d9 d3 6ƒ Z% e j d1  d: k rƒd d l' Z' e' j( Z) e' j* Z+ n( d5 „  Z, d e% f d6 „  ƒ  YZ+ d7 „  Z) d S(;   s    
Python 3 compatibility tools.

i    (   t   divisiont   absolute_importt   print_functiont   bytest   asbytest	   isfileobjt   getexceptiont   strchart   unicodet	   asunicodet   asbytes_nestedt   asunicode_nestedt   asstrt   open_latin1t   longt
   basestringt   sixut   integer_typest   is_pathlib_patht   npy_load_modulet   Patht   contextlib_nullcontextt	   os_fspatht   os_PathLikeN(   R   t   PurePathi   c         C` s&   t  |  t ƒ r |  j d ƒ St |  ƒ S(   Nt   latin1(   t
   isinstanceR   t   decodet   str(   t   s(    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR	      s    c         C` s&   t  |  t ƒ r |  St |  ƒ j d ƒ S(   NR   (   R   R   R   t   encode(   R   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   !   s    c         C` s&   t  |  t ƒ r |  j d ƒ St |  ƒ S(   NR   (   R   R   R   R   (   R   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   &   s    c         C` s   t  |  t j t j t j f ƒ S(   N(   R   t   iot   FileIOt   BufferedReadert   BufferedWriter(   t   f(    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   +   s    t   rc         C` s   t  |  d | d d ƒS(   Nt   modet   encodings
   iso-8859-1(   t   open(   t   filenameR%   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   .   s    c         C` s   |  S(   N(    (   R   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   1   s    t   Ut   Sc         C` s   t  |  t ƒ S(   N(   R   t   file(   R#   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   A   s    c         C` s&   t  |  t ƒ r |  St |  ƒ j d ƒ S(   Nt   ascii(   R   R   R   R   (   R   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR	   D   s    c         C` s   t  |  d | ƒS(   NR%   (   R'   (   R(   R%   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   I   s    c         C` s   t  |  d ƒ S(   Nt   unicode_escape(   R   (   R   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   L   s    c           C` s   t  j ƒ  d S(   Ni   (   t   syst   exc_info(    (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   P   s    c         C` sP   t  |  d ƒ rB t |  t t f ƒ rB g  |  D] } t | ƒ ^ q, St |  ƒ Sd  S(   Nt   __iter__(   t   hasattrR   R   R   R
   R   (   t   xt   y(    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR
   S   s    %c         C` sP   t  |  d ƒ rB t |  t t f ƒ rB g  |  D] } t | ƒ ^ q, St |  ƒ Sd  S(   NR0   (   R1   R   R   R   R   R	   (   R2   R3   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   Y   s    %c         C` s   t  d k	 o t |  t  ƒ S(   s€   
    Check whether obj is a pathlib.Path object.

    Prefer using `isinstance(obj, os_PathLike)` instead of this function.
    N(   R   t   NoneR   (   t   obj(    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   _   s    c           B` s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   sO  Context manager that does no additional processing.

    Used as a stand-in for a normal context manager, when a particular
    block of code is only sometimes used with a normal context manager:

    cm = optional_cm if condition else nullcontext()
    with cm:
        # Perform operation, using optional_cm if condition is True
    c         C` s   | |  _  d  S(   N(   t   enter_result(   t   selfR6   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyt   __init__s   s    c         C` s   |  j  S(   N(   R6   (   R7   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyt	   __enter__v   s    c         G` s   d  S(   N(    (   R7   t   excinfo(    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyt   __exit__y   s    N(   t   __name__t
   __module__t   __doc__R4   R8   R9   R;   (    (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   h   s   		i   i   c         C` s%   d d l  } | j j |  | ƒ j ƒ  S(   sd  
        Load a module.

        .. versionadded:: 1.11.2

        Parameters
        ----------
        name : str
            Full module name.
        fn : str
            Path to module file.
        info : tuple, optional
            Only here for backward compatibility with Python 2.*.

        Returns
        -------
        mod : module

        i    N(   t   importlib.machineryt	   machineryt   SourceFileLoadert   load_module(   t   namet   fnt   infot	   importlib(    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   ~   s    c         C` s˜   d d l  } d d l } | d k rW | j j | ƒ } | j |  | g ƒ \ } } } n t | | d ƒ } z | j |  | | | ƒ } Wd | j ƒ  X| S(   s}  
        Load a module.

        .. versionadded:: 1.11.2

        Parameters
        ----------
        name : str
            Full module name.
        fn : str
            Path to module file.
        info : tuple, optional
            Information as returned by `imp.find_module`
            (suffix, mode, type).

        Returns
        -------
        mod : module

        i    Ni   (	   t   impt   osR4   t   patht   dirnamet   find_moduleR'   RB   t   close(   RC   RD   RE   RG   RH   RI   t   fot   mod(    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   •   s    !i   t   ABCt	   __slots__i   c         C` s
   t  |  ƒ S(   N(   R   (   R7   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyt   _PurePath__fspath__Å   s    c           B` s/   e  Z d  Z e j d „  ƒ Z e d „  ƒ Z RS(   sC   Abstract base class for implementing the file system path protocol.c         C` s
   t  ‚ d S(   s9   Return the file system path representation of the object.N(   t   NotImplementedError(   R7   (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyt
   __fspath__Ë   s    c         C` s,   t  d  k	 r t | t  ƒ r t St | d ƒ S(   NRS   (   R   R4   t
   issubclasst   TrueR1   (   t   clst   subclass(    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyt   __subclasshook__Ð   s    (   R<   R=   R>   t   abct   abstractmethodRS   t   classmethodRX   (    (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   È   s   c         C` sÚ   t  |  t t f ƒ r |  St |  ƒ } y | j |  ƒ } Wn^ t k
 r˜ t | d ƒ r] ‚  q™ t d k	 r‚ t	 | t ƒ r‚ t
 |  ƒ St d | j ƒ ‚ n Xt  | t t f ƒ r² | St d j | j t | ƒ j ƒ ƒ ‚ d S(   st  Return the path representation of a path-like object.
        If str or bytes is passed in, it is returned unchanged. Otherwise the
        os.PathLike interface is used to get the path representation. If the
        path representation is not str or bytes, TypeError is raised. If the
        provided path is not str, bytes, or os.PathLike, TypeError is raised.
        RS   s/   expected str, bytes or os.PathLike object, not s7   expected {}.__fspath__() to return str or bytes, not {}N(   R   R   R   t   typeRS   t   AttributeErrorR1   R   R4   RT   RQ   t	   TypeErrorR<   t   format(   RI   t	   path_typet	   path_repr(    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyR   ×   s"    
	(   i   i   (    (   i   i   (-   R>   t
   __future__R    R   R   t   __all__R.   t   pathlibR   R   t   ImportErrorR4   t   version_infoR   t   intR   R   R   R   R   R   R	   R   R   R   R   R   R   R   R
   R   R   t   objectR   R   RY   RO   t   abc_ABCt   ABCMetaRH   t   fspathR   t   PathLikeR   RQ   (    (    (    s0   lib/python2.7/site-packages/numpy/compat/py3k.pyt   <module>   sp   															&#		