o
    f	                     @   s   d dl mZ d dlZd dlZd dlZz
d dlmZ dZW n1 eyM   dZzd dl	m
Z W n eyJ   zd dl	mZ W n eyG   dZY nw Y nw Y nw 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| dr| dd  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   W/var/www/html/mig_web/myenv/lib/python3.10/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 u 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   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||pi  d S d S N)r   r   r   r!   r   r   r   r   r   r   8   s   zCythonDebugWriter.startc                 C   s   t |r| j| d S d S r#   )r   r   end)r!   r   r   r   r   r%   <   s   zCythonDebugWriter.endc                 K   s*   t |r| j|| | j| d S d S r#   )r   r   r   r%   r$   r   r   r   	add_entry@   s   zCythonDebugWriter.add_entryc              
   C   s   | j d | j d | j  }zt| j W n ty2 } z|jtjkr( W Y d }~nd }~ww 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    d S 1 suw   Y  d S )
NModuler   Tpretty_printcython_debug_info_encodingzUTF-8interpreterw)r   r%   closer   makedirsr   OSErrorerrnoEEXISTr   r   	have_lxmlr   writer   r   opensys
executable)r!   xml_root_elementeetkwfninterpreter_pathfr   r   r   	serializeE   s*   


""zCythonDebugWriter.serializer#   )	__name__
__module____qualname____doc__r"   r   r%   r&   r>   r   r   r   r   r   &   s    

r   )
__future__r   r   r5   r0   lxmlr   r2   ImportError	xml.etreer   r   Compilerr   Compiler.StringEncodingr   r   objectr   r   r   r   r   <module>   s2    
