Ë
    oPêjN/  ã                  óH  — d Z 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lmZmZ ddlmZ ddlmZmZmZmZ ddlmZmZ dd	lmZ dd
lmZ  ee«      Zej:                  j<                  Z G d„ d«      Z 	 	 	 	 dd„Z! G d„ d«      Z"dd„Z#dd„Z$dd„Z%dd„Z&y)zExecute files of Python code.é    )ÚannotationsN)Ú
ModuleSpec)ÚCodeTypeÚ
ModuleType)ÚAny)ÚCoverageExceptionÚNoCodeÚNoSourceÚ_ExceptionDuringRun)Úcanonical_filenameÚpython_reported_file)Úisolate_module)Úget_python_sourcec                  ó   — e Zd ZdZdd„Zy)ÚDummyLoaderzzA shim for the pep302 __loader__, emulating pkgutil.ImpLoader.

    Currently only implements the .fullname attribute
    c                ó   — || _         y )N)Úfullname)Úselfr   Ú_argss      úV/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/coverage/execfile.pyÚ__init__zDummyLoader.__init__$   s	   € Ø ˆ�ó    N)r   Ústrr   r   ÚreturnÚNone)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r   r      s   „ ñô
!r   r   c                óÎ  — 	 t         j                  j                  | «      }|st	        d| ›�«      ‚|j                  }|j                  }|j                  rS| dz   }t         j                  j                  |«      }|st	        d|› d�| ›d�z   «      ‚|j                  }|j                  }|j                  d«      d   }|||fS # t        $ r}t	        t        |«      «      |‚d}~ww xY w)z‡Find the module named `modulename`.

    Returns the file path of the module, the name of the enclosing
    package, and the spec.
    NzNo module named z	.__main__z; z- is a package and cannot be directly executedú.r   )
Ú	importlibÚutilÚ	find_specÚImportErrorr
   r   ÚoriginÚnameÚsubmodule_search_locationsÚ
rpartition)Ú
modulenameÚspecÚerrÚpathnameÚpackagenameÚmod_mains         r   Úfind_moduler1   (   sò   € ð*Ü�~‰~×'Ñ'¨
Ó3ˆñ ÜÐ)¨*¨Ð8Ó9Ð9Ø�{‰{€HØ—)‘)€KØ×&Ò&Ø Ñ+ˆÜ�~‰~×'Ñ'¨Ó1ˆÙÜØ" 8 *¨BÐ/Ø�NÐ"OÐPñQóð ð —;‘;ˆØ—i‘iˆØ×(Ñ(¨Ó-¨aÑ0€KØ�[ $Ð&Ð&øô# ò *Ü”s˜3“xÓ  cÐ)ûð*ús   ‚C Ã	C$Ã
CÃC$c                  ó2   — e Zd ZdZddd„Zd	d„Zd	d„Zd	d„Zy)
ÚPyRunnerzwMulti-stage execution of Python code.

    This is meant to emulate real Python execution as closely as possible.

    c                óz   — || _         || _        |d   | _        d | _        d | _        d | _        d | _        d | _        y )Nr   )ÚargsÚ	as_moduleÚarg0Úpackager+   r.   Úloaderr,   )r   r5   r6   s      r   r   zPyRunner.__init__M   s>   € ØˆŒ	Ø"ˆŒà˜‘GˆŒ	Ø#'ˆŒØ&*ˆŒØ$(ˆŒØ*.ˆŒØ'+ˆ�	r   c                ó¬  — t         j                  j                  st         j                  j                  rd}nº| j                  rt        j                  «       }n™t
        j                  j                  | j                  «      r| j                  }nct
        j                  j                  t
        j                  j                  t
        j                  j                  | j                  «      «      «      }t
        j                  j                  t         j                  d   «      r¿t        j                  «       d   j                  j                   j"                  }t
        j                  j                  t         j                  d   «      }t
        j                  j                  t
        j                  j                  |«      «      }t%        |«      }t%        |«      }||k7  rXd}nUt         j                  d   t
        j                  j                  t         j                  d   «      k(  rt         j                  d= |�t'        |«      t         j                  d<   yy)zsSet sys.path properly.

        This needs to happen before any importing, and without importing anything.
        Nr   éÿÿÿÿé   )ÚsysÚflagsÚ	safe_pathÚisolatedr6   ÚosÚgetcwdÚpathÚisdirr7   ÚabspathÚdirnameÚrealpathÚinspectÚstackÚframeÚf_codeÚco_filenamer   r   )r   Úpath0Útop_fileÚsys_path_0_absÚtop_file_dir_abss        r   ÚpreparezPyRunner.prepareX   sn  € ô �9‰9×Ò¤#§)¡)×"4Ò"4Ø‰EØ�^Š^Ü—I‘I“K‰EÜ�W‰W�]‰]˜4Ÿ9™9Ô%ð —I‘I‰Eä—G‘G—O‘O¤B§G¡G§O¡O´B·G±G×4DÑ4DÀTÇYÁYÓ4OÓ$PÓQˆEä�7‰7�=‰=œŸ™ !™Ô%ô —}‘}“ rÑ*×0Ñ0×7Ñ7×CÑCˆHÜŸW™WŸ_™_¬S¯X©X°a©[Ó9ˆNÜ!Ÿw™wŸ™¬r¯w©w¯©¸xÓ/HÓIÐÜ/°Ó?ˆNÜ1Ð2BÓCÐØÐ!1Ò1Ø‘ô
 �x‰x˜‰{œbŸg™gŸo™o¬c¯h©h°q©kÓ:Ò:ä—H‘H˜Q�KàÐÜ.¨uÓ5ŒC�H‰H�QŠKð r   c                óh  — | j                   rÚ| j                  | _        t        | j                  «      \  }| _        | _        | j
                  �| j
                  j                  | _        t        | j                  «      | _        | j                  | j
                  _        |€J ‚t        j                  j                  |«      | _        | j                  x| j                  d<   | _        �n2t        j                  j                  | j                  «      rùdD ]v  }t        j                  j                  | j                  d|› �«      }t        j                  j                  |«      }t        j                  j!                  |«      sŒo|| _         n t#        d| j                  › d�«      ‚t%        |«      }d| _        t        d«      | _        t&        j(                  j+                  d| j                  |¬«      | _        d	| j
                  _        nt        d«      | _        t%        | j                  «      | _        y)
