Your IP : 216.73.216.213
�
g f� � @ s� d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m
Z
d d � Z d d � Z e j
d d
� � Z d S)� )�util� N)�supportc s8 t j r d d � St j � � � f d d � � } | S)ztDecorator to protect sys.dont_write_bytecode from mutation and to skip
tests that require it to be set to False.c _ s d S)N� )�args�kwargsr r �D/opt/alt/python34/lib64/python3.4/test/test_importlib/source/util.py�<lambda> s z'writes_bytecode_files.<locals>.<lambda>c s6 t j } d t _ z � | | � } Wd | t _ X| S)NF)�sys�dont_write_bytecode)r r ZoriginalZ to_return)�fxnr r �wrapper s
z&writes_bytecode_files.<locals>.wrapper)r
r � functools�wraps)r r
r )r r �writes_bytecode_files s
! r c C sa y t j t j j | � � Wn= t k
r\ } z | j t j k rJ � n WYd d } ~ Xn Xd S)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�errorr r r �ensure_bytecode_path s
r c g s d } g } i } d } d } z�t j � } | | d <t � } x<| D]4} | j d � se | } n | d t d � � } | j | � | t j k r� t j | =n | j d � }
| } x\ |
d d � D]J } t j
j | | � } t j
j | � s� t j
| � | j | � q� q� Wt j
j | |
d d � } t | d � � }
|
j | j | � � Wd QX| j | � | | | <qG Wt j | � } | j � t j d
| g � } | j � | VWd | d k r�| j d d d � n | d k r| j d d d � n t j | � Xd S)
aR Temporarily 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.
zattr = {0!r}Nz.root�__init__z .__init__�.� z.py�wr ���r )�tempfileZmkdtemp�set�endswith�len�addr
�modules�splitr r �join�existsr �append�open�write�formatr Zuncache� __enter__Zimport_state�__exit__r Zrmtree)�names�sourceZ
created_paths�mappingZ
state_managerZuncache_managerZtemp_dirZimport_names�nameZimport_nameZ
name_partsZ file_pathZ directory�filer r r �create_modules) sL
r3 )� r �
contextlibr r r Zos.pathr
r Ztestr r r �contextmanagerr3 r r r r �<module> s