HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/distutils/tests/__pycache__/support.cpython-37.pyc
B

!��g��@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
mZmZmZddlmZGdd�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__��3/usr/local/lib/python3.7/distutils/tests/support.pyrs



zLoggingSilencer.setUpcs$t�|j�|jtj_t���dS)N)rr
rrrrr�tearDown)r)rrrrs
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||S)Nr)r r!rrr�_format)sz)LoggingSilencer.get_logs.<locals>._formatcs"g|]\}}}|�kr||�qSrr)�.0rr r!)�levelsrr�
<listcomp>+sz,LoggingSilencer.get_logs.<locals>.<listcomp>)r)rr$r"r)r$r�get_logs(s
zLoggingSilencer.get_logscCs
g|_dS)N)r)rrrr�
clear_logs.szLoggingSilencer.clear_logs)	r�
__module__�__qualname__rrrr&r'�
__classcell__rr)rrr
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|_dS)N)rr�os�getcwd�old_cwd�tempdirs)r)rrrr8s

zTempdirManager.setUpcsBt�|j�t���x&|jr<|j��}t�|tj	dk�qWdS)N)�nt�cygwin)
r,�chdirr.rrr/�pop�shutilZrmtree�name)r�d)rrrr=s


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

        Returns the path of the directory.
        )�tempfile�mkdtempr/r)rr6rrrr8FszTempdirManager.mkdtemp�xxxcCsBt|ttf�rtjj|�}t|d�}z|�|�Wd|��XdS)zWWrites a file in the given path.


        path can be a string or a sequence.
        �wN)	r�list�tupler,�path�join�open�write�close)rr=Zcontent�frrr�
write_fileOs
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)r8r,r=r>�mkdirr	)rZpkg_name�kwZtmp_dirZpkg_dirZdistrrr�create_dist]s



zTempdirManager.create_dist)r9)rD)
rr(r)�__doc__rrr8rCrGr*rr)rrr+2s		
r+c@s eZdZdZdd�Zdd�ZdS)�DummyCommandzAClass to store options for retrieval via set_undefined_options().cKs&x |��D]\}}t|||�q
WdS)N)�items�setattr)r�kwargsrF�valrrr�__init__rszDummyCommand.__init__cCsdS)Nr)rrrr�ensure_finalizedvszDummyCommand.ensure_finalizedN)rr(r)rHrNrOrrrrrIosrIcs(eZdZ�fdd�Z�fdd�Z�ZS)�EnvironGuardcstt|���ttj�|_dS)N)rrPrrr,�environ�old_environ)r)rrrr|szEnvironGuard.setUpcsnx0|j��D]"\}}tj�|�|kr|tj|<qWx(ttj���D]}||jkrBtj|=qBWtt|��	�dS)N)
rRrJr,rQ�getr<�keysrrPr)r�key�value)rrrr�s
zEnvironGuard.tearDown)rr(r)rrr*rr)rrrPzsrPcCs(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�unittestZSkipTestr4�copy)Z	directory�filenamerrr�copy_xxmodule_c�s
r[c
Csft�d�}tj�tj�t�d�tj�|dd�tj�|ddddd�g}x|D]}tj�|�rJ|SqJWdS)N�srcdirz
xxmodule.cZModulesz..)�	sysconfig�get_config_varr,r=r>�dirname�__file__�exists)r\Z
candidatesr=rrrrW�s

rWcCs~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.
    r0z_d.exeZPy_ENABLE_SHAREDZ	RUNSHAREDN�.�darwin�=cSsg|]}|r|�qSrr)r#r6rrrr%�sz#fixup_build_ext.<locals>.<listcomp>)
r,r5�sys�
executable�endswith�debugr]r^Zlibrary_dirs�platform�	partition�split�pathsep)�cmdZ	runsharedr5ZequalsrVrrr�fixup_build_ext�s




rn)rHr,rer4r7rXr]rYrZ	distutilsrZ
distutils.logrrrrrZdistutils.corer	�objectr
r+rIrPr[rWrnrrrr�<module>s"#=