관리-도구
편집 파일: filesystem.cpython-311.pyc
� �DgV � � � d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl m Z mZmZm Z mZmZ d dlmZ d dlmZ d dlmZ ded efd �Zedede d eeddf fd�� � Z ed d�� � ej � � Zded efd�Zded efd�Zdeded e e fd�Zded eeef fd�Z ded efd�Z!ded eeef fd�Z"ded efd�Z#dS )� N)�contextmanager)�NamedTemporaryFile)�Any�BinaryIO� Generator�List�Union�cast)�get_path_uid)�format_size)�retry�path�returnc �� � t j dk st t d� � sdS t j � | � � sJ �d }| |k r�t j � | � � r^t j � � dk r( t | � � }n# t $ r Y dS w xY w|dk S t j | t j � � S | t j � | � � } }| |k ��dS )N�win32�geteuidTr F) �sys�platform�hasattr�osr �isabs�lexistsr r �OSError�access�W_OK�dirname)r �previous�path_uids �~/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/utils/filesystem.py�check_path_ownerr s� � � �|�w���g�b�)�&<�&<���t� �7�=�=��������H� �(� � � �7�?�?�4� � � 9��z�|�|�q� � �!�+�D�1�1�H�H��� !� !� !� �5�5�!�����1�}�$��y��r�w�/�/�/�!�2�7�?�?�4�#8�#8�d�H� �(� � � �5s �B � B&�%B&�kwargsc + � K � t ddt j � | � � t j � | � � dd�|��5 }t t |� � } |V � |� � � t j |� � � � � n?# |� � � t j |� � � � � w xY w ddd� � dS # 1 swxY w Y dS )a% Return a file-like object pointing to a tmp file next to path. The file is created securely and is ensured to be written to disk after the context reaches its end. kwargs will be passed to tempfile.NamedTemporaryFile to control the way the temporary file will be opened. Fz.tmp)�delete�dir�prefix�suffixN� ) r r r r �basenamer r �flush�fsync�fileno)r r! �f�results r �adjacent_tmp_filer. * s0 � � � � � ���G�O�O�D�!�!��w����%�%�� � � � � � &� ��h��"�"�� &��L�L�L��L�L�N�N�N��H�V�]�]�_�_�%�%�%�%�� �L�L�N�N�N��H�V�]�]�_�_�%�%�%�%����%�&� &� &� &� &� &� &� &� &� &� &� &���� &� &� &� &� &� &s* �C1�%B$�);C1�$<C � C1�1C5�8C5� g �?)�stop_after_delay�waitc �J � t j � | � � sGt j � | � � }|| k rn!|} t j � | � � �Gt j dk rt j | t j � � S t | � � S )zgCheck if a directory is writable. Uses os.access() on POSIX, tries creating files on Windows. �posix)r r �isdirr �namer r �_test_writable_dir_win)r �parents r �test_writable_dirr8 H s� � � �g�m�m�D�!�!� ������&�&���T�>�>���� �g�m�m�D�!�!� � �w�'����y��r�w�'�'�'�!�$�'�'�'� c �� �� d}d�t d� � D ]�}|d� �fd�t d� � D � � � � z }t j � | |� � } t j |t j t j z t j z � � }t j |� � t j |� � dS # t $ r Y ��t $ r Y dS w xY wt d � � �) N�(accesstest_deleteme_fishfingers_custard_�$abcdefghijklmnopqrstuvwxyz0123456789� � c 3 �@ �K � | ]}t j �� � V � �d S �N)�random�choice)�.0�_�alphabets �r � <genexpr>z)_test_writable_dir_win.<locals>.<genexpr>` s- �� � � �!L�!L�a�&�-��"9�"9�!L�!L�!L�!L�!L�!Lr9 � TFz3Unexpected condition testing for writable directory) �range�joinr r �open�O_RDWR�O_CREAT�O_EXCL�close�unlink�FileExistsError�PermissionErrorr )r r( rD r5 �file�fdrE s @r r6 r6 Z s �� � :�H�5�H� �2�Y�Y� � ���"�'�'�!L�!L�!L�!L�5��8�8�!L�!L�!L�L�L�L���w�|�|�D�$�'�'�� ����r�y�2�:�5�� �A�B�B�B� �H�R�L�L�L��I�d�O�O�O��4�4�� � � � ��D�� � � � �5�5�5� ���� �G� H� H�Hs �)9C � C'� C'�&C'�patternc � �� g }t j | � � D ]<\ �}}t j ||� � }|� �fd�|D � � � � �=|S )z�Returns a list of absolute paths of files beneath path, recursively, with filenames which match the UNIX-style shell glob pattern.c 3 �X �K � | ]$}t j � �|� � V � �%d S r@ )r r rI )rC r, �roots �r rF zfind_files.<locals>.<genexpr>| s3 �� � � �=�=��b�g�l�l�4��+�+�=�=�=�=�=�=r9 )r �walk�fnmatch�filter�extend)r rT r- rD �files�matchesrW s @r � find_filesr^ v sg �� � �F��'�$�-�-� >� >���a���.���0�0��� � �=�=�=�=�W�=�=�=�=�=�=�=��Mr9 c � � t j � | � � rdS t j � | � � S )Nr )r r �islink�getsize�r s r � file_sizerc � s1 � � �w�~�~�d��� ��q� �7�?�?�4� � � r9 c �: � t t | � � � � S r@ )r rc rb s r �format_file_sizere � s � ��y����'�'�'r9 c � � d}t j | � � D ]=\ }}}|D ]4}t j � ||� � }|t |� � z }�5�>|S )Ng )r rX r rI rc )r �sizerW �_dirsr\ �filename� file_paths r �directory_sizerk � si � ��D� �g�d�m�m� )� )���e�U�� )� )�H�����T�8�4�4�I��I�i�(�(�(�D�D� )� �Kr9 c �: � t t | � � � � S r@ )r rk rb s r �format_directory_sizerm � s � ��~�d�+�+�,�,�,r9 )$rY r �os.pathrA r � contextlibr �tempfiler �typingr r r r r r �pip._internal.utils.compatr �pip._internal.utils.miscr �pip._internal.utils.retryr �str�boolr r. �replacer8 r6 r^ �int�floatrc re rk rm r'