z§Do more preparation to run Python code.

        Includes finding the module to run and adjusting sys.argv[0].
        This method is allowed to import code.

        Nr   )z.pyú.pycú.pyoÚ__main__z!Can't find '__main__' module in 'ú'Ú )r'   T)r6   r7   r+   r1   r8   r,   r(   r   r9   rA   rC   rE   r.   r5   rD   ÚjoinÚexistsr
   r   r#   Ú	machineryr   Úhas_location)r   r.   ÚextÚtry_filenames       r   Ú	_prepare2zPyRunner._prepare2�   s¢  € ð �>Š>Ø"Ÿi™iˆDŒOÜ0;¸D¿O¹OÓ0LÑ-ˆH�d”l D¤IØ�y‰yÐ$Ø"&§)¡)§.¡.�”Ü% d§o¡oÓ6ˆDŒKØ#Ÿ{™{ˆD�I‰IÔØÐ'Ð'Ð'ÜŸG™GŸO™O¨HÓ5ˆDŒMØ'+§}¡}Ð4ˆD�I‰I�a‰L˜4ž9Ü�W‰W�]‰]˜4Ÿ9™9Ô%ð /ò 	Q�Ü!Ÿw™wŸ|™|¨D¯I©I¸À#ÀÐ7GÓH�ô  "Ÿw™wŸ™¨|Ó<�Ü—7‘7—>‘> ,Õ/Ø ,�D”IÙð	Qô Ð!BÀ4Ç9Á9À+ÈQÐOÓPÐPä/°Ó=ˆLØˆDŒLÜ% jÓ1ˆDŒKô "×+Ñ+×6Ñ6ØØ—‘Ø#ð 7ó ˆDŒIð
 &*ˆD�I‰IÕ"ä% jÓ1ˆDŒKä(¨¯©Ó3ˆ�	r   c                ó¤  — | j                  «        t        d«      }| j                  j                  d«      }| j                  |_        |r|j                  dd |_        | j
                  �| j
                  |_        | j                  |_        | j                  �| j                  |_
        t        j                  d   |_        |t        j                  d<   | j                  t        _        	 |rt!        | j                  «      }nt#        | j                  «      }t-        j.                  «       }	 t1        ||j2                  «       t-        jL                  |«       y# t$        $ r ‚ t&        $ r:}d| j                  › d|j(                  j*                  › d|› �}t%        |«      |‚d}~ww xY w# t4        $ r ‚ t&        $ �r{ t        j6                  «       \  }}}	|€J ‚|€J ‚|	€J ‚t9        |d	d«       	 |j:                  €J ‚|j:                  j<                  |_        t        j>                  |||	j<                  «       t        j@                  d
