o
    5‘ði€
  ã                   @  s|   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZmZ ddd„ZG d	d
„ d
ƒZdd„ Zdd„ ZdS )zýReusable functions and classes for different types of integration tests.

For example ``Archive`` can be used to check the contents of distribution built
with setuptools, and ``run`` will always try to be as verbose as possible to
facilitate debugging.
é    )ÚannotationsN)ÚIterator©ÚPath)ÚZipFileÚZipInfoc                 C  sz   t j| dddi tj¥|pi ¥d�}|jd |j }tdƒ td| › d|j› d|› �ƒ |jd	kr2|S t  |j| |j|j¡‚)
NTúutf-8)Úcapture_outputÚtextÚencodingÚenvÚ
z<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~z	Command: z
return code: z

r   )	Ú
subprocessÚrunÚosÚenvironÚstdoutÚstderrÚprintÚ
returncodeÚCalledProcessError)Úcmdr   ÚrÚout© r   úc/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/tests/integration/helpers.pyr      s   û	
r   c                   @  s4   e Zd ZdZddd„Zddd„Zd	d
„ Zdd„ ZdS )ÚArchivez5Compatibility layer for ZipFile/Info and TarFile/InfoÚreturnÚNonec                 C  sH   || _ | d¡rt |d¡| _d S | d¡rt|ƒ| _d S t|› d�ƒ‚)Nztar.gzúr:gzÚzipz# doesn't seem to be a zip or tar.gz)Ú	_filenameÚendswithÚtarfileÚopenÚ_objr   Ú
ValueError)ÚselfÚfilenamer   r   r   Ú__init__)   s   

zArchive.__init__ú-Iterator[ZipInfo] | Iterator[tarfile.TarInfo]c                 C  s$   t | jdƒrt| j ¡ ƒS t| jƒS )NÚinfolist)Úhasattrr%   Úiterr+   )r'   r   r   r   Ú__iter__2   s   
zArchive.__iter__c                 C  s   t |dƒr|jS |jS )Nr(   )r,   r(   Úname)r'   Úzip_or_tar_infor   r   r   Úget_name7   s   
zArchive.get_namec                 C  s\   t | jdƒr%| j |¡}|d u rd|j› d| j› �}t|ƒ‚t| ¡ dƒS t| j |¡dƒS )NÚextractfilezInvalid z in r   )r,   r%   r2   r/   r!   r&   ÚstrÚread)r'   r0   ÚcontentÚmsgr   r   r   Úget_content<   s   zArchive.get_contentN)r   r   )r   r*   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r)   r.   r1   r7   r   r   r   r   r   &   s    

	r   c                 C  sZ   t  | d¡�}dd„ | ¡ D ƒ}W d   ƒ n1 sw   Y  dd„ |D ƒ}dd„ |D ƒS )Nr   c                 S  s   g | ]}t |ƒ‘qS r   r   ©Ú.0Úfr   r   r   Ú
<listcomp>H   ó    z%get_sdist_members.<locals>.<listcomp>c                 s  s$   � | ]}d   |jdd… ¡V  qdS )ú/é   N)ÚjoinÚpartsr<   r   r   r   Ú	<genexpr>J   s   €" z$get_sdist_members.<locals>.<genexpr>c                 S  s   h | ]}|r|’qS r   r   r<   r   r   r   Ú	<setcomp>K   r@   z$get_sdist_members.<locals>.<setcomp>)r#   r$   Úgetnames)Ú
sdist_pathÚtarÚfilesÚrelative_filesr   r   r   Úget_sdist_membersF   s
   ÿrL   c                 C  s8   t | ƒ�}t| ¡ ƒW  d   ƒ S 1 sw   Y  d S ©N)r   ÚsetÚnamelist)Ú
wheel_pathÚzipfiler   r   r   Úget_wheel_membersN   s   

$ÿrR   rM   )r;   Ú
__future__r   r   r   r#   Úcollections.abcr   Úpathlibr   rQ   r   r   r   r   rL   rR   r   r   r   r   Ú<module>   s    
 