o
    ˜»áfG  ã                   @   s   d Z dd„ Zdd„ ZdS )z˜Convert a NT pathname to a file URL and vice versa.

This module only exists to provide OS-specific code
for urllib.requests, thus do not use directly.
c                 C   sü   ddl }ddl}|  dd¡} d| vr.| dd… dkr | dd… } |  d¡}|j d	 |¡¡S |  d¡}t|ƒdksB|d d
 |jvrJd|  }t	|ƒ‚|d d
  
¡ }|d  d¡}|d }|D ]}|rm|d	 |j |¡ }q_| d¡r||  d¡r||d	7 }|S )z{OS-specific conversion from a relative URL of the 'file' scheme
    to a file system path; not recommended for general use.é    Nú:ú|é   z////é   ú/ú\éÿÿÿÿz	Bad URL: é   )ÚstringÚurllib.parseÚreplaceÚsplitÚparseÚunquoteÚjoinÚlenÚascii_lettersÚOSErrorÚupperÚendswith)Úurlr
   ÚurllibÚ
componentsÚcompÚerrorÚdriveÚpath© r   ú!/usr/lib/python3.10/nturl2path.pyÚurl2pathname   s*   	

€r   c                 C   s0  ddl }| dd… dkr3| dd… } | dd…  ¡ dkr%d| dd…  } n| dd… d	kr3td
|  ƒ‚d	| vrQ| dd… dkrCd|  } |  d¡}|j d |¡¡S | jd	dd}t|ƒdksft|d ƒdkrnd
|  }t|ƒ‚|j |d  ¡ ¡}|d  d¡}d| d	 }|D ]}|r•|d |j |¡ }q‡|S )z{OS-specific conversion from a file system path to a relative URL
    of the 'file' scheme; not recommended for general use.r   Nr   z\\?\zUNC\r   r	   r   r   z
Bad path: z\\r   )Úmaxsplitz///)r   r   r   r   r   Úquoter   r   )Úpr   r   r   r   r   r   r   r   r   Úpathname2url-   s0   
€r#   N)Ú__doc__r   r#   r   r   r   r   Ú<module>   s    %