ó
™^c           @   s   d  „  Z  d „  Z d S(   c   	      C   sç   t  |  t ƒ rã t |  ƒ d k rã |  d } t  | t ƒ rã t | ƒ d k rã | \ } } } } } } t  | t ƒ rà | rà | d } | rÝ d d l } d | j | ƒ d } | j | | j ƒ  ƒ } | rÚ | j d ƒ SqÝ qà qã n  d S(   sH  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.
    i   i   i    iÿÿÿÿNs    (?:\w+\.)*(\w+)\s*=\s*(?:\w+\.)*s   \(.*\)(	   t
   isinstancet   listt   lent   tuplet   ret   escapet   matcht   stript   group(	   t   stack_framest   constructor_namet   parent_stack_framet   _t   source_linest   source_lineR   t   assignment_regexpR   (    (    s:   /torch/pytorch/third_party/python-peachpy/peachpy/parse.pyt   parse_assigned_variable_name   s    !
!
c   	      C   sç   t  |  t ƒ rã t |  ƒ d k rã |  d } t  | t ƒ rã t | ƒ d k rã | \ } } } } } } t  | t ƒ rà | rà | d } | rÝ d d l } d | j | ƒ d } | j | | j ƒ  ƒ } | rÚ | j d ƒ SqÝ qà qã n  d S(   s$  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.
    i   i   i    iÿÿÿÿNs   with\s+(?:\w+\.)*s    \(.*\)\s+as\s+([_a-zA-Z]\w*)\s*:(	   R    R   R   R   R   R   R   R   R   (	   R	   R
   R   R   R   R   R   t   with_regexpR   (    (    s:   /torch/pytorch/third_party/python-peachpy/peachpy/parse.pyt   parse_with_variable_name   s    !
!
N(   R   R   (    (    (    s:   /torch/pytorch/third_party/python-peachpy/peachpy/parse.pyt   <module>   s   	