«       nå# t4        $ r ‚ t&        $ rÐ}t        jB                  jE                  d«       t        j6                  «       \  }
}}|
€J ‚|€J ‚|€J ‚d|_#        |j:                  €J ‚|j:                  j<                  |_        t        jH                  |
||j<                  «       t        jB                  jE                  d«       tK        |||	j<                  «      |‚d}~ww xY wY �Œòw xY w# t-        jL                  |«       w xY w)zRun the Python code!rU   )rS   rT   Nr;   ÚbuiltinszCouldn't run 'z' as Python code: z: Ú__context__r<   zError in sys.excepthook:
Tz
Original exception was:
)'r^   r   r7   ÚendswithÚ__file__r8   Ú__package__r9   Ú
__loader__r,   Ú__spec__r=   ÚmodulesÚ__builtins__r5   ÚargvÚmake_code_from_pycÚmake_code_from_pyr   Ú	ExceptionÚ	__class__r   rA   rB   ÚexecÚ__dict__Ú
SystemExitÚexc_infoÚgetattrÚ__traceback__Útb_nextÚ
excepthookÚexitÚstderrÚwriteÚ__suppress_context__Ú__excepthook__r   Úchdir)r   Úmain_modÚfrom_pycÚcodeÚexcÚmsgÚcwdÚtypr-   ÚtbÚtyp2Úerr2Útb2s                r   ÚrunzPyRunner.run°   sñ  € ð 	�‰Ôô ˜jÓ)ˆà—9‘9×%Ñ%Ð&6Ó7ˆØ ŸI™IˆÔÙØ (× 1Ñ 1°#°2Ð 6ˆHÔØ�<‰<Ð#Ø#'§<¡<ˆHÔ Ø"Ÿk™kˆÔØ�9‰9Ð Ø $§	¡	ˆHÔä #§¡¨JÑ 7ˆÔà"*Œ�‰�JÑð —9‘9ŒŒð
	2áÜ)¨$¯)©)Ó4‘ä(¨¯©Ó3�ô �i‰i‹kˆð/	Ü��x×(Ñ(Ô)ô\ �H‰H�S�Møôs !ò 	ØÜò 	2Ø" 4§9¡9 +Ð-?ÀÇÁ×@VÑ@VÐ?WÐWYÐZ]ÐY^Ð_ˆCÜ# CÓ(¨cÐ1ûð	2ûô ò 	ð Üó '	ô Ÿ<™<›>‰LˆC��bØ�?Ð"�?Ø�?Ð"�?Ø�>Ð!�>ô �C˜¨Ô-ðØ×(Ñ(Ð4Ð4Ð4Ø$'×$5Ñ$5×$=Ñ$=�Ô!Ü—‘˜s C¨¯©Ô4ô$ —‘˜•øô# ò ØÜò Iô —
‘
× Ñ Ð!=Ô>Ü"%§,¡,£.‘��d˜CØÐ'Ð'Ð'ØÐ'Ð'Ð'Ø�Ð&�Ø,0�Ô)Ø×)Ñ)Ð5Ð5Ð5Ø%)×%7Ñ%7×%?Ñ%?�Ô"Ü×"Ñ" 4¨¨s¯{©{Ô;Ü—
‘
× Ñ Ð!>Ô?Ü)¨#¨s°B·J±JÓ?ÀSÐHûðIúò ðO'	ûôR �H‰H�S�Músc   Ã*-E Ä,F' ÅF$Å*5FÆF$Æ'AL5Ç,A
IÈ6L5ÉL.ÉCL)Ì)L.Ì.L5Ì1L8 Ì4L5Ì5L8 Ì8MN)F)r5   ú	list[str]r6   Úboolr   r   )r   r   )r   r   r   r   r   rQ   r^   r‡   r    r   r   r3   r3   F   s   „ ñô	,ó'6óR-4ô^Xr   r3   c                ó^   — t        | d¬«      }|j                  «        |j                  «        y)a  Run a Python module, as though with ``python -m name args...``.

    `args` is the argument array to present as sys.argv, including the first
    element naming the module being executed.

    This is a helper for tests, to encapsulate how to use PyRunner.

    T©r6   N©r3   rQ   r‡   ©r5   Úrunners     r   Úrun_python_moduler�     s#   € ô �d dÔ+€FØ
‡N�NÔØ
‡J�J…Lr   c                ó^   — t        | d¬«      }|j                  «        |j                  «        y)aG  Run a Python file as if it were the main program on the command line.

    `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.

    This is a helper for tests, to encapsulate how to use PyRunner.

    Fr‹   NrŒ   r�   s     r   Úrun_python_filer‘     s#   € ô �d eÔ,€FØ
‡N�NÔØ
‡J�J…Lr   c                óŠ   — 	 t        | «      }t        || dd¬«      }|S # t        t        f$ r}t        d| › d�«      |‚d}~ww xY w)z8Get source from `filename` and make a code object of it.úNo file to run: 'rV   Nrn   T)ÚmodeÚdont_inherit)r   ÚOSErrorr
   Úcompile)ÚfilenameÚsourcer   r~   s       r   rk   rk   (  sY   € ðAÜ" 8Ó,ˆô �6˜8¨&¸tÔD€DØ€Køô	 ”XÐò AÜÐ*¨8¨*°AÐ6Ó7¸SÐ@ûðAús   ‚ žA­=½Ac                ó  — 	 t        | d«      }|5  |j                  d«      }|t        k7  rt        d|›dt        ›�«      ‚t        j                  d|j                  d«      «      d	   }|d
z  }|r|j                  d«       n"|j                  d«       |j                  d«       t        j                  |«      }t        |t        «      sJ ‚	 ddd«       |S # t        $ r}t        d| › d�«      |‚d}~ww xY w# 1 sw Y   S xY w)z#Get a code object from a .pyc file.Úrbr“   rV   Né   zBad magic number in .pyc file: z != z<Lr   r<   é   )Úopenr–   r	   ÚreadÚPYC_MAGIC_NUMBERÚstructÚunpackÚmarshalÚloadÚ
isinstancer   )r˜   Úfpycr   Úmagicr>   Ú
hash_basedr~   s          r   rj   rj   3  sþ   € ð?Ü�H˜dÓ#ˆð 
ñ *ð —	‘	˜!“ˆØÔ$Ò$ÜÐ:¸5¸)À4ÔHXÐG[Ð\Ó]Ð]ä—‘˜d D§I¡I¨a£LÓ1°!Ñ4ˆØ˜T‘\ˆ
ÙØ�I‰I�a�Lð �I‰I�aŒLØ�I‰I�aŒLô �|‰|˜DÓ!ˆÜ˜$¤Ô)Ð)Ñ)÷%*ð( €Køô/ ò ?ÜÐ(¨¨
°!Ð4Ó5¸3Ð>ûð?ú÷*ð( €Kús#   ‚C �B:C6Ã	C3ÃC.Ã.C3Ã6D )r+   r   r   z"tuple[str | None, str, ModuleSpec])r5   rˆ   r   r   )r˜   r   r   r   )'r   Ú
__future__r   Úimportlib.machineryr#   Úimportlib.utilrH   r£   rA   r¡   r=   r   Útypesr   r   Útypingr   Úcoverage.exceptionsr   r	   r
   r   Úcoverage.filesr   r   Úcoverage.miscr   Úcoverage.pythonr   r$   ÚMAGIC_NUMBERr    r   r1   r3   r�   r‘   rk   rj   r    r   r   ú<module>r³      s–   ðñ $å "ã Û Û Û Û 	Û Û 
Ý *ß &Ý ç XÓ Xß CÝ (Ý -á�BÓ€ð —>‘>×.Ñ.Ð ÷!ñ !ð'Øð'à'ó'÷<Bñ BóJóóôr   