3
ûâdeß  ã               @   sp   d dl Z d dlZd dlZd dlZd dlmZ ddlmZ e	ee	 dœdd„Z
e	e	dœd	d
„Ze	e	dœdd„ZdS )é    N)ÚOptionalé   )ÚWINDOWS)ÚurlÚreturnc             C   s    d| krd S | j ddƒd jƒ S )Nú:r   r   )ÚsplitÚlower)r   © r
   ú7/tmp/pip-build-red6nood/pip/pip/_internal/utils/urls.pyÚget_url_scheme
   s    r   )Úpathr   c             C   s.   t jjt jj| ƒƒ} tjjdtjj| ƒƒ}|S )zh
    Convert a path to a file: URL.  The path will be made absolute and have
    quoted path parts.
    zfile:)	Úosr   ÚnormpathÚabspathÚurllibÚparseÚurljoinÚrequestÚpathname2url)r   r   r
   r
   r   Úpath_to_url   s    r   c             C   sÀ   | j dƒstd| ›d�ƒ‚tjj| ƒ\}}}}}| s>|dkrDd}ntrRd| }ntd| ›�ƒ‚tjj|| ƒ}tr¼| r¼t	|ƒdkr¼|d	 d
kr¼|d t
jkr¼|dd… dkr¼|dd… }|S )z(
    Convert a file: URL to a path.
    zfile:z1You can only turn file: urls into filenames (not ú)Ú	localhostÚ z\\z8non-local file URIs are not supported on this platform: é   r   ú/r   é   é   r   ú:/N)r   r   )Ú
startswithÚAssertionErrorr   r   Úurlsplitr   Ú
ValueErrorr   Úurl2pathnameÚlenÚstringÚascii_letters)r   Ú_Únetlocr   r
   r
   r   Úurl_to_path   s&    
r)   )r   r%   Úurllib.parser   Úurllib.requestÚtypingr   Úcompatr   Ústrr   r   r)   r
   r
   r
   r   Ú<module>   s   
