B
    Í‹d™  ã               @   sÂ   d dl mZ d dlZd dlZd dlZyd dlmZ dZW nh ek
r    dZyd dl	m
Z W n> ek
rš   yd dl	mZ W n ek
r”   dZY nX Y nX Y nX dd	lmZ G d
d„ deƒZdS )é    )Úabsolute_importN)ÚetreeTF)ÚcElementTree)ÚElementTreeé   )ÚErrorsc               @   s:   e Zd ZdZdd„ Zddd„Zdd„ Zd	d
„ Zdd„ ZdS )ÚCythonDebugWriterz¥
    Class to output debugging information for cygdb

    It writes debug information to cython_debug/cython_debug_info_<modulename>
    in the build directory.
    c             C   sN   t d krt ¡ ‚tj |ptjd¡| _t  ¡ | _	d | _
| jdtddd d S )NÚcython_debugz1.0)Úversion)Úattrs)r   r   ZNoElementTreeInstalledExceptionÚosÚpathÚjoinÚcurdirÚ
output_dirZTreeBuilderÚtbÚmodule_nameÚstartÚdict)Úselfr   © r   úh/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/Cython/Debugger/DebugWriter.pyÚ__init__   s    
zCythonDebugWriter.__init__Nc             C   s   | j  ||pi ¡ d S )N)r   r   )r   Únamer   r   r   r   r   )   s    zCythonDebugWriter.startc             C   s   | j  |¡ d S )N)r   Úend)r   r   r   r   r   r   ,   s    zCythonDebugWriter.endc             K   s   | j  ||¡ | j  |¡ d S )N)r   r   r   )r   r   r   r   r   r   Ú	add_entry/   s    zCythonDebugWriter.add_entryc          
   C   sà   | j  d¡ | j  d¡ | j  ¡ }yt | j¡ W n0 tk
rb } z|jtjkrR‚ W d d }~X Y nX t	 
|¡}i }tr~d|d< d| j }|jtj | j|¡fddi|—Ž tj | jd¡}t|d	ƒ}| tj¡ W d Q R X d S )
NÚModuler	   TZpretty_printZcython_debug_info_ÚencodingzUTF-8ÚinterpreterÚw)r   r   Úcloser   Úmakedirsr   ÚOSErrorÚerrnoÚEEXISTr   r   Ú	have_lxmlr   Úwriter   r   ÚopenÚsysÚ
executable)r   Zxml_root_elementÚeÚetÚkwÚfnZinterpreter_pathÚfr   r   r   Ú	serialize3   s"    


"zCythonDebugWriter.serialize)N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r/   r   r   r   r   r      s   

r   )Ú
__future__r   r   r(   r#   Zlxmlr   r%   ÚImportErrorZ	xml.etreer   r   ZCompilerr   Úobjectr   r   r   r   r   Ú<module>   s"   