3
h	                 @   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 dd
lmZ dd ZG dd deZdS )    )absolute_importN)etreeTF)cElementTree)ElementTree   )Errors)EncodedStringc             C   s,   t | tr(| jdr(| dd j r(dS dS )z
    Names like '.0' are used internally for arguments
    to functions creating generator expressions,
    however they are not identifiers.

    See https://github.com/cython/cython/issues/5552
    .   NFT)
isinstancer   
startswith	isdecimal)name r   m/var/www/html/CrowdFlow/Picklecon/ble_analysis_env/lib/python3.6/site-packages/Cython/Debugger/DebugWriter.pyis_valid_tag   s    
r   c               @   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j tjj|ptjd| _t j | _	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_dirTreeBuildertbmodule_namestartdict)selfr   r   r   r   __init__.   s    
zCythonDebugWriter.__init__Nc             C   s   t |r| jj||pi  d S )N)r   r   r   )r    r   r   r   r   r   r   8   s    zCythonDebugWriter.startc             C   s   t |r| jj| d S )N)r   r   end)r    r   r   r   r   r"   <   s    zCythonDebugWriter.endc             K   s&   t |r"| jj|| | jj| d S )N)r   r   r   r"   )r    r   r   r   r   r   	add_entry@   s    zCythonDebugWriter.add_entryc             C   s   | j jd | j jd | j j }ytj| j W n0 tk
rb } z|jtjkrR W Y d d }~X nX t	j
|}i }tr~d|d< d| j }|jtjj| j|fddi| tjj| jd}t|d	}|j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   	serializeE   s"    


"zCythonDebugWriter.serialize)N)	__name__
__module____qualname____doc__r!   r   r"   r#   r7   r   r   r   r   r   &   s   

r   )
__future__r   r   r0   r+   lxmlr   r-   ImportErrorZ	xml.etreer   r   ZCompilerr   ZCompiler.StringEncodingr   r   objectr   r   r   r   r   <module>   s&   