Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/distutils/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/distutils/tests/__pycache__/support.cpython-38.pyc
U

@��g��@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	Z
ddlmZddl
mZmZmZmZmZddlmZGdd�de�ZGd	d
�d
e�ZGdd�d�ZGd
d�de�Zdd�Zdd�Zdd�ZdS)z&Support code for distutils test cases.�N)�deepcopy)�log)�DEBUG�INFO�WARN�ERROR�FATAL)�Distributioncs@eZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Z�ZS)�LoggingSilencercs6t���t�tj�|_tjj|_|jtj_g|_	dS�N)
�super�setUpr�
set_thresholdr�	threshold�Log�_log�_old_log�logs��self��	__class__��6/opt/cppython/lib/python3.8/distutils/tests/support.pyr
s



zLoggingSilencer.setUpcs$t�|j�|jtj_t���dSr)rrrrrrr�tearDownrrrrrs
zLoggingSilencer.tearDowncCsT|tttttfkr"tdt|���t|t�s>tdt	|�j
��|j�|||f�dS)Nz%s wrong log levelzmsg should be str, not '%.200s')
rrrrr�
ValueError�str�
isinstance�	TypeError�type�__name__r�append)r�level�msg�argsrrrr!s
�zLoggingSilencer._logcsdd�}�fdd�|jD�S)NcSs||Srr)r#r$rrr�_format*sz)LoggingSilencer.get_logs.<locals>._formatcs"g|]\}}}|�kr||�qSrr)�.0r"r#r$��levelsrr�
<listcomp>,s�z,LoggingSilencer.get_logs.<locals>.<listcomp>�r)rr(r%rr'r�get_logs)s
�zLoggingSilencer.get_logscCs
g|_dSrr*rrrr�
clear_logs/szLoggingSilencer.clear_logs)	r �
__module__�__qualname__r
rrr+r,�
__classcell__rrrrr
s

r
csHeZdZdZ�fdd�Z�fdd�Zdd�Zdd	d
�Zddd
�Z�Z	S)�TempdirManagerz}Mix-in class that handles temporary directories for test cases.

    This is intended to be used with unittest.TestCase.
    cst���t��|_g|_dSr)rr
�os�getcwd�old_cwd�tempdirsrrrrr
9s

zTempdirManager.setUpcs8t�|j�t���|jr4|j��}tj�	|�qdSr)
r1�chdirr3rrr4�pop�test�support�rmtree)rZtmpdirrrrr>s


zTempdirManager.tearDowncCst��}|j�|�|S)zjCreate a temporary directory that will be cleaned up.

        Returns the path of the directory.
        )�tempfile�mkdtempr4r!)r�drrrr;GszTempdirManager.mkdtemp�xxxcCsBt|ttf�rtjj|�}t|d�}z|�|�W5|��XdS)zWWrites a file in the given path.


        path can be a string or a sequence.
        �wN)	r�list�tupler1�path�join�open�close�write)rrAZcontent�frrr�
write_filePs
zTempdirManager.write_file�foocKs2|��}tj�||�}t�|�t|d�}||fS)aWill generate a test environment.

        This function creates:
         - a Distribution instance using keywords
         - a temporary directory with a package structure

        It returns the package directory and the distribution
        instance.
        )Zattrs)r;r1rArB�mkdirr	)rZpkg_name�kwZtmp_dirZpkg_dir�distrrr�create_dist^s



zTempdirManager.create_dist)r=)rH)
r r-r.�__doc__r
rr;rGrLr/rrrrr03s		
r0c@s eZdZdZdd�Zdd�ZdS)�DummyCommandzAClass to store options for retrieval via set_undefined_options().cKs"|��D]\}}t|||�qdSr)�items�setattr)r�kwargsrJ�valrrr�__init__sszDummyCommand.__init__cCsdSrrrrrr�ensure_finalizedwszDummyCommand.ensure_finalizedN)r r-r.rMrSrTrrrrrNpsrNcs(eZdZ�fdd�Z�fdd�Z�ZS)�EnvironGuardcstt|���ttj�|_dSr)rrUr
rr1�environ�old_environrrrrr
}szEnvironGuard.setUpcsf|j��D]"\}}tj�|�|kr
|tj|<q
ttj���D]}||jkr<tj|=q<tt|��	�dSr)
rWrOr1rV�getr@�keysrrUr)r�key�valuerrrr�s

zEnvironGuard.tearDown)r r-r.r
rr/rrrrrU{srUcCs(t�}|dkrt�d��t�||�dS)akHelper for tests that need the xxmodule.c source file.

    Example use:

        def test_compile(self):
            copy_xxmodule_c(self.tmpdir)
            self.assertIn('xxmodule.c', os.listdir(self.tmpdir))

    If the source file can be found, it will be copied to *directory*.  If not,
    the test will be skipped.  Errors during copy are not caught.
    Nz>cannot find xxmodule.c (test must run in the python build dir))�_get_xxmodule_path�unittestZSkipTest�shutil�copy)Z	directory�filenamerrr�copy_xxmodule_c�s
rac
Csft�d�}tj�tj�t�d�tj�|dd�tj�|ddddd�g}|D]}tj�|�rH|SqHdS)N�srcdirz
xxmodule.cZModulesz..)�	sysconfig�get_config_varr1rArB�dirname�__file__�exists)rbZ
candidatesrArrrr\�s
�
r\cCs~tjdkrtj�d�|_n`t�d�rzt�d�}|dkr@dg|_n:tj	dkrRg|_n(|�
d�\}}}d	d
�|�tj�D�|_dS)a�Function needed to make build_ext tests pass.

    When Python was built with --enable-shared on Unix, -L. is not enough to
    find libpython<blah>.so, because regrtest runs in a tempdir, not in the
    source directory where the .so lives.

    When Python was built with in debug mode on Windows, build_ext commands
    need their debug attribute set, and it is not done automatically for
    some reason.

    This function handles both of these things.  Example use:

        cmd = build_ext(dist)
        support.fixup_build_ext(cmd)
        cmd.ensure_finalized()

    Unlike most other Unix platforms, Mac OS X embeds absolute paths
    to shared libraries into executables, so the fixup is not needed there.
    �ntz_d.exeZPy_ENABLE_SHAREDZ	RUNSHAREDN�.�darwin�=cSsg|]}|r|�qSrr)r&r<rrrr)�sz#fixup_build_ext.<locals>.<listcomp>)
r1�name�sys�
executable�endswith�debugrcrdZlibrary_dirs�platform�	partition�split�pathsep)�cmdZ	runsharedrlZequalsr[rrr�fixup_build_ext�s




rv)rMr1rmr^r:r]rcr_rZtest.supportr7Z	distutilsrZ
distutils.logrrrrrZdistutils.corer	�objectr
r0rNrUrar\rvrrrr�<module>s$#=

F1le Man4ger