%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core22/current/usr/lib/python3.10/test/support/__pycache__/
Upload File :
Create Path :
Current File : //snap/core22/current/usr/lib/python3.10/test/support/__pycache__/os_helper.cpython-310.pyc

o

�*�g�M�	@sddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ejdkr0dZndZd�
ee���ZedZejdkrMddlZe�de�ZdZejd	kre��jd
kr~edZz	e�e���Wn	eyqYn1wedee��f�dZn#ejdkr�z	d
�e���Wney�ed�e��d�ZYnw	dZdD]Zze�e�e��ekr�e�Wn	ey�Yq�weZe� �Z!dZ"dD]Zz	e�e���Wq�ey�e�e�eZ"Ynwer�eeZ#ndZ#e#p�eZ$dd�Z%da&dd�Z'dd�Z(da)dd�Z*dd�Z+dd�Z,ej�-d��r.dGd!d"�Z.d#d$�Z/d%d&�Z0d'd(�Z1d)d*�Z2nej,Z/ej3Z0d+d(�Z1d,d*�Z2d-d.�Z3d/d0�Z4ej5dHd1d2��Z6ej5dGd3d4��Z7ej5dId6d7��Z8d8d9�Z9ej5d:d;��Z:d<d=�Z;Gd>d?�d?�Z<d@dA�Z=e>edB��r�ej5dCdD��Z?GdEdF�dFej@jA�ZBdS)J�N�javaz$testz@testz	{}_{}_tmpu-àòɘŁğ�darwin�NFD�nt�u-共Ł♡ͣ�ztWARNING: The filename %r CAN be encoded by the filesystem encoding (%s). Unicode filename tests may not be effective��s-��surrogateescape�)�æuİuŁuφuКuאu،uتuก� u€)s�w�rs���s�s��cCs8ttd�}z
|��W|��tt�S|��tt�w)z`
    Create an invalid file descriptor by opening and closing a file and return
    its fd.
    �wb)�open�TESTFN�fileno�close�unlink��file�r�-/usr/lib/python3.10/test/support/os_helper.py�make_bad_fd�s

�
rc
Cs^tdurtStd}z
t�t|�d}Wntttfy%d}Y|a|Swt�|�|a|S)N�can_symlinkTF)�_can_symlinkr�os�symlink�OSError�NotImplementedError�AttributeError�remove)�symlink_path�canrrrr�s�
rcC� t�}d}|r	|St�|�|�S)z8Skip decorator for tests that require functional symlinkz*Requires functional symlink implementation)r�unittest�skip��test�ok�msgrrr�skip_unless_symlink��r(c		CsLddl}tdur
tSttd�sd}|a|Sddl}|��}|j|d�\}}zsttd��D}z0t�	|dd�t�	|dd	�t�	|�
�dd�|��}t�
d
|�}|dupZt|�d��dk}Wntygd}YnwWd�n1srwYWtt�t|�t|�|a|SWtt�t|�t|�|a|Stt�t|�t|�w)
Nr�setxattrF��dirrs	user.test�strusted.foos42z
2.6.(\d{1,2})��')�tempfile�
_can_xattr�hasattrr�platform�mkdtemp�mkstempr
rr*r�release�re�match�int�grouprr�rmdir)	r0r r3�tmp_dir�tmp_fp�tmp_name�fp�kernel_version�mrrr�	can_xattr�sL
������
rBcCr!)zDSkip decorator for tests that require functional extended attributesz(no non-broken extended attribute support)rBr"r#r$rrr�skip_unless_xattr�r)rCc	Cs(zt|�WdSttfyYdSw�N)�_unlink�FileNotFoundError�NotADirectoryError��filenamerrrr�s
�r�winFcCs�||�|r	|}ntj�|�\}}|pd}d}|dkr9t�|�}|r&|s,dS||vs,dSt�|�|d9}|dkstjd|tdd�dS)N�.g����MbP?g�?rz)tests may fail, delete still pending for ���
stacklevel)	r�path�split�listdir�time�sleep�warnings�warn�RuntimeWarning)�func�pathname�waitall�dirname�name�timeout�Lrrr�_waitfor�s$
�
�

�r^cC�ttj|�dSrD)r^rrrHrrrrE�rEcCr_rD)r^rr;�rZrrr�_rmdirr`rbcs>ddlm���fdd��t�|dd�t�fdd�|�dS)	Nr��
_force_runcs��|tj|�D]L}tj�||�}zt�|�j}Wnty7}ztd||ftj	d�d}WYd}~nd}~wwt
�|�rLt�|dd��|tj
|�q�|tj|�qdS)Nz-support.rmtree(): os.lstat(%r) failed with %srrT�rY)rrQrO�join�lstat�st_moder�print�sys�
__stderr__�stat�S_ISDIRr^r;r)rOr[�fullname�mode�exc�rd�
_rmtree_innerrrrrs$����
�_rmtree.<locals>._rmtree_innerTrecs�|tj|�SrD)rr;)�prcrr�<lambda>.sz_rmtree.<locals>.<lambda>)�test.supportrdr^�rOrrqr�_rmtreesrxcCs^zddl}Wn
tyY|Sw|�t|�d�}|jj�||t|��}|r-|d|�S|S)Nrr)�ctypes�ImportError�create_unicode_buffer�len�windll�kernel32�GetLongPathNameW)rOry�buffer�lengthrrr�	_longpath0s��r�csNddl}z|�|�WdStyYnw�fdd���|�t�|�dS)Nrc	s�ddlm}||tj|�D]5}tj�||�}zt�|�j}Wnty)d}Ynwt	�
|�r;�|�||tj|�q
||tj|�q
dS)Nrrc)
rvrdrrQrOrfrgrhrrlrmr;r)rOrdr[rnro�rrrrrrIs�
�rs)�shutil�rmtreerrr;)rOr�rr�rrxAs
�
cC�|SrDrrwrrrr�Y�cC�$zt|�WdStyYdSwrD)rbrFrarrrr;]�
�r;cCr�rD)rxrFrwrrrr�dr�r�c
cs��ddl}d}|dur|��}d}tj�|�}n-z	t�|�d}Wn#tyD}z|s,�tjd|�d|��t	dd�WYd}~nd}~ww|rKt�
�}z|VW|r^|t�
�kr`t|�dSdSdS|ro|t�
�krpt|�www)	a�Return a context manager that creates a temporary directory.

    Arguments:

      path: the directory to create temporarily.  If omitted or None,
        defaults to creating a temporary directory using tempfile.mkdtemp.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, if the path is specified and cannot be
        created, only a warning is issued.

    rNFTz5tests may fail, unable to create temporary directory �: �rM)r0r4rrO�realpath�mkdirrrTrUrV�getpidr�)rO�quietr0�dir_createdrp�pidrrr�temp_dirks>�
������
�r�c
cs��t��}zt�tj�|��Wn#ty3}z|s�tjd|�d|��tdd�WYd}~nd}~wwz
t��VWt�|�dSt�|�w)agReturn a context manager that changes the current working directory.

    Arguments:

      path: the directory to use as the temporary current working directory.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, it issues only a warning and keeps the current
        working directory the same.

    zBtests may fail, unable to change the current working directory to r�r�rMN)	r�getcwd�chdirrOr�rrTrUrV)rOr��	saved_dirrprrr�
change_cwd�s&�
�����r��tempcwdc	csv�t||d��*}t||d��}|VWd�n1swYWd�dSWd�dS1s4wYdS)a�
    Context manager that temporarily creates and changes the CWD.

    The function temporarily changes the current working directory
    after creating a temporary directory in the current directory with
    name *name*.  If *name* is None, the temporary directory is
    created using tempfile.mkdtemp.

    If *quiet* is False (default) and it is not possible to
    create or change the CWD, an error is raised.  If *quiet* is True,
    only a warning is raised and the original CWD is used.

    )rOr�)r�N)r�r�)r[r��	temp_path�cwd_dirrrr�temp_cwd�s���"�r�cCs(t�|tjtjBtjB�}t�|�dS)z>Create an empty file. If the file already exists, truncate it.N)rr
�O_WRONLY�O_CREAT�O_TRUNCr)rI�fdrrr�create_empty_file�sr�c	csD�tj�|�s	J�t�|tj�}z|VWt�|�dSt�|�w)z&Open a file descriptor to a directory.N)rrO�isdirr
�O_RDONLYr)rO�dir_fdrrr�open_dir_fd�s�r�c	Cs�ddl}|j|d��0}|j}|��}||kr|��}ztj�||�WWd�Sty9YWd�dSw1s=wYdS)zODetects if the file system for the specified directory
    is case-insensitive.rNr+F)	r0�NamedTemporaryFiler[�upper�lowerrrO�samefilerF)�	directoryr0�base�	base_path�	case_pathrrr�fs_is_case_insensitive�s���r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�FakePathz.Simple implementing of the path protocol.
    cCs
||_dSrDrw)�selfrOrrr�__init__��
zFakePath.__init__cCsd|j�d�S)Nz
<FakePath �>rw�r�rrr�__repr__�szFakePath.__repr__cCs0t|jt�st|jt�rt|jt�r|j�|jSrD)�
isinstancerO�
BaseException�type�
issubclassr�rrr�
__fspath__�s
�
�zFakePath.__fspath__N)�__name__�
__module__�__qualname__�__doc__r�r�r�rrrrr��s
r�c	Cs�tj�d�rzt�d�}t|�dWStyYnwd}ttd�r4zt�d�}Wn	t	y3Ynwd}tjdkrez	d	dl
}|jWntt
fyOYnwi}|j|j|jfD]
}|�|d	�||<qZzMd	}t|�D],}zt�|�}Wnt	y�}z
|jtjkr��WYd}~qld}~wwt�|�|d7}qlW|dur�|j|j|jfD]
}|�|||�q�|S|dur�|j|j|jfD]}|�|||�q�ww)
z/Count the number of open file descriptors.
    )�linux�freebsdz
/proc/self/fdr.��sysconf�SC_OPEN_MAXN�win32r)rjr3�
startswithrrQr|rFr2r�r�msvcrt�CrtSetReportModerrz�CRT_WARN�	CRT_ERROR�
CRT_ASSERT�range�dup�errno�EBADFr)	�names�MAXFD�	old_modesr��report_type�countr��fd2�errr�fd_count�sv
�
�

��
����

�����r��umaskc	cs0�t�|�}zdVWt�|�dSt�|�w)z8Context manager that temporarily sets the process umask.N)rr�)r��oldmaskrrr�
temp_umask3s
�
r�c@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�EnvironmentVarGuardz_Class to help protect the environment variable properly.  Can be used as
    a context manager.cCstj|_i|_dSrD)r�environ�_environ�_changedr�rrrr�Bs
zEnvironmentVarGuard.__init__cCs
|j|SrD)r��r��envvarrrr�__getitem__Fr�zEnvironmentVarGuard.__getitem__cCs*||jvr|j�|�|j|<||j|<dSrD�r�r��get�r�r��valuerrr�__setitem__Is
zEnvironmentVarGuard.__setitem__cCs6||jvr|j�|�|j|<||jvr|j|=dSdSrDr�r�rrr�__delitem__Os


�zEnvironmentVarGuard.__delitem__cCs
|j��SrD)r��keysr�rrrr�Vr�zEnvironmentVarGuard.keyscC�
t|j�SrD)�iterr�r�rrr�__iter__Yr�zEnvironmentVarGuard.__iter__cCr�rD)r|r�r�rrr�__len__\r�zEnvironmentVarGuard.__len__cCs|||<dSrDrr�rrr�set_szEnvironmentVarGuard.setcCs
||=dSrDrr�rrr�unsetbr�zEnvironmentVarGuard.unsetcCr�rDrr�rrr�	__enter__er�zEnvironmentVarGuard.__enter__cGsF|j��D]\}}|dur||jvr|j|=q||j|<q|jt_dSrD)r��itemsr�rr�)r��
ignore_exc�k�vrrr�__exit__hs
�zEnvironmentVarGuard.__exit__N)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�=sr�)F)NF)r�F)C�collections.abc�collections�
contextlibr�rr7rlrjrRr"rTr[�TESTFN_ASCII�formatr��TESTFN_UNICODEr3�unicodedata�	normalize�TESTFN_UNENCODABLE�getwindowsversion�encode�getfilesystemencoding�UnicodeEncodeErrorri�decode�UnicodeDecodeError�FS_NONASCII�	character�fsdecode�fsencode�UnicodeErrorr��SAVEDCWD�TESTFN_UNDECODABLE�TESTFN_NONASCIIrrrrr(r1rBrCrr�r^rErbrxr�r;r��contextmanagerr�r�r�r�r�r�r�r�r2r��abc�MutableMappingr�rrrr�<module>s�


�
��
��!���

!
!
(

<
	

Zerion Mini Shell 1.0