HEX
Server: LiteSpeed
System: Linux osault1.hostarmada.net 4.18.0-553.123.2.lve.el8.x86_64 #1 SMP Thu May 7 23:17:13 UTC 2026 x86_64
User: tucom (1048)
PHP: 8.4.24
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.6/site-packages/importlib_resources/tests/__pycache__/util.cpython-36.pyc
3

	LBj��@s�ddlZddlZddlZddlZddlZddlmZmZddlm	Z	ddlm
Z
ddlmZddlm
Z
dd	lmZGd
d�de�Zdd
d�Zdddffdd�ZGdd�dejd�ZGdd�d�ZGdd�de�ZdS)�N)�Path�PurePath�)�data01)�	zipdata01�)�ResourceReader)�
import_helper)�
ModuleSpecc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ReadercKst|�j|�dS)N)�vars�update)�self�kwargs�r�M/tmp/pip-build-44150kxb/importlib-resources/importlib_resources/tests/util.py�__init__szReader.__init__cCs|S)Nr)r�packagerrr�get_resource_readerszReader.get_resource_readercCs||_t|jt�r|j�|jS)N)�_path�
isinstance�file�	Exception)r�pathrrr�
open_resourceszReader.open_resourcecCs||_t|jt�r|j�|jS)N)rrrr)r�path_rrr�
resource_pathszReader.resource_pathcs>�|_t|jt�r|j�dd�}t�fdd�t||j�D��S)NcSs
|jd�S)N�/)�split)�entryrrr�part)sz Reader.is_resource.<locals>.partc3s&|]}t|�dko|d�kVqdS)rrN)�len)�.0�parts)rrr�	<genexpr>-sz%Reader.is_resource.<locals>.<genexpr>)rrrr�any�map�	_contents)rrr r)rr�is_resource$szReader.is_resourceccs"t|jt�r|j�|jEdHdS)N)rrrr')rrrr�contents0szReader.contentsN)	�__name__�
__module__�__qualname__rrrrr(r)rrrrrsrTcCs.d}tj|�}t||d|d�}||_||_|S)NZtestingpackagezdoes-not-exist)�origin�
is_package)�types�
ModuleTyper
�__spec__�
__loader__)�loaderr.�name�module�specrrr�create_package_from_loader6s
r7cCstt|||d�|�S)N)rrr')r7r)rrr.r)rrr�create_package?sr8c@sneZdZdZejdd��Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�CommonTestsz>
    Tests shared by test_open, test_path, and test_read.
    cCsdS)zl
        Call the pertinent legacy API function (e.g. open_text, path)
        on package and path.
        Nr)rrrrrr�executeKszCommonTests.executecCs|jtjd�dS)Nz
utf-8.file)r:rr*)rrrr�test_package_nameRszCommonTests.test_package_namecCs|jtd�dS)Nz
utf-8.file)r:r)rrrr�test_package_objectVszCommonTests.test_package_objectcCsd}|jt|�dS)Nz
utf-8.file)r:r)rrrrr�test_string_pathZszCommonTests.test_string_pathcCstd�}|jt|�dS)Nz
utf-8.file)rr:r)rrrrr�test_pathlib_path_szCommonTests.test_pathlib_pathcCstjtj=|jtjd�dS)Nz
utf-8.file)�sys�modulesrr*r:)rrrr�$test_importing_module_as_side_effectds
z0CommonTests.test_importing_module_as_side_effectc
Cs&|jt��|jtd�WdQRXdS)Nz
utf-8.file)�assertRaises�	TypeErrorr:r*)rrrr�test_non_package_by_nameisz$CommonTests.test_non_package_by_namec
Cs0|jt��tjd}|j|d�WdQRXdS)Nzimportlib_resources.tests.utilz
utf-8.file)rBrCr?r@r:)rr5rrr�test_non_package_by_packagens
z'CommonTests.test_non_package_by_packagecCs8tjd�}t|t�d�}|j|d�|j|jjd�dS)Ns
Hello, world!)rrz
utf-8.file)�io�BytesIOr8�FileNotFoundErrorr:�assertEqualr2r)r�
bytes_datarrrr�test_missing_pathts
zCommonTests.test_missing_pathcCs:tjd�}t}t||d�}|j|d�|j|jjd�dS)Ns
Hello, world!)rrz
utf-8.file)rFrG�__file__r8r:rIr2r)rrJrrrrr�test_extant_path}s

zCommonTests.test_extant_pathc
Cs6tt�t�d�}|jt��|j|d�WdQRXdS)N)rrz
utf-8.file)r8rHrBr:)rrrrr�test_useless_loader�szCommonTests.test_useless_loaderN)r*r+r,�__doc__�abc�abstractmethodr:r;r<r=r>rArDrErKrMrNrrrrr9Fs	r9)�	metaclassc@s0eZdZdZedd��Zedd��Zdd�ZdS)�ZipSetupBaseNcCs>t|jj�}|j}t|d�|_tjj|j�t	j
d�|_dS)Nzziptestdata.zipZziptestdata)r�
ZIP_MODULErL�parent�str�	_zip_pathr?r�append�	importlib�
import_module�data)�clsZ	data_pathZdata_dirrrr�
setUpClass�s
zZipSetupBase.setUpClasscCs~ytjj|j�Wntk
r&YnXytj|j=tj|jj=Wnt	k
rVYnXy|`|`Wnt
k
rxYnXdS)N)r?r�removerW�
ValueError�path_importer_cacher@r[r*�KeyError�AttributeError)r\rrr�
tearDownClass�s
zZipSetupBase.tearDownClasscCstj�}|jtjf|��dS)N)r	Z
modules_setupZ
addCleanupZmodules_cleanup)rr@rrr�setUp�szZipSetupBase.setUp)r*r+r,rT�classmethodr]rcrdrrrrrS�srSc@seZdZeZdS)�ZipSetupN)r*r+r,rrTrrrrrf�srf)T)rPrYrFr?r/Zpathlibrr�rrr�_compatr	�importlib.machineryr
rr7r8�ABCMetar9rSrfrrrr�<module>s %
	H#