
ѧAj                 @   s   d  Z  d d l Z d d l m Z d d l m Z Gd d   d  Z Gd d   d  Z Gd	 d
   d
 e  Z Gd d   d  Z Gd d   d e  Z	 d S)zjutilities for analyzing expressions and blocks of Python
code, as well as generating Python from AST nodes    N)
exceptions)pyparserc               @   s"   e  Z d  Z d Z d d   Z d S)
PythonCodez<represents information about a string containing Python codec             K   sw   | |  _  t   |  _ t   |  _ t | t  rN t j | j   d |  } n | } t j	 |  |  } | j
 |  d  S)Nexec)codesetdeclared_identifiersundeclared_identifiers
isinstancestrr   parselstripZFindIdentifiersvisit)selfr   exception_kwargsexprf r   R/home/www/goberdata.com/tradingbinance/backend/.venv/Lib/site-packages/mako/ast.py__init__   s    	zPythonCode.__init__N)__name__
__module____qualname____doc__r   r   r   r   r   r      s   r   c               @   s"   e  Z d  Z d Z d d   Z d S)ArgumentListzBparses a fragment of code as a comma-separated list of expressionsc             K   s   g  |  _  g  |  _ t   |  _ t   |  _ t | t  r t j d |  rh t j d |  rh | d 7} t	 j
 | d |  } n | } t	 j |  t |  } | j |  d  S)Nz\Sz,\s*$,r   )Zcodeargsargsr   r   r	   r
   r   rematchr   r   Z	FindTupler   r   )r   r   r   r   r   r   r   r   r   6   s    		%
zArgumentList.__init__N)r   r   r   r   r   r   r   r   r   r   2   s   r   c                   s(   e  Z d  Z d Z   f d d   Z   S)PythonFragmentzextends PythonCode to provide identifier lookups in partial control
    statements

    e.g.::

        for x in 5:
        elif y==9:
        except (MyException, e):

    c                s,  t  j d | j   t  j  } | s: t j d | |   | j d  rb | d  | j d   } | j d d  \ } } | d k r | d	 } n | d
 k r | d } ni | d k r d | d	 } nL | d k r d | d	 } n/ | d k r | d	 } n t j d | |   t   j	 | |  d  S)Nz^(\w+)(?:\s+(.*?))?:\s*(#|$)z0Fragment '%s' is not a partial control statement         forifwhileZpassZtryzpass
except:passelifelsezif False:pass
Zexceptz	try:pass
Zwithz!Unsupported control keyword: '%s')r#   r$   r%   )r&   r'   )
r   r   stripSr   CompileExceptiongroupstartsuperr   )r   r   r   mZkeywordr   )	__class__r   r   r   U   s,    		zPythonFragment.__init__)r   r   r   r   r   r   r   )r/   r   r   H   s   r   c               @   sF   e  Z d  Z d Z d d d  Z d d d  Z e d d	    Z d
 S)FunctionDeclzfunction declarationTc             K   s   | |  _  t j | d |  } t j |  |  } | j |  t |  d  sb t j d | |   | r |  j r t j d |  j	 d |   d  S)Nr   funcnamez'Code '%s' is not a function declarationz('**%s' keyword argument not allowed herer!   )
r   r   r   Z	ParseFuncr   hasattrr   r*   kwargs
kwargnames)r   r   Zallow_kwargsr   r   r   r   r   r   r   u   s    		zFunctionDecl.__init__Fc       	      C   s  g  } |  j  d d d  } |  j d d d  } |  j d d d	  } |  j d d d
  } |  j r | j d | j d   x | D] } | r | j d | | f  q | r| j d  } | d k r | j |  q| j d | t j |  j	   f  q | j |  q W|  j
 r<| j d | j d   x` | D]X } | sV| rf| j |  qC| j d  } | j d | t j |  j	   f  qCW| j   | S)aE  Return the argument declarations of this FunctionDecl as a printable
        list.

        By default the return value is appropriate for writing in a ``def``;
        set `as_call` to true to build arguments to be passed to the function
        instead (assuming locals with the same names as the arguments exist).
        Nr!   z**r   z%s=%s*r2   r2   r2   r2   )argnamesr5   defaults
kwdefaultsr4   appendpopr   ZExpressionGeneratorvalueZvarargsreverse)	r   Zas_callZ	namedeclsr7   r5   r8   r9   namedefaultr   r   r   get_argument_expressions   s:    		 	!
z%FunctionDecl.get_argument_expressionsc             C   s   t  |  j  t  |  j  S)N)tupler7   r5   )r   r   r   r   allargnames   s    zFunctionDecl.allargnamesN)r   r   r   r   r   r@   propertyrB   r   r   r   r   r0   q   s   9r0   c                   s(   e  Z d  Z d Z   f d d   Z   S)FunctionArgsz.the argument portion of a function declarationc                s   t    j d | |  d  S)Nzdef ANON(%s):pass)r-   r   )r   r   r4   )r/   r   r   r      s    zFunctionArgs.__init__)r   r   r   r   r   r   r   )r/   r   rD      s   rD   )
r   r   makor   r   r   r   r   r0   rD   r   r   r   r   <module>   s   ")T