o
    œh:  ã                   @   sÖ   d 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krUz(ddl	Z	dd	l
mZmZmZmZ e	jjjZeeege_ee_d
d„ Zeeƒ W n	 eyR   Y nw eZdd„ Zdd„ Zdd„ ZG dd„ deƒZdS )z"Compiler helpers for the debugger.é    N)ÚCachingCompilerc           	      C   sx  d}dd„ t  | d¡D ƒ} t| ƒ}||A }|d@ }td|dƒD ]H}t| | ƒd@ t| |d	  ƒd@ d
> B t| |d  ƒd@ d> B t| |d  ƒd> B }|| d@ }||d? N }|| d@ }|| d@ }||N }q|d@ }d}|dkr~t| |d  ƒd@ d> }|dv r�|t| |d	  ƒd@ d
> O }|dv r¨|t| | ƒd@ O }||N }|| d@ }||d? N }|| d@ }||d? N }|S )zGet the murmur2 hash.i•éÑ[c                 S   s   g | ]}t |ƒ‘qS © )Úchr)Ú.0Údr   r   úHc:\Users\shubh\Videos\agent\nova\Lib\site-packages\ipykernel/compiler.pyÚ
<listcomp>   s    zmurmur2_x86.<locals>.<listcomp>Úutf8l   üÿ r   é   éÿ   é   é   é   é   é   é   l   ÿÿ )r   r   )r   r   r   é   é   )ÚstrÚencodeÚlenÚrangeÚord)	ÚdataÚseedÚmÚlengthÚhZrounded_endÚiÚkÚvalr   r   r   Úmurmur2_x86	   sB   ÿþýÿ
r!   c                 C   s   | S )Nr   )Úfilenamer   r   r   Ú<lambda>0   s    r#   Úwin32)ÚDWORDÚLPCWSTRÚLPWSTRÚMAX_PATHc                 C   s0   t  t¡}t| |tƒ}|dkr|tkr|j} | S )Nr   )ÚctypesÚcreate_unicode_bufferr(   Ú_GetLongPathNameÚvalue)r"   ÚbufÚrvr   r   r   Ú_convert_to_long_pathname;   s
   
r/   c                  C   s*   t t ¡ ƒ} t ¡ }| tj d t|ƒ S )zGet a temp directory.Z
ipykernel_)Úconvert_to_long_pathnameÚtempfileÚ
gettempdirÚosÚgetpidÚsepr   )Ztmp_dirÚpidr   r   r   Úget_tmp_directoryJ   s   r7   c                   C   s   dS )zGet a temp hash seed.l   i r   r   r   r   r   Úget_tmp_hash_seedQ   s   r8   c                 C   s<   t j d¡}|du rt| tƒ ƒ}tƒ t j t|ƒ d }|S )zGet a file name.ZIPYKERNEL_CELL_NAMENz.py)r3   ÚenvironÚgetr!   r8   r7   r5   r   )ÚcodeZ	cell_nameÚnamer   r   r   Úget_file_nameV   s
   r=   c                       s(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )ÚXCachingCompilerzA custom caching compiler.c                    s   t ƒ j|i |¤Ž d| _dS )zInitialize the compiler.N)ÚsuperÚ__init__Úlog)ÚselfÚargsÚkwargs©Ú	__class__r   r   r@   b   s   
zXCachingCompiler.__init__c                 C   s   t |ƒS )zGet the code name.)r=   )rB   Zraw_coder;   Únumberr   r   r   Úget_code_nameg   s   zXCachingCompiler.get_code_name)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r@   rH   Ú__classcell__r   r   rE   r   r>   _   s    r>   )rL   r3   Úsysr1   ZIPython.core.compileropr   r!   r0   Úplatformr)   Zctypes.wintypesr%   r&   r'   r(   ÚwindllÚkernel32ZGetLongPathNameWr+   ÚargtypesÚrestyper/   Ú__file__Ú	Exceptionr7   r8   r=   r>   r   r   r   r   Ú<module>   s0    '

ÿ	