o
    ¹ib  ã                   @   s@   d dl Z d dlZd dlZd dlmZmZ dZdd„ Zdd„ ZdS )é    N)ÚunquoteÚurlparsez^file://([^/]+|/[A-Z]:)c                 C   s,   t  | ¡ ¡  ¡  ¡ }t tdd„ |¡}|S )z¾Attempt to make an LSP rootUri from a ContentsManager root_dir

    Special care must be taken around windows paths: the canonical form of
    windows drives and UNC paths is lower case
    c                 S   s   d  |  d¡ ¡ ¡S )Nz	file://{}é   )ÚformatÚgroupÚlower)Úm© r	   úL/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/jupyter_lsp/paths.pyÚ<lambda>   s    z normalized_uri.<locals>.<lambda>)ÚpathlibÚPathÚ
expanduserÚresolveÚas_uriÚreÚsubÚRE_PATH_ANCHOR)Úroot_dirÚroot_urir	   r	   r
   Únormalized_uri	   s
   
ÿr   c                 C   sB   t jdk}t| ƒ}t|jƒ}|r| d¡r|dd… }|S |}|S )z¨Return a path string for give file:/// URI.

    Respect the different path convention on Windows.
    Based on https://stackoverflow.com/a/57463161/6646912, BSD 0
    Úntú/r   N)ÚosÚnamer   r   ÚpathÚ
startswith)Úfile_uriÚwindows_pathÚfile_uri_parsedÚfile_uri_path_unquotedÚresultr	   r	   r
   Úfile_uri_to_path   s   

ÿr"   )	r   r   r   Úurllib.parser   r   r   r   r"   r	   r	   r	   r
   Ú<module>   s    