Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/test_importlib/source/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/test_importlib/source/__pycache__/util.cpython-34.pyo

�
g f��@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
dd�Zdd�Zej
d	d
��ZdS)�)�util�N)�supportcs8tjrdd�Stj���fdd��}|S)ztDecorator to protect sys.dont_write_bytecode from mutation and to skip
    tests that require it to be set to False.c_sdS)N�)�args�kwargsrr�D/opt/alt/python34/lib64/python3.4/test/test_importlib/source/util.py�<lambda>sz'writes_bytecode_files.<locals>.<lambda>cs6tj}dt_z�||�}Wd|t_X|S)NF)�sys�dont_write_bytecode)rrZoriginalZ	to_return)�fxnrr�wrappers		
z&writes_bytecode_files.<locals>.wrapper)r
r�	functools�wraps)rr
r)rr�writes_bytecode_filess	
!	rcCsaytjtjj|��Wn=tk
r\}z|jtjkrJ�nWYdd}~XnXdS)z�Ensure that the __pycache__ directory for PEP 3147 pyc file exists.

    :param bytecode_path: File system path to PEP 3147 pyc file.
    N)�os�mkdir�path�dirname�OSError�errnoZEEXIST)�
bytecode_path�errorrrr�ensure_bytecode_paths
rcgsd}g}i}d}d}z�tj�}||d<t�}x<|D]4}|jd�se|}	n|dtd��}	|j|	�|	tjkr�tj|	=n|jd�}
|}x\|
dd�D]J}t	j
j||�}t	j
j|�s�t	j
|�|j|�q�q�Wt	j
j||
dd�}t|d	��}
|
j|j|��WdQX|j|�|||<qGWtj|�}|j�tjd
|g�}|j�|VWd|dk	r�|jddd�n|dk	r|jddd�ntj|�XdS)
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.root�__init__z	.__init__�.�z.py�wr���r)�tempfileZmkdtemp�set�endswith�len�addr
�modules�splitrr�join�existsr�append�open�write�formatrZuncache�	__enter__Zimport_state�__exit__rZrmtree)�names�sourceZ
created_paths�mappingZ
state_managerZuncache_managerZtemp_dirZimport_names�nameZimport_nameZ
name_partsZ	file_pathZ	directory�filerrr�create_modules)sL
	
	





	r3)�r�
contextlibrrrZos.pathr
rZtestrrr�contextmanagerr3rrrr�<module>s