ó
\c           @   sâ   d  Z  d d l Z d d l Z d Z y d d l m Z Wn e k
 rT 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	 „  Z d
 „  Z d S(   s*   
Compatibility module for high-level h5py
iÿÿÿÿNt   mbcs(   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.   lib/python2.7/site-packages/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(   NR    t   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.   lib/python2.7/site-packages/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.   lib/python2.7/site-packages/h5py/_hl/compat.pyt   fsdecodeJ   s
    (   t   syst   getfilesystemencodingt   codecsR   t   LookupError(   R   R   R   (    (   R   R   s.   lib/python2.7/site-packages/h5py/_hl/compat.pyt   _fscodec0   s    	
(   R   (   R   c         C   sK   t  |  ƒ }  t j d k rA t |  t j ƒ r= |  j t d ƒ S|  St |  ƒ S(   sÿ   
    Encode filename for use in the HDF5 library.

    Due to how HDF5 handles filenames on different systems, this should be
    called on any filenames passed to the HDF5 library. See the documentation on
    filenames in h5py for more information.
    t   win32R   (	   R   R   t   platformR   R   R   R   t   WINDOWS_ENCODINGR   (   R   (    (    s.   lib/python2.7/site-packages/h5py/_hl/compat.pyt   filename_encodeg   s    c         C   sm   t  j d k rc t |  t j ƒ r1 |  j t d ƒ St |  t j ƒ rG |  St d t	 |  ƒ j
 ƒ ‚ n  t |  ƒ S(   sú   
    Decode filename used by HDF5 library.

    Due to how HDF5 handles filenames on different systems, this should be
    called on any filenames passed from the HDF5 library. See the documentation
    on filenames in h5py for more information.
    R    R   s   expect bytes or str, not %s(   R   R!   R   R   R   R   R"   R   R   R   R   R   (   R   (    (    s.   lib/python2.7/site-packages/h5py/_hl/compat.pyt   filename_decodew   s    (   t   __doc__R   R   R"   t   osR   R   R   t	   _fsencodet	   _fsdecodeR   R   R#   R$   (    (    (    s.   lib/python2.7/site-packages/h5py/_hl/compat.pyt   <module>   s(   #	)

	