o
    É­ZZ;'  ã                   @   sÔ   d 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lmZm	Z	m
Z
 ddlmZmZmZmZmZ ddlmZ ddlmZ eeƒZG dd	„ d	eƒZe
rSd
d„ Zndd„ Zdd„ Zddd„Zdd„ Zdd„ ZdS )zExecute files of Python code.é    N)ÚBUILTINS)ÚPYC_MAGIC_NUMBERÚimpÚimportlib_util_find_spec)ÚCoverageExceptionÚExceptionDuringRunÚNoCodeÚNoSourceÚisolate_module)Úcompile_unicode)Úget_python_sourcec                   @   s   e Zd ZdZdd„ ZdS )ÚDummyLoaderzzA shim for the pep302 __loader__, emulating pkgutil.ImpLoader.

    Currently only implements the .fullname attribute
    c                 G   s
   || _ d S )N)Úfullname)Úselfr   Ú_args© r   úC/var/www/html/env/lib/python3.10/site-packages/coverage/execfile.pyÚ__init__   s   
zDummyLoader.__init__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s    r   c              
   C   sª   zt | ƒ}W n ty } ztt|ƒƒ‚d}~ww |s"td| f ƒ‚|j}|j}| d¡rJ|  d¡sJ| d }t |ƒ}|sDtd|| f ƒ‚|j}|j}| d¡d }||fS )	ú‰Find the module named `modulename`.

        Returns the file path of the module, and the name of the enclosing
        package.
        NzNo module named %rz__init__.pyr   z	.__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ÚpackagenameÚmod_mainr   r   r   Úfind_module   s.   €ÿþÿr&   c              
   C   s  d}t ƒ tƒ }}zrzTd| v r#|  dd¡\}}t|||dgƒ}|j}nd| }}d}t ||¡\}}}	|du rA|du rAtd|  ƒ‚|du r]| }d}t|||dgƒ}|j}t ||¡\}}}	W n typ }
 ztt	|
ƒƒ‚d}
~
ww W |rx| 
¡  ||fS |rƒ| 
¡  w w )r   Nr   é   Ú__path__z"module does not live in a file: %rÚ__main__)ÚglobalsÚlocalsÚrsplitÚ
__import__r(   r   r&   r	   r   r   Úclose)r    ÚopenfileÚgloÚlocr$   r   ÚpackageÚ
searchpathr#   Ú_r"   r   r   r   r&   ;   s@   
ÿ€€ÿ€ý
ÿc                 C   s6   t | ƒ\}}tj |¡}||d< t|||| dd� dS )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   Ú )r2   r    Úpath0N)r&   ÚosÚpathÚabspathÚrun_python_file)r    Úargsr#   r$   r   r   r   Úrun_python_modulef   s   r<   c                 C   s¢  |du rt jdkrd}t jd }t d¡}|t jd< | |_|r"||_|r)t|ƒ|_t	|_
t j}|t _tj | ¡rY| }dD ]}	tj | d|	 ¡}
tj |
¡rQ|
}  nq<td|  ƒ‚n
tj tj | ¡¡}t jd }|durn|n|t jd< zÏz|  d¡rt| ƒ}nt| ƒ}W n tyŒ   ‚  ty¢ } zd}t|j| |d	�ƒ‚d}~ww zt||jƒ W nw ty³   ‚  t�y"   t  ¡ \}}}t|d
dƒ zt|dƒrÒ|j j!|_ t  "|||j!¡ W n? tyã   ‚  t�y   t j# $d¡ t  ¡ \}}}d|_%t|dƒ�r|j j!|_ t  &|||j!¡ t j# $d¡ t'|||j!ƒ‚w t  (d¡ Y nw W |t jd< |t _|t jd< dS W |t jd< |t _|t jd< dS |t jd< |t _|t jd< w )a  Run 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>   r)   )z.pyú.pycú.pyoz$Can't find '__main__' module in '%s'r   )r?   r@   zICouldn't run {filename!r} as Python code: {exc.__class__.__name__}: {exc})ÚfilenameÚexcÚ__context__Ú__traceback__zError in sys.excepthook:
Tz
Original exception was:
r'   ))ÚsysÚversion_infoÚmodulesÚtypesÚ
ModuleTypeÚ__file__Ú__package__r   Ú
__loader__r   Ú__builtins__Úargvr7   r8   ÚisdirÚjoinÚexistsr	   r9   Údirnamer   Úmake_code_from_pycÚmake_code_from_pyr   Ú	ExceptionÚformatÚexecÚ__dict__Ú
SystemExitÚexc_infoÚgetattrÚhasattrrD   Útb_nextÚ
excepthookÚstderrÚwriteÚ__suppress_context__Ú__excepthook__r   Úexit)rA   r;   r2   r    r6   Úold_main_modÚmain_modÚold_argvÚmy_path0ÚextÚtry_filenameÚ	old_path0ÚcoderB   ÚmsgÚtypr"   ÚtbÚtyp2Úerr2Útb2r   r   r   r:   u   s–   



þþ


€€þ


ößû
*ú

þr:   c              	   C   s<   zt | ƒ}W n ttfy   td|  ƒ‚w t|| dƒ}|S )z8Get source from `filename` and make a code object of it.úNo file to run: '%s'rW   )r   ÚIOErrorr	   r   )rA   Úsourcerk   r   r   r   rT   ç   s   ÿrT   c                 C   sØ   zt | dƒ}W n ty   td|  ƒ‚w |�K | d¡}|tkr%tdƒ‚d}tjdkrDt d| d¡¡d }|d	@ }|rD| d
¡ d}|rU| d¡ tjdkrU| d¡ t	 
|¡}W d  ƒ |S 1 sew   Y  |S )z#Get a code object from a .pyc file.Úrbrr   é   zBad magic number in .pyc fileT)r>   é   r   Úalpharv   z<Lr   r'   é   Fr=   N)Úopenrs   r   Úreadr   rE   rF   ÚstructÚunpackÚmarshalÚload)rA   ÚfpycÚmagicÚ
date_basedÚflagsÚ
hash_basedrk   r   r   r   rS   ó   s2   ÿ






êèrS   )NNN)r   r~   r7   r|   rE   rH   Úcoverage.backwardr   r   r   r   Úcoverage.miscr   r   r   r	   r
   Úcoverage.phystokensr   Úcoverage.pythonr   Úobjectr   r&   r<   r:   rT   rS   r   r   r   r   Ú<module>   s(   	
+
r