File: //usr/local/lib/python3.10/test/support/__pycache__/import_helper.cpython-310.opt-1.pyc
o
�i8 � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZddlm Z e j
ddd��Zdd� Zd d
� Z
dd� Zddd�dd�Zdd� Zd dd�ZG dd� de�ZG dd� de�Zdd� Zdd� ZdS )!� N� )�unlinkTc c sR � | r$t �� � t �ddt� dV W d � dS 1 sw Y dS dV dS )z�Context manager to suppress package and module deprecation
warnings when importing them.
If ignore is False, this context manager has no effect.
�ignorez.+ (module|package)N)�warnings�catch_warnings�filterwarnings�DeprecationWarning)r � r �7/usr/local/lib/python3.10/test/support/import_helper.py�_ignore_deprecated_imports
s �
�"�
r c C s$ zt j| = W d S ty Y d S w �N)�sys�modules�KeyError)�namer r r
�unload s
�r c C sT t | � tjD ] }tj�|| d �}t|d � dD ]}ttjj||d�� qqdS )z�'Forget' a module was ever imported.
This removes the module from sys.modules and deletes any PEP 3147/488 or
legacy .pyc files.
z.py�c)� r � )�optimizationN) r r
�path�os�joinr � importlib�util�cache_from_source)�modname�dirname�source�optr r r
�forget$ s
��r c C sB t j�| �}tj�tj�| ��}tj�|| d �}t� ||� |S )a Move a PEP 3147/488 pyc file to its legacy pyc location.
:param source: The file system path to the source file. The source file
does not need to exist, however the PEP 3147/488 pyc file must exist.
:return: The file system path to the legacy pyc file.
r )
r r r r r r �abspathr �shutil�move)r Zpyc_fileZup_oneZ
legacy_pycr r r
�make_legacy_pyc4 s
r$ Fr )�required_onc C sr t |��+ z
t�| �W W d � S ty. } ztj�t|��r#� t� t
|���d}~ww 1 s2w Y dS )ac Import and return the module to be tested, raising SkipTest if
it is not available.
If deprecated is True, any module or package deprecation messages
will be suppressed. If a module is required on a platform but optional for
others, set required_on to an iterable of platform prefixes which will be
compared against sys.platform.
N)r r �
import_module�ImportErrorr
�platform�
startswith�tuple�unittestZSkipTest�str)r �
deprecatedr% �msgr r r
r&