
[[\
                 @   sR   d  Z  d d l Z d d l Z d d g Z d d   Z d d   Z d d   Z d S)	zqMacintosh-specific module for conversion between pathnames and URLs.

Do not import directly; use urllib instead.    Nurl2pathnamepathname2urlc             C   s  t  j j |   d } | r7 | d k r7 t d   n  |  d d  d k r` |  d d  }  n% |  d d  d k r t d   n  |  j d	  } d } x | t |  k  rb| | d
 k r | | =q | | d k r| d k r| | d d k r| | d | d  =| d } q | | d k rU| d k rU| | d d k rU| | =q | d } q W| d sd j | d d   } nV d } x: | t |  k  r| | d k rd | | <| d } qWd d j |  } t  j j |  S)z{OS-specific conversion from a relative URL of the 'file' scheme
    to a file system path; not recommended for general use.r   filez(Cannot convert non-local URL to pathnameN   z///   z///...    :)r   r	   )urllibparseZ	splittypeRuntimeErrorsplitlenjoinZunquote)pathnameZtp
componentsirv r   !/usr/lib/python3.4/macurl2path.pyr   
   s6    
0

%
c             C   s   d |  k r t  d   n  |  j d  } | d d k rD | d =n  | d	 d k r^ | d
 =n  x7 t t |   D]# } | | d k rq d | | <qq qq Wt t |  } t j j |   r d d j	 |  Sd j	 |  Sd S)z{OS-specific conversion from a file system path to a relative URL
    of the 'file' scheme; not recommended for general use.r   z*Cannot convert pathname containing slashesr   r   r   r
   z..Nr   )
r   r   ranger   map_pncomp2urlospathisabsr   )r   r   r   r   r   r   r   4   s    

c             C   s    t  j j |  d  d  d d S)N   Zsafer   )r   r   Zquote)Z	componentr   r   r   r   K   s    r   )__doc__Zurllib.parser   r   __all__r   r   r   r   r   r   r   <module>   s   *