a
    ]9a                     @   sx   d dl mZ d dlZd dlT d dlmZ ze W n eyF   eZY n0 dddZdd	 Z	d
d Z
dddZdd ZdS )    )absolute_importN)*)
fscommands<string>c              
   C   s   t | trt| } d| v r0| dddd} | dsB| d7 } ztj| ddW S  tt	fy } z,t
 }d|_||_t||_|W Y d }~n
d }~0 0 d S )N   s   
   
z	<unknown>)filename   )
isinstanceunicoder   Zunicode_to_file_datareplaceendswithastparse	TypeError
ValueErrorSyntaxErrorlinenor   strmsg)sourcer   eerror r   ,lib/python3.9/site-packages/rope/base/ast.pyr      s    



r   c                 C   s`   d| j j }t||d}|durDt| tjr<| jdu r<d| _|| S t| D ]}t|| qLdS )zWalk the syntax tree_N )		__class____name__getattrr
   r   Z
ImportFrommoduleget_child_nodeswalk)nodeZwalkermethod_namemethodchildr   r   r   r"      s    r"   c                 C   sz   t | tjr| jS g }| jd urv| jD ]N}t| |}t |tr^|D ]}t |tjrB|| qBt |tjr&|| q&|S )N)	r
   r   ZModulebody_fieldsr   listZASTappend)r#   resultnamer&   entryr   r   r   r!   -   s    



r!   Fc                 C   s.   || }|r*|s*t | D ]}t||| qdS )z6If callback returns `True` the child nodes are skippedN)r!   call_for_nodes)r#   callback	recursiver+   r&   r   r   r   r.   =   s    r.   c                 C   s<   g }| j d ur8| j D ]"}|dv r"qt| |}|| q|S )N)r   
col_offset)r(   r   r*   )r#   r+   r,   r&   r   r   r   get_childrenE   s    


r2   )r   )F)Z
__future__r   r   Z	rope.baser   r   	NameErrorr   r   r"   r!   r.   r2   r   r   r   r   <module>   s   


