o
    i&                     @   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   U/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/debugpy/_vendored/__init__.py
<listcomp>   s    zlist_all.<locals>.<listcomp>r   )resolveprojectsr   r   r
   list_all   s   r   c                 C   s   | sd} t jt| S )zReturn 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   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 )zYield 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   
extensions
unvendoredmodnamer"   r%   r   r   r
   check_modulesY   s"   

r7   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   r0   r   insertremove)r   r   r   r   r
   vendoredm   s   r:   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)r:   r   )r   r1   r   r	   r   r   r
   	preimportz   s
   
"r;   )F)N)
contextlib	importlibr   r   r0   r   r   r   dirnameabspathr.   r   listdirr   r   r   r&   r-   r7   contextmanagerr:   r;   r   r   r   r
   <module>   s"   
	

