Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/coverage/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/coverage/__pycache__/execfile.cpython-35.pyc



E�W8!�@s$dZddlZddlZddlZddlZddlmZddlmZmZm	Z	ddl
mZmZm
Z
mZddlmZddlmZee�ZGdd	�d	e�Ze	r�d
d�Zndd�Zd
d�Zddddd�Zdd�Zdd�ZdS)zExecute files of Python code.�N)�BUILTINS)�PYC_MAGIC_NUMBER�imp�importlib_util_find_spec)�ExceptionDuringRun�NoCode�NoSource�isolate_module)�compile_unicode)�get_python_sourcec@s"eZdZdZdd�ZdS)�DummyLoaderzzA shim for the pep302 __loader__, emulating pkgutil.ImpLoader.

    Currently only implements the .fullname attribute
    cGs
||_dS)N)�fullname)�selfr
�_args�r�D/opt/alt/python35/lib64/python3.5/site-packages/coverage/execfile.py�__init__szDummyLoader.__init__N)�__name__�
__module__�__qualname__�__doc__rrrrrrsrcCs�yt|�}Wn7tk
rI}ztt|���WYdd}~XnX|sctd|f��|j}|j}|jd�r�|jd�r�|d}t|�}|s�td||f��|j}|j}|jd�d}||fS)	z�Find the module named `modulename`.

        Returns the file path of the module, and the name of the enclosing
        package.
        NzNo module named %rz__init__.pyrz	.__main__zCNo module named %s; %r is a package and cannot be directly executed�.r)r�ImportErrorr�str�origin�name�endswith�
rpartition)�
modulename�spec�err�pathname�packagenameZmod_mainrrr�find_modules&%		
		r#cCskd}t�t�}}z4y�d|krg|jdd�\}}t|||dg�}|j}nd|}}d}tj||�\}}}	|dkr�|dkr�td|��|dkr|}d}t|||dg�}|j}tj||�\}}}	Wn7tk
rK}
ztt	|
���WYdd}
~
XnXWd|r`|j
�X||fS)z�Find the module named `modulename`.

        Returns the file path of the module, and the name of the enclosing
        package.
        Nr��__path__z"module does not live in a file: %r�__main__)�globals�locals�rsplit�
__import__r%rr#rrr�close)rZopenfileZglo�locr"r�packageZ
searchpathr!�_r rrrr#:s0

	)c	CsQt|�\}}tjj|�}||d<t||d|d|dd�dS)aRun a Python module, as though with ``python -m name args...``.

    `modulename` is the name of the module, possibly a dot-separated name.
    `args` is the argument array to present as sys.argv, including the first
    element naming the module being executed.

    rr-r�path0�N)r#�os�path�abspath�run_python_file)r�argsr!r"rrr�run_python_modulees
r6cCs|dkr!tjd
kr!d}tjd}tjd�}|tjd<||_|rb||_|rwt|�|_t	|_
tj}|t_tj
j|�r	|}xzdddgD]8}	tj
j|d|	�}
tj
j|
�r�|
}Pq�Wtd|��ntj
jtj
j|��}tj
d}|dk	rF|n|tj
d<z�|jd�rtt|�}nt|�}yt||j�WnVtk
r��YnBtj�\}
}}t|d	d�t|
||j��YnXWd|tjd<|t_|tj
d<XdS)aRun a Python file as if it were the main program on the command line.

    `filename` is the path to the file to execute, it need not be a .py file.
    `args` is the argument array to present as sys.argv, including the first
    element naming the file being executed.  `package` is the name of the
    enclosing package, if any.

    `modulename` is the name of the module the file was run as.

    `path0` is the value to put into sys.path[0].  If it's None, then this
    function will decide on a value.

    N�r&z.py�.pyc�.pyoz$Can't find '__main__' module in '%s'r�__context__)r7r7)r8r9)�sys�version_info�modules�types�
ModuleType�__file__�__package__r�
__loader__r�__builtins__�argvr1r2�isdir�join�existsrr3�dirnamer�make_code_from_pyc�make_code_from_py�exec�__dict__�
SystemExit�exc_info�getattrr�tb_next)�filenamer5r-rr/Zold_main_modZmain_modZold_argvZmy_path0�extZtry_filenameZ	old_path0�code�typr �tbrrrr4tsN

					


	r4cCsQyt|�}Wn(ttfk
r:td|��YnXt||d�}|S)z8Get source from `filename` and make a code object of it.zNo file to run: '%s'rK)r�IOErrorrr
)rQ�sourcerSrrrrJ�srJcCs�yt|d�}Wn"tk
r7td|��YnX|�d|jd�}|tkrftd��|jd�tjdkr�|jd�tj|�}WdQRX|S)z#Get a code object from a .pyc file.�rbzNo file to run: '%s'�zBad magic number in .pyc filer7N)r7r7)	�openrVr�readrr;r<�marshal�load)rQZfpyc�magicrSrrrrI�s


rI)rr\r1r;r>Zcoverage.backwardrrrrZ
coverage.miscrrrr	Zcoverage.phystokensr
Zcoverage.pythonr�objectrr#r6r4rJrIrrrr�<module>s$"	+X