mò
­fIc        #   @   s¥  d  Z  d k Z d k Z d d d d d d d d	 d
 d d d d d d d d d d d d d d d d d d d d d d  d! d" d# d$ g# Z d% Z d& Z d% Z d' Z d( Z d) Z	 d* Z
 d+ Z d, „  Z d- „  Z d. „  Z d/ „  Z d0 „  Z d1 „  Z d2 „  Z d3 „  Z d4 „  Z d5 „  Z d6 „  Z d7 „  Z d8 „  Z d9 „  Z d: „  Z d; „  Z e Z d< „  Z d= „  Z d> „  Z d? „  Z  d@ „  Z! dA „  Z" dB „  Z# dC „  Z$ e$ Z% e& Z' d S(D   sŒ   Common pathname manipulations, OS/2 EMX version.

Instead of importing this module directly, import os and refer to this
module as os.path.
Nt   normcaset   isabst   joint
   splitdrivet   splitt   splitextt   basenamet   dirnamet   commonprefixt   getsizet   getmtimet   getatimet   getctimet   islinkt   existst   lexistst   isdirt   isfilet   ismountt   walkt
   expandusert
   expandvarst   normpatht   abspatht   splitunct   curdirt   pardirt   sept   pathsept   defpatht   altsept   extsept   devnullt   realpatht   supports_unicode_filenamest   .s   ..t   /s   \t   ;s   .;C:\bint   nulc         C   s   |  i d d ƒ i ƒ  S(   sZ   Normalize case of pathname.

    Makes all characters lowercase and all altseps into seps.s   \R$   N(   t   st   replacet   lower(   R'   (    (    t'   /mit/python/lib/python2.4/os2emxpath.pyR        s     c         C   s+   t  |  ƒ d }  |  d j o |  d  d j S(   s   Test whether a path is absolutei   t    s   /\N(   R   R'   (   R'   (    (    R*   R   -   s     c         G   sl   |  } x_ | D]W } t | ƒ o
 | } q | d j p | d d j o | | } q | d | } q W| S(   s=   Join two or more pathname components, inserting sep as neededR+   iÿÿÿÿs   /\:R$   N(   t   at   patht   pt   bR   (   R,   R.   R/   R-   (    (    R*   R   5   s      
c         C   s7   |  d d !d j o |  d d !|  d f Sn d |  f S(   sl   Split a pathname into drive and path specifiers. Returns a 2-tuple
"(drive,path)";  either part may be emptyi   i   t   :i    R+   N(   R.   (   R.   (    (    R*   R   E   s     c         C   sÝ   |  d d !d j o d |  f Sn |  d d !} | d d j p | d d j o‚ t |  ƒ } | i d d ƒ } | d j o d |  f Sn | i d | d ƒ } | d j o t |  ƒ } n |  |  |  | f Sn d |  f S(
   s@  Split a pathname into UNC mount point and relative path specifiers.

    Return a 2-tuple (unc, rest); either part may be empty.
    If unc is not empty, it has the form '//host/mount' (or similar
    using backslashes).  unc+rest is always the input path.
    Paths containing drive letters never have an UNC part.
    i   i   R0   R+   i    R$   s   \iÿÿÿÿN(   R.   t   firstTwoR    t   normpt   findt   indext   len(   R.   R4   R1   R2   (    (    R*   R   N   s     "c         C   s¬   t  |  ƒ \ } }  t |  ƒ } x+ | o# |  | d d j o | d } q! W|  |  |  | } } | } x' | o | d d j o | d  } qj W| p | } | | | f S(   s~   Split a pathname.

    Return tuple (head, tail) where tail is everything after the final slash.
    Either part may be empty.i   s   /\iÿÿÿÿN(   R   R.   t   dR5   t   it   headt   tailt   head2(   R.   R8   R6   R7   R9   R:   (    (    R*   R   o   s       c         C   s¥   d \ } } xŒ |  D]„ } | d d g j o | | | d } } q | d j o& | o | | | } } q— | } q | o | | } q | | } q W| | f S(   s‘   Split the extension from a pathname.

    Extension is everything from the last dot to the end.
    Return (root, ext), either part may be empty.R+   R$   s   \R#   N(   R+   R+   (   t   roott   extR.   t   c(   R.   R<   R;   R=   (    (    R*   R   ˆ   s      
c         C   s   t  |  ƒ d S(   s)   Returns the final component of a pathnamei   N(   R   R.   (   R.   (    (    R*   R   Ÿ   s     c         C   s   t  |  ƒ d S(   s-   Returns the directory component of a pathnamei    N(   R   R.   (   R.   (    (    R*   R   ¦   s     c         C   sŒ   |  p d Sn |  d } xl |  D]d } x[ t t | ƒ ƒ D]G } | | d  | | d  j o$ | |  } | d j o d Sn Pq9 q9 Wq  W| S(   sG   Given a list of pathnames, returns the longest common leading componentR+   i    i   N(   t   mt   prefixt   itemt   rangeR5   R7   (   R>   R7   R@   R?   (    (    R*   R   ­   s      
  
 c         C   s   t  i |  ƒ i S(   s0   Return the size of a file, reported by os.stat()N(   t   ost   statt   filenamet   st_size(   RD   (    (    R*   R	   ¼   s     c         C   s   t  i |  ƒ i S(   sB   Return the last modification time of a file, reported by os.stat()N(   RB   RC   RD   t   st_mtime(   RD   (    (    R*   R
   À   s     c         C   s   t  i |  ƒ i S(   s<   Return the last access time of a file, reported by os.stat()N(   RB   RC   RD   t   st_atime(   RD   (    (    R*   R   Ä   s     c         C   s   t  i |  ƒ i S(   s:   Return the creation time of a file, reported by os.stat().N(   RB   RC   RD   t   st_ctime(   RD   (    (    R*   R   È   s     c         C   s   t  S(   s5   Test for symbolic link.  On OS/2 always returns falseN(   t   False(   R-   (    (    R*   R   Ï   s     c         C   s4   y t  i |  ƒ } Wn t  i j
 o t Sn Xt S(   s   Test whether a path existsN(   RB   RC   R-   t   stt   errorRI   t   True(   R-   RJ   (    (    R*   R   ×   s     	c         C   s@   y t  i |  ƒ } Wn t  i j
 o t Sn Xt i | i ƒ S(   s"   Test whether a path is a directoryN(   RB   RC   R-   RJ   RK   RI   t   S_ISDIRt   st_mode(   R-   RJ   (    (    R*   R   ä   s     	c         C   s@   y t  i |  ƒ } Wn t  i j
 o t Sn Xt i | i ƒ S(   s%   Test whether a path is a regular fileN(   RB   RC   R-   RJ   RK   RI   t   S_ISREGRN   (   R-   RJ   (    (    R*   R   ñ   s     	c         C   sX   t  |  ƒ \ } } | o | d j Sn t |  ƒ d } t | ƒ d j o | d d j S(	   s?   Test whether a path is a mount point (defined as root of drive)R+   R$   s   \i   i    s   /\N(   R+   R$   s   \(   R   R-   t   unct   restR   R.   R5   (   R-   RQ   R.   RP   (    (    R*   R   ý   s     c         C   sœ   y t  i |  ƒ } Wn t  i j
 o d Sn X| | |  | ƒ d } xO | D]G } | | j o4 t	 |  | ƒ } t
 | ƒ o t | | | ƒ q” qM qM Wd S(   së   Directory tree walk whth callback function.

    walk(top, func, arg) calls func(arg, d, files) for each directory d
    in the tree rooted at top (including top itself); files is a list
    of all the files and subdirs in directory d.NR#   s   ..(   R#   s   ..(   RB   t   listdirt   topt   namesRK   t   funct   argt
   exceptionst   nameR   R   R   (   RS   RU   RV   RX   RT   RW   (    (    R*   R     s     	 c         C   sù   |  d  d j o |  Sn d t |  ƒ } } x- | | j  o |  | d j o | d } q/ W| d j o€ d t i j o t i d } qí d t i j o |  Sqí y t i d } Wn t j
 o d } n Xt	 | t i d ƒ } n |  S| |  | S(	   sL   Expand ~ and ~user constructs.

    If user or $HOME is unknown, do nothing.i   t   ~s   /\t   HOMEt   HOMEPATHt	   HOMEDRIVER+   N(
   R-   R5   R7   t   nRB   t   environt   userhomet   drivet   KeyErrorR   (   R-   R7   R`   R]   R_   (    (    R*   R   *  s&      c         C   s’  d |  j o |  Sn d k } | i | i d } d } d } t |  ƒ } xA| | j  o3|  | } | d j oq |  | d }  t |  ƒ } y) |  i d ƒ } | d |  | d  } Wqt
 j
 o | |  } | d } qXnž| d j o†|  | d | d !d j o | | } | d } q|  | d | d !d	 j oŠ |  | d }  t |  ƒ } yB |  i d
 ƒ } |  |  } | t i j o | t i | } n Wqqt
 j
 o | |  } | d } qqXqd } | d } |  | | d !} xD | d j o6 | | j o) | | } | d } |  | | d !} qíW| t i j o | t i | } n | d j o | | } qn | | } | d } qM W| S(   sZ   Expand shell variables of form $var and ${var}.

    Unknown variables are left unchanged.t   $Ns   _-R+   i    s   'i   i   t   {t   }(   R-   t   stringt   letterst   digitst   varcharst   resR4   R5   t   pathlenR=   t
   ValueErrort   varRB   R^   (   R-   R4   R=   Re   Ri   Rh   Rj   Rl   (    (    R*   R   L  sd     	 





 


c         C   sj  |  i d d ƒ }  t |  ƒ \ } }  x* |  d  d j o | d } |  d }  q' W|  i d ƒ } d } xÏ | t | ƒ j  o» | | d j o | | =qi | | d j oB | d j o5 | | d d	 j o  | | d | d 5| d } qi | | d j o- | d j o  | | d d j o | | =qi | d } qi W| o | o | i d ƒ n | d i	 | ƒ S(
   s0   Normalize path, eliminating double slashes, etc.s   \R$   i   i    R#   s   ..R+   N(   R+   s   ..(
   R-   R(   R   R?   R   t   compsR7   R5   t   appendR   (   R-   R7   Rm   R?   (    (    R*   R   …  s,      
 33c         C   s0   t  |  ƒ p t t i ƒ  |  ƒ }  n t |  ƒ S(   s%   Return the absolute version of a pathN(   R   R-   R   RB   t   getcwdR   (   R-   (    (    R*   R   Ÿ  s     ((   t   __doc__RB   RC   t   __all__R   R   R   R   R   R   R   R    R    R   R   R   R   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R!   RI   R"   (&   R   R   R   R   R   R   R   R   R   R
   R   R   R   R"   Rq   R   R   R	   R   R    R   R   R!   RC   R   R   R    R   R   R   R   R   R   R   R   R   R   RB   (    (    R*   t   ?   sL   		o						!																"	9		