Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/coverage/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/coverage/__pycache__/execfile.cpython-37.pyc

B

E�W8!�@s�dZddlZddlZddlZddlZddlmZddlmZmZm	Z	ddl
mZmZm
Z
mZddlmZddlmZee�ZGdd	�d	e�Ze	r�d
d�Zndd�Zd
d�Zddd�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@seZdZdZdd�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/python37/lib64/python3.7/site-packages/coverage/execfile.py�__init__szDummyLoader.__init__N)�__name__�
__module__�__qualname__�__doc__rrrrrrsrc
Cs�yt|�}Wn.tk
r:}ztt|���Wdd}~XYnX|sNtd|f��|j}|j}|�d�r�|�d�s�|d}t|�}|s�td||f��|j}|j}|�d�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#c
Csd}t�t�}}z�y�d|krF|�dd�\}}t|||dg�}|j}nd|}}d}t�||�\}}}	|dkr�|dkr�td|��|dkr�|}d}t|||dg�}|j}t�||�\}}}	Wn.tk
r�}
ztt	|
���Wdd}
~
XYnXWd|�r�|�
�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

"
cCs6t|�\}}tj�|�}||d<t||||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.

    r�)r-r�path0N)r#�os�path�abspath�run_python_file)r�argsr!r"rrr�run_python_moduleesr6c	Cs�|dkrtjdkrd}tjd}t�d�}|tjd<||_|rD||_|rRt|�|_t	|_
tj}|t_tj
�|�r�|}xRdD](}	tj
�|d|	�}
tj
�|
�rz|
}PqzWtd|��ntj
�tj
�|��}tj
d}|dk	r�|n|tj
d<z||�d�r�t|�}nt|�}yt||j�WnJtk
�r.�Yn4t��\}
}}t|dd�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)�r7r&)z.pyz.pycz.pyoz$Can't find '__main__' module in '%s'r)z.pycz.pyo�__context__)�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-rr0Zold_main_modZmain_modZold_argvZmy_path0�extZtry_filenameZ	old_path0�code�typr �tbrrrr4tsN








r4c	CsByt|�}Wn$ttfk
r0td|��YnXt||d�}|S)z8Get source from `filename` and make a code object of it.zNo file to run: '%s'rI)r�IOErrorrr
)rO�sourcerQrrrrH�srHc	Cs�yt|d�}Wn tk
r.td|��YnX|�H|�d�}|tkrPtd��|�d�tjdkrn|�d�t�|�}WdQRX|S)z#Get a code object from a .pyc file.�rbzNo file to run: '%s'�zBad magic number in .pyc file)r7r7N)	�openrTr�readrr9r:�marshal�load)rOZfpyc�magicrQrrrrG�s



rG)NNN)rrZr1r9r<Zcoverage.backwardrrrrZ
coverage.miscrrrr	Zcoverage.phystokensr
Zcoverage.pythonr�objectrr#r6r4rHrGrrrr�<module>s$	
+
X