Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/test_importlib/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/test_importlib/__pycache__/util.cpython-39.pyc

a

��g-H�@s�ddlZddlZddlZddlZddlZddlZddlmZmZmZddl	m
Z
ddlZddlZddl
Z
ddlZ
ddlmZmZddlmZddlZddlZddlZddlZddlmZddlmZe��Zde_de_d	ejvr�d	e_d
ejvr�d
e_e��a dt _!dt _"dt _#dt _$dt _%dd
�Z&e&�dd�Z'dDdd�Z(dEdd�Z)dFdd�Z*dZ+ej,dv�r�e-�.�Z/e/e-k�r|e-�0�Z/e
j!�1e/��s�dZ+e'd
�dZ2e3ej4�e3e2j4�d�Z4dd�Z5dGdd�Z6d d!�Z7ej8d"d#��Z9ej8dHdd$�d%d&��Z:ej8d'd(��Z;Gd)d*�d*�Z<Gd+d,�d,e<�Z=Gd-d.�d.e<�Z>d/d0�Z?d1d2�Z@ej8d3d4��ZAej8d5d6��ZBd7d8�ZCGd9d:�d:�ZDdId<d=�ZEGd>d?�d?ejF�ZGGd@dA�dA�ZHGdBdC�dCeH�ZIdS)J�N)�	machinery�util�invalidate_caches)�ResourceReader)�Path�PurePath)�support�)�data01)�	zipdata01�errno�	importlibZ	_testcapicCs`tjD]T}tjD]H}tj|}tj�||�}tj�|�r|t_|t_	|t_
|t_dSqqdS�N)�sys�pathr�EXTENSION_SUFFIXES�
EXTENSIONS�name�os�join�exists�ext�filename�	file_path)rrrr�r�4/usr/local/lib/python3.9/test/test_importlib/util.py�_extension_details's


rcCs4d|vrdnd}t�|�}tj||dd�}||d�S)zAImport a module from importlib both w/ and w/o _frozen_importlib.�.)r
r)�_frozen_importlib�_frozen_importlib_external)�freshZblocked��Frozen�Source)rZimport_fresh_module)�module_namer �frozen�sourcerrr�import_importlib7s
�r'c
Ks�|durtj}nt|t�s"||}d�||j�}||f}t�||�}|j|_|j|_	||_
|��D]\}}||}	t|||	�qb|S)Nz{}_{})
�unittestZTestCase�
isinstance�type�format�__name__�types�	new_class�
__module__Z_NAMEZ_KIND�items�setattr)
�cls�kind�base�kwargsr�basesZspecialized�attr�values�valuerrr�specialize_class@s
r:cKs0t|d|fi|��}t|d|fi|��}||fS)Nr"r#)r:)r2r4r5r%r&rrr�split_frozenSsr;cKst||fi|��Sr)r;)Z
test_classr4r5rrr�	test_bothYsr<T)�win32�cygwinFr#r!cCst�td�|�S)zRClass decorator that nullifies tests requiring a case-insensitive
    file system.z&requires a case-insensitive filesystem)r(�skipIf�CASE_INSENSITIVE_FS)�testrrr�case_insensitive_testsls
��rB�cCsVtj�||d�}t|d��}|�|�Wd�n1s<0Yd�||�|fS)N�.py�wz{}.{})rrr�open�writer+)�parentrZpkg_dir�contentrZsubfilerrr�	submoduless(rJcCsBt|d��$}|�d�t�|�Wd�S1s40YdS)znReads a pyc file and returns the unmarshalled code object within.

    No header validation is performed.
    �rb�N)rF�seek�marshal�load)Zpyc_pathZpyc_frrr�get_code_from_pyczs
rPcgs�|D]:}|dvrtd�|���ztj|=Wqty<Yq0qz4dVW|D]$}ztj|=WqNtypYqN0qNn,|D]$}ztj|=Wqzty�Yqz0qz0dS)z�Uncache a module from sys.modules.

    A basic sanity check is performed to prevent uncaching modules that either
    cannot/shouldn't be uncached.

    )rrNZimpzcannot uncache {0}N)�
ValueErrorr+r�modules�KeyError)�namesrrrr�uncache�s*�
�rU)�pkgc#s&�fdd�tjD�}t�d���}t�g|�R���t�|���t�tj�	|��}|rptj�	|d�}t�
��n|d}|dur�d}|dur�t|d��}|�|�Wd�n1s�0Y|VWd�n1s�0YWd�n1s�0YWd�n1�s0YdS)Ncs"g|]}|�d�d�kr|�qS)rr)�	partition)�.0�n�rrr�
<listcomp>��ztemp_module.<locals>.<listcomp>z__init__.pyrDrCrE)
rrRrZtemp_cwdrUZ
DirsOnSysPathrrrr�mkdirrFrG)rrIrV�	conflicts�cwd�location�modpathZmodfilerrZr�temp_module�s (rbcks�i}z�dgfdgfdgfdiffD]>\}}tt|�||<||vrP||}||=n|}tt||�q"t|�r|td�|�����dVW|��D]\}}tt||�q�n |��D]\}}tt||�q�0dS)a,Context manager to manage the various importers and stored state in the
    sys module.

    The 'modules' attribute is not supported as the interpreter state stores a
    pointer to the dict that the interpreter uses internally;
    reassigning to sys.modules does not have the desired effect.

    �	meta_pathr�
path_hooks�path_importer_cachezunrecognized arguments: {0}N)�getattrrr1�lenrQr+�keysr0)r5Z	originalsr7�defaultZ	new_valuer9rrr�import_state�s*
���rjc@s6eZdZdZid�dd�Zdd�Zdd�Zd	d
�ZdS)�
_ImporterMockz0Base class to help with creating importer mocks.)�module_codecGs�i|_i|_|D]�}|�d�s$|}n|dtd��}d|vrDd}n||kr^|�dd�d}n|}t�|�}||_d|_||_	||_
||kr�dg|_||j|<||vr|||j|<qdS)N�	.__init__rr	rz<mock __file__>z<mock __path__>)rRrl�endswithrg�rsplitr-�
ModuleType�
__loader__�__file__�__package__r7�__path__)�selfrlrTr�import_name�package�modulerrr�__init__�s*


z_ImporterMock.__init__cCs
|j|Sr�rR)rurrrr�__getitem__�sz_ImporterMock.__getitem__cCst|j���|_|j��|Sr)rUrRrh�_uncache�	__enter__�rurrrr}�s
z_ImporterMock.__enter__cGs|j�ddd�dSr)r|�__exit__)ru�exc_inforrrr�sz_ImporterMock.__exit__N)r,r/�__qualname__�__doc__ryr{r}rrrrrrk�s
rkc@s"eZdZdZddd�Zdd�ZdS)�mock_modulesz!Importer mock using PEP 302 APIs.NcCs||jvrdS|SdSrrz)ru�fullnamerrrr�find_modules
zmock_modules.find_modulecCsf||jvrt�nR|j|tj|<||jvrXz|j|�WntyVtj|=�Yn0|j|SdSr)rR�ImportErrorrrl�	Exception)rur�rrr�load_modules

zmock_modules.load_module)N)r,r/r�r�r�r�rrrrr��s
r�c@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
�	mock_specz!Importer mock using PEP 451 APIs.NcCsDz|j|}Wnty"YdS0tj||j|t|dd�d�}|S)Nrt)�loader�submodule_search_locations)rRrSr�spec_from_file_locationrrrf)rur�rrHrx�specrrr�	find_specs
�zmock_spec.find_speccCs|j|jvrt�|j|jSr)rrRr�)rur�rrr�
create_module$szmock_spec.create_modulecCs,z|j|jj�Wnty&Yn0dSr)rl�__spec__rrS�rurxrrr�exec_module)szmock_spec.exec_module)NN)r,r/r�r�r�r�r�rrrrr�s

r�cs(tjrdd�St����fdd��}|S)ztDecorator to protect sys.dont_write_bytecode from mutation and to skip
    tests that require it to be set to False.c_sdSrr)�argsr5rrr�<lambda>4r\z'writes_bytecode_files.<locals>.<lambda>cs2tj}dt_z�|i|��}W|t_n|t_0|S)NF)r�dont_write_bytecode)r�r5ZoriginalZ	to_return��fxnrr�wrapper5sz&writes_bytecode_files.<locals>.wrapper)rr��	functools�wraps)r�r�rr�r�writes_bytecode_files0s
r�c
CsNzt�tj�|��Wn2tyH}z|jtjkr4�WYd}~n
d}~00dS)z�Ensure that the __pycache__ directory for PEP 3147 pyc file exists.

    :param bytecode_path: File system path to PEP 3147 pyc file.
    N)rr]r�dirname�OSErrorr�EEXIST)�
bytecode_path�errorrrr�ensure_bytecode_pathAs
r�ccs*tj}|t_zdVW|t_n|t_0dS)z&Adjust and restore sys.pycache_prefix.N)r�pycache_prefix)�prefixZ_orig_prefixrrr�temporary_pycache_prefixMs
r�cgs�d}g}i}d}d}�zxt��}||d<t�}|D]�}|�d�sF|}	n|dtd��}	|�|	�|	tjvrttj|	=|�d�}
|}|
dd�D]2}t	j
�||�}t	j
�|�s�t	�
|�|�|�q�t	j
�||
dd�}t|d	�� }
|
�|�|��Wd�n1�s
0Y|�|�|||<q2t|�}|��t|gd
�}|��|VW|du�rl|�ddd�|du�r�|�ddd�t�|�n<|du�r�|�ddd�|du�r�|�ddd�t�|�0dS)aRTemporarily create each named module with an attribute (named 'attr')
    that contains the name passed into the context manager that caused the
    creation of the module.

    All files are created in a temporary directory returned by
    tempfile.mkdtemp(). This directory is inserted at the beginning of
    sys.path. When the context manager exits all created files (source and
    bytecode) are explicitly deleted.

    No magic is performed when creating packages! This means that if you create
    a module within a package you must also create the package's __init__ as
    well.

    zattr = {0!r}Nz.rootryrmr���rDrE�r)�tempfile�mkdtemp�setrnrg�addrrR�splitrrrrr]�appendrFrGr+rUr}rjrr�rmtree)rTr&Z
created_paths�mappingZ
state_managerZuncache_managerZtemp_dirZimport_namesrrvZ
name_partsrZ	directory�filerrr�create_modulesXsV




0



�

r�cs��fdd�}|S)zA mock sys.path_hooks entry.cs|�vrt��Sr)r�)�entry��entries�importerrr�hook�szmock_path_hook.<locals>.hookr)r�r�r�rr�r�mock_path_hook�sr�c@seZdZdd�ZdS)�CASEOKTestBasecs,d}t�fdd�|D��|kr(��d�dS)N)sPYTHONCASEOK�PYTHONCASEOKc3s|]}|�jjjjvVqdSr)r
�_bootstrap_external�_os�environ)rX�xr~rr�	<genexpr>�s�z4CASEOKTestBase.caseok_env_changed.<locals>.<genexpr>z/os.environ changes not reflected in _os.environ)�anyZskipTest)ruZshould_existZ
possibilitiesrr~r�caseok_env_changed�s��z!CASEOKTestBase.caseok_env_changedN)r,r/r�r�rrrrr��sr�rc	sNG���fdd�dt�}d}t�|�}|�}tj||d|d�}||_||_|S)NcsHeZdZdd�Z�fdd�Z�fdd�Z��fdd�Z��fd	d
�ZdS)zcreate_package.<locals>.ReadercSs|Srr�rurwrrr�get_resource_reader�sz2create_package.<locals>.Reader.get_resource_readercs||_t�t�r��n�SdSr��_pathr)r��rur)r�rr�
open_resource�s
z,create_package.<locals>.Reader.open_resourcecs||_t�t�r��n�SdSrr�)ru�path_r�rr�
resource_path�s
z,create_package.<locals>.Reader.resource_pathcsJ||_t�t�r���D],}|�d�}t|�dkr|d|krdSqdS)N�/r	rTF)r�r)r�r�rg)rur�r��parts��contentsrrr�is_resource�s

z*create_package.<locals>.Reader.is_resourcec3s"t�t�r���D]
}|VqdSr)r)r�)rur�r�rrr��s
z'create_package.<locals>.Reader.contentsN)r,r/r�r�r�r�r�r�r�r�r�rrr�Reader�s

r�Ztestingpackagezdoes-not-exist)�origin�
is_package)rr-rpr�
ModuleSpecr�rq)	r�rr�r�r�rrxr�r�rr�r�create_package�s#
�r�c@s�eZdZejdd��Zdd�Zdd�Zdd�Ze	�
ejd	kd
�dd��Z
d
d�Zdd�Zdd�Zdd�Zdd�Ze	�
ejdkd�dd��Ze	�
ejdkd�dd��Zdd�ZdS) �CommonResourceTestscCst�dSr)�NotImplementedError)rurwrrrr�execute�szCommonResourceTests.executecCs|�tjd�dS�N�
utf-8.file)r�r
r,r~rrr�test_package_name�sz%CommonResourceTests.test_package_namecCs|�td�dSr��r�r
r~rrr�test_package_object�sz'CommonResourceTests.test_package_objectcCsd}|�t|�dSr�r�r�rrr�test_string_path�sz$CommonResourceTests.test_string_path)��zrequires os.PathLike supportcCstd�}|�t|�dSr�)rr�r
r�rrr�test_pathlib_path�sz%CommonResourceTests.test_pathlib_pathcCsLtt�}|jd}|�t��|�t|�Wd�n1s>0YdSr�)rrrrH�assertRaisesrQr�r
)rur�	full_pathrrr�test_absolute_path�s
z&CommonResourceTests.test_absolute_pathcCs:|�t��|�td�Wd�n1s,0YdS)Nz../data01/utf-8.file)r�rQr�r
r~rrr�test_relative_path�sz&CommonResourceTests.test_relative_pathcCstjtj=|�tjd�dSr�)rrRr
r,r�r~rrr�$test_importing_module_as_side_effect�s
z8CommonResourceTests.test_importing_module_as_side_effectcCs:|�t��|�td�Wd�n1s,0YdSr�)r��	TypeErrorr�r,r~rrr�test_non_package_by_name�sz,CommonResourceTests.test_non_package_by_namecCsD|�t��&tjd}|�|d�Wd�n1s60YdS)Nztest.test_importlib.utilr�)r�r�rrRr�r�rrr�test_non_package_by_packages
z/CommonResourceTests.test_non_package_by_package)r�zNo ResourceReader in Python 2cCs8t�d�}t|t�d�}|�|d�|�|jjd�dS�Ns
Hello, world!�r�rr�)�io�BytesIOr��FileNotFoundErrorr��assertEqualrqr�)ru�
bytes_datarwrrr�test_resource_opener
s
z(CommonResourceTests.test_resource_openercCs:t�d�}t}t||d�}|�|d�|�|jjd�dSr�)r�r�rrr�r�r�rqr�)rur�rrwrrr�test_resource_paths

z&CommonResourceTests.test_resource_pathcCsJtt�t�d�}|�t��|�|d�Wd�n1s<0YdS)Nr�r�)r�r�r�r�r�rrr�test_useless_loaders
�z'CommonResourceTests.test_useless_loaderN)r,r/r��abc�abstractmethodr�r�r�r�r(r?r�version_infor�r�r�r�r�r�r�r�r�rrrrr��s"



r�c@s0eZdZdZedd��Zedd��Zdd�ZdS)�ZipSetupBaseNcCs>t|jj�}|j}t|d�|_tj�|j�t	�
d�|_dS)Nzziptestdata.zipZziptestdata)r�
ZIP_MODULErrrH�str�	_zip_pathrrr�r
�
import_module�data)r2Z	data_pathZdata_dirrrr�
setUpClass#s
zZipSetupBase.setUpClasscCsxztj�|j�Wnty$Yn0ztj|j=tj|jj=Wnt	yRYn0z|`|`Wnt
yrYn0dSr)rr�remover�rQrerRr�r,rS�AttributeError)r2rrr�
tearDownClass+s
zZipSetupBase.tearDownClasscCs t��}|jtjg|�R�dSr)rZ
modules_setupZ
addCleanupZmodules_cleanup)rurRrrr�setUp>szZipSetupBase.setUp)r,r/r�r��classmethodr�r�r�rrrrr� s

r�c@seZdZeZdS)�ZipSetupN)r,r/r�rr�rrrrrCsr)N)N)N)rC)rC)Tr)Jr��builtins�
contextlibrr�r
rrr�
importlib.abcrr�rNrZos.path�pathlibrrrArr(rr�r-rCr
r�SimpleNamespaceZBUILTINSZ	good_nameZbad_name�builtin_module_namesrrrrrrrr'r:r;r<r@�platformrr�upperZchanged_name�lowerrZsource_importlib�staticmethod�
__import__rBrJrP�contextmanagerrUrbrjrkr�r�r�r�r�r�r�r�r��ABCr�r�rrrrr�<module>s�


	



�



)


9		
2J#

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists