
    Mh}                         d dl Z d dlZd dlmZ d dlmZ d dlmZmZ dZ	d Z
d Zdeeef         d	eeef         d
efdZdS )    N)Path)Union)unquoteurlparsez^file://([^/]+|/[A-Z]:)c                     t          |                                                                                                           }t	          j        t          d |          }|S )zAttempt 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                 v    d                     |                     d                                                    S )Nz	file://{}   )formatgrouplower)ms    Q/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jupyter_lsp/paths.py<lambda>z normalized_uri.<locals>.<lambda>   s*    +"4"4QWWQZZ5E5E5G5G"H"H     )r   
expanduserresolveas_uriresubRE_PATH_ANCHOR)root_dirroot_uris     r   normalized_urir   
   sV     H~~((**2244;;==HvHH( H Or   c                     t           j        dk    }t          |           }t          |j                  }|r |                    d          r|dd         }n|}|S )zReturn 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results        r   file_uri_to_pathr&      se     7d?Lx((O$_%9:: (.99#>> ('+'Mr   rootr   returnc                     	 t          |                                                              t          |                                                      dS # t          $ r Y dS w xY w)z"Return if path is relative to rootTF)r   r   relative_to
ValueError)r'   r   s     r   is_relativer,   '   sf    T

((d););)=)=>>>t   uus   AA 
A%$A%)r   r   pathlibr   typingr   urllib.parser   r   r   r   r&   strboolr,    r   r   <module>r3      s    				 				             * * * * * * * *+
 
 
   eCI& eCI.> 4      r   