o
    Žqi	  ã                   @   s   d d„ Z dd„ ZdS )c           	      C   ó¶   t | tƒrKt| ƒdkrM| d }t |tƒrOt|ƒdkrQ|\}}}}}}t |tƒrS|rU|d }|rWddl}d| |¡ d }| || ¡ ¡}|rY| d¡S dS dS dS dS dS dS dS dS )aH  Analyses the provided stack frames and parses Python assignment expressions like
         some.namespace.variable_name   =   some.module.name.`constructor_name`(...)
    from the caller's call site and returns the name of the variable being assigned as a string.
    If the assignment expression is not found, returns None.
    é   é   é    Nz (?:\w+\.)*(\w+)\s*=\s*(?:\w+\.)*z\(.*\)©	Ú
isinstanceÚlistÚlenÚtupleÚreÚescapeÚmatchÚstripÚgroup)	Ústack_framesÚconstructor_nameÚparent_stack_frameÚ_Úsource_linesÚsource_liner
   Zassignment_regexpr   © r   úJ/home/app/PyTorch/test/pytorch/third_party/python-peachpy/peachpy/parse.pyÚparse_assigned_variable_name   ó"   
ôr   c           	      C   r   )a$  Analyses the provided stack frames and parses Python with expressions like
         with `constructor_name`(...) as variable_name:
    from the caller's call site and returns the name of the variable named in the statement as a string.
    If a with statement is not found, returns None.
    r   r   r   Nzwith\s+(?:\w+\.)*z \(.*\)\s+as\s+([_a-zA-Z]\w*)\s*:r   )	r   r   r   r   r   r   r
   Zwith_regexpr   r   r   r   Úparse_with_variable_name   r   r   N)r   r   r   r   r   r   Ú<module>   s   