ó
¾÷Xc           @   sÊ   d  Z  d d l Z d d l Z y d d l m Z Wn e k
 rN d „  Z n Xd „  Z e ƒ  \ Z Z [ y d d l m	 Z	 Wn e k
 r— e Z	 n Xy d d l m
 Z
 Wn e k
 rÅ e Z
 n Xd S(   s*   
Compatibility module for high-level h5py
iÿÿÿÿN(   t   fspathc         C   s¿   t  |  t j t j f ƒ r |  St |  ƒ } y | j |  ƒ SWn| t k
 rº t | d ƒ ra ‚  n  y d d l } Wn t	 k
 r„ n  Xt  |  | j
 ƒ r¤ t j |  ƒ St d | j ƒ ‚ n Xd S(   s	  
        Return the string representation of the path.
        If str or bytes is passed in, it is returned unchanged.
        This code comes from PEP 519, modified to support earlier versions of
        python.

        This is required for python < 3.6.
        t
   __fspath__iÿÿÿÿNs/   expected str, bytes or os.PathLike object, not (   t
   isinstancet   sixt	   text_typet   binary_typet   typeR   t   AttributeErrort   hasattrt   pathlibt   ImportErrort   PurePatht	   TypeErrort   __name__(   t   patht	   path_typeR	   (    (    s-   /tmp/pip-build-isqEY4/h5py/h5py/_hl/compat.pyR       s     	c             s   t  j ƒ  ‰  ˆ  d k r! d ‰ n> y d d l m }  |  d ƒ Wn t k
 rX d ‰ n Xd ‰ ‡  ‡ f d †  } ‡  ‡ f d †  } | | f S(   Nt   mbcst   strictiÿÿÿÿ(   t   lookup_errort   surrogateescapec            sU   t  |  t j ƒ r |  St  |  t j ƒ r8 |  j ˆ  ˆ ƒ St d t |  ƒ j ƒ ‚ d S(   sø   
        Encode filename to the filesystem encoding with 'surrogateescape' error
        handler, return bytes unchanged. On Windows, use 'strict' error handler if
        the file system encoding is 'mbcs' (which is the default encoding).
        s   expect bytes or str, not %sN(   R   R   R   R   t   encodeR   R   R   (   t   filename(   t   encodingt   errors(    s-   /tmp/pip-build-isqEY4/h5py/h5py/_hl/compat.pyt   fsencode;   s
    c            sU   t  |  t j ƒ r |  St  |  t j ƒ r8 |  j ˆ  ˆ ƒ St d t |  ƒ j ƒ ‚ d S(   sø   
        Decode filename from the filesystem encoding with 'surrogateescape' error
        handler, return str unchanged. On Windows, use 'strict' error handler if
        the file system encoding is 'mbcs' (which is the default encoding).
        s   expect bytes or str, not %sN(   R   R   R   R   t   decodeR   R   R   (   R   (   R   R   (    s-   /tmp/pip-build-isqEY4/h5py/h5py/_hl/compat.pyt   fsdecodeH   s
    (   t   syst   getfilesystemencodingt   codecsR   t   LookupError(   R   R   R   (    (   R   R   s-   /tmp/pip-build-isqEY4/h5py/h5py/_hl/compat.pyt   _fscodec.   s    	
(   R   (   R   (   t   __doc__R   R   t   osR    R
   R   t	   _fsencodet	   _fsdecodeR   R   (    (    (    s-   /tmp/pip-build-isqEY4/h5py/h5py/_hl/compat.pyt   <module>   s"   #	)
