o
    ß›h¤  ã                   @   s°   d dl Z d dlmZ d dlZd dlZddlmZ ej ej 	e
¡¡Zde e¡vr/ej e¡Zddd„Zd	d
„ Zddd„Zdd„ Zdd„ Zddd„Ze jddd„ƒZdd„ ZdS )é    N)Úimport_moduleé   )Ú_utilÚpydevdFc                 C   s   dg}| s|S dd„ |D ƒS )z%Return the list of vendored projects.r   c                 S   s   g | ]}t |ƒ‘qS © )Úproject_root)Ú.0Únamer   r   úPc:\Users\shubh\Videos\agent\nova\Lib\site-packages\debugpy/_vendored/__init__.pyÚ
<listcomp>   s    zlist_all.<locals>.<listcomp>r   )ÚresolveZprojectsr   r   r
   Úlist_all   s   r   c                 C   s   | sd} t j t| ¡S )z¼Return the path the root dir of the vendored project.

    If "project" is an empty string then the path prefix for vendored
    projects (e.g. "debugpy/_vendored/") will be returned.
    Ú )ÚosÚpathÚjoinÚVENDORED_ROOT)Úprojectr   r   r
   r      s   r   c                 k   s~   � |r*t  t¡� t j| fi |¤ŽD ]}|V  qW d  ƒ dS 1 s#w   Y  dS t| ƒ}t j|fi |¤ŽD ]}|V  q7dS )zAYield (dirname, basename, filename) for all files in the project.N)r   Úcwdr   Ziter_all_filesr   )r   ÚrelativeÚkwargsÚresultÚrootr   r   r
   Úiter_project_files(   s   €ÿ"ÿÿr   c                 c   st   � d}d}z
t d | ¡tƒ}W n	 ty   Y nw t|d|ƒ}t|d|ƒ}t| d||d�}|D ]\}}}|V  q/dS )z­Yield the filenames for all files in the project.

    The filenames are relative to "debugpy/_vendored".  This is most
    useful for the "package data" in a setup.py.
    Nz._{}_packagingÚ	prune_dirÚexclude_fileT)r   r   r   )r   ÚformatÚ__name__ÚImportErrorÚgetattrr   )r   r   r   ÚmodÚresultsÚ_Úfilenamer   r   r
   Úiter_packaging_files4   s    €ÿÿÿr$   c                     s   ˆ sJ ‚‡ fdd„}|S )zBReturn a module match func that matches any of the given prefixes.c                    s   ˆ D ]
}|   |¡r dS qdS )NTF)Ú
startswith)r	   ÚmoduleÚprefix©Úprefixesr   r
   ÚmatchO   s
   
ÿzprefix_matcher.<locals>.matchr   )r)   r*   r   r(   r
   Úprefix_matcherK   s   r+   c                 C   s„   |du rt | ƒ}g }i }ttj ¡ ƒD ]*\}}|||ƒsqzt|ddƒ}W n   d}Y |s4| |¡ q| |¡s=|||< q||fS )z5Verify that only vendored modules have been imported.NÚ__file__)r   ÚlistÚsysÚmodulesÚitemsr   Úappendr%   )r   r*   r   Ú
extensionsZ
unvendoredÚmodnamer    r#   r   r   r
   Úcheck_modulesY   s"   

€r4   c              	   c   sH   � |du r	t | ƒ}tj d|¡ z|V  W tj |¡ dS tj |¡ w )zDA context manager under which the vendored project will be imported.Nr   )r   r.   r   ÚinsertÚremove)r   r   r   r   r
   Úvendoredm   s   €r7   c                 K   sH   t | fi |¤Ž� |D ]}t|ƒ qW d  ƒ dS 1 sw   Y  dS )z=Import each of the named modules out of the vendored project.N)r7   r   )r   r/   r   r	   r   r   r
   Ú	preimportz   s
   
ÿ"ÿr8   )F)N)Ú
contextlibÚ	importlibr   r   r.   r   r   r   ÚdirnameÚabspathr,   r   Úlistdirr   r   r   r$   r+   r4   Úcontextmanagerr7   r8   r   r   r   r
   Ú<module>   s"   
	

