
    -Shs                     h   d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZ ddlZddlmZ ddlmZ dd	lmZ dd
lmZ 	 	 ddZej        d             Zd Zd Zd Zd Zd Zd Zd Z G d dej                  Z G d de           Z! G d de          Z"d Z#d Z$d Z%dS ) zBAnnotate python syntax trees with formatting from the source file.    )absolute_import)division)print_functionN)zip)ast_constants)	ast_utils)
formatting)token_generatorTFc           	      b     t          j                    fd            }|S )Nc                 &   r|                      |d          nt                      5  r |                     |
r| j        nd            | |g|R i | r|                     |	
rdnd           d d d            d S # 1 swxY w Y   d S )NFtrailing_comma default
)	max_lines	semicoloncommentr   )scope_noop_contextprefix_indentsuffix)selfnodeargskwargsr   fmax_suffix_linesr   r   r   	statementr   s       Y/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/pasta/base/annotate.pywrappedz_gen_wrapper.<locals>.wrapped*   s'   49
N$**T%*
0
0
0} H H	 ED)"C$,,DDDad$T$$$V$$$	 HD$4	#Y-FTTB 	 	H 	H 	HH H H H H H H H H H H H H H H H H Hs   ABB
B

contextlibwraps)	r   r   r   r   r    r   r   r!   r#   s	   ```````` r"   _gen_wrapperr'   (   so    AH H H H H H H H H H H H 
.    c               #      K   d V  d S N r+   r(   r"   r   r   6   s      %%%%%r(   c                 $    t          | d          S )z5Decorates a function where the node is an expression.r   )r    r'   r   s    r"   
expressionr/   ;   s    	a!	,	,	,,r(   c                 $    t          | d          S )zFDecorates a function where the node is a FormattedValue in an fstring.Fr   r-   r.   s    r"   fstring_expressionr2   @       	au	%	%	%%r(   c                 $    t          | d          S )zEDecorates a function where the node has whitespace prefix and suffix.Fr1   r-   r.   s    r"   space_aroundr5   E   r3   r(   c                 &    t          | dd          S )z:Decorates a function where the node has whitespace prefix.F)r   r   r-   r.   s    r"   
space_leftr7   J   s    	auU	3	3	33r(   c                 ,    t          | ddddd          S )z3Decorates a function where the node is a statement.F   T)r   r    r   r   r!   r-   r.   s    r"   r!   r!   O   s&    	auqD"d
4 
4 
4 4r(   c                 &    t          | dd          S )z&Special decorator for the module node.FT)r   r   r-   r.   s    r"   moduler;   U   s    	aud	3	3	33r(   c                 F     t          j                    fd            }|S )zADecorates a function where the node is a statement with children.c                    |                      || j                    | |g|R i | t          | d          r{t          j        |          }|ra|j        t          |dd          k    rIt          j        |d          pd	                                d         }| 
                    ||           d S d S d S |                     |d	           d S )
Nr   block_suffixlinenor   r   r   Tr   )r   r   hasattrr   get_last_childr?   getattrfmtget
splitlinesr>   r   )r   r   r   r   
last_childindentr   s         r"   r#   z block_statement.<locals>.wrapped\   s    KKdlK+++AdD"4"""6"""t^$$ &+D11j	 (
)WT8Q-G-GGG'*h//74CCEEbI$'''''( (GG kk$k%%%%%r(   r$   )r   r#   s   ` r"   block_statementrJ   Z   s9    A
& 
& 
& 
& 
& 
.r(   c                   <    e Zd ZdZej        Zd Z fdZdzdZ		 	 d{dZ
d	 Zd
 Zej        d|d            Zd Zd}dZd~dZd Zd ZddZd Zed             Zed             Zej        d             Zed             Zed             Zd Zed             Z d Z!ej        d             Z"ej        d             Z#d Z$e%d             Z&ed              Z'ed!             Z(d" Z)ed#             Z*ed$             Z+ed%             Z,ed&             Z-e.d'             Z/d( Z0e.d)             Z1e.d*             Z2e.d+             Z3e.d,             Z4e5d-             Z6e.d.             Z7e.d/             Z8e.d0             Z9e.d1             Z:e.d2             Z;e.d3             Z<e.d4             Z=e.d5             Z>e5d6             Z?e.d7             Z@e.d8             ZAe.d9             ZBe.d:             ZCe5d;             ZDe5d<             ZEe5d=             ZFe5d>             ZGe5d?             ZHe5d@             ZIdA ZJdB ZKdC ZLe5dD             ZMe5dE             ZNe5dF             ZOe5dG             ZPe5dH             ZQe5dI             ZRe5dJ             ZSe5dK             ZTd}dLZUe5dM             ZVe5dN             ZWe5dO             ZXe5dP             ZYe5dQ             ZZe5dR             Z[e5dS             Z\e5dT             Z]e%dU             Z^dV Z_dW Z`dX ZadY ZbdZ Zcd[ Zdd\ Zed] Zfd^ Zgd_ Zhd` Zida Zjdb Zkdc Zldd Zmde Zndf Zodg Zpdh Zqdi Zrdj Zsdk Ztdl Zudm Zvdn Zwdo Zxdp Zye%dq             Zze%dr             Z{e%ds             Z|e%dt             Z}e~du             Ze~dv             Ze~dw             Zdx Zedy             Z xZS )BaseVisitora  Walks a syntax tree in the order it appears in code.

  This class has a dual-purpose. It is implemented (in this file) for annotating
  an AST with formatting information needed to reconstruct the source code, but
  it also is implemented in pasta.base.codegen to reconstruct the source code.

  Each visit method in this class specifies the order in which both child nodes
  and syntax tokens appear, plus where to account for whitespace, commas,
  parentheses, etc.
  c                 >    g | _         d| _        d| _        d| _        d S )Nr   z  )_stackr   _indent_diff_default_indent_diffr   s    r"   __init__zBaseVisitor.__init__}   s&    DKDLD $Dr(   c                     | j                             |           t          t          |                               |           || j                                         u sJ d S r*   )rN   appendsuperrL   visitpop)r   r   	__class__s     r"   rV   zBaseVisitor.visit   sZ    Kt	+t""4(((4;??$$$$$$$$r(   r   c                 B                           |d fdg|           dS )z>Account for some amount of whitespace as the prefix to a node.r   c                  0                          d          S )NTrA   wsrQ   s   r"   <lambda>z$BaseVisitor.prefix.<locals>.<lambda>   s    twwtw'<'< r(   r   Nattr)r   r   r   s   `  r"   r   zBaseVisitor.prefix   s0    IIdH<<<<=wIOOOOOr(   NFc                 R      fd}                      |d|g|           dS )z>Account for some amount of whitespace as the suffix to a node.c                  4                                    S )N)r   r   r   r[   )r   r   r   r   s   r"   _wszBaseVisitor.suffix.<locals>._ws   s    WWyIwWOOOr(   r   r   Nr^   )r   r   r   r   r   r   rb   s   ` ```  r"   r   zBaseVisitor.suffix   sX    P P P P P P P PIIdHseWI55555r(   c              #     K   t          ||          }| j        }| j        }t          j        |d         d          }|| j        }|| _        || j        z   | _        |D ]}|V  |                     |d|z  g            || _        || _        d S )Nr   indent_diffblock_suffix_%s)rD   r   rO   rE   rF   rP   r_   )r   r   children_attrchildrenprev_indentprev_indent_diffnew_diffchilds           r"   indentedzBaseVisitor.indented   s      t]++H,K(wx{M22H*h D!22DL  kkkkIId%5r:::DL(Dr(   c                     || _         d S r*   )rP   )r   rI   s     r"   set_default_indent_diffz#BaseVisitor.set_default_indent_diff   s     &Dr(   c              #      K   |r |                      ||dz   g |rdnd           dV  |r"|                      ||dz   g |rdnd           dS dS )aB  Context manager to handle a parenthesized scope.

    Arguments:
      node: (ast.AST) Node to store the scope prefix and suffix on.
      attr: (string, optional) Attribute of the node contained in the scope, if
        any. For example, as `None`, the scope would wrap the entire node, but
        as 'bases', the scope might wrap only the bases of a class.
      trailing_comma: (boolean) If True, allow a trailing comma at the end.
      default_parens: (boolean) If True and no formatting information is
        present, the scope would be assumed to be parenthesized.
    _prefix(r   r   N_suffix)r^   r   r   r_   r   default_parenss        r"   r   zBaseVisitor.scope   s        7
iidY&-52  7 7 7	EEE 7
iidY&-52  7 7 7 7 77 7r(   c                     dS )zAccount for a specific token.Nr+   )r   	token_vals     r"   tokenzBaseVisitor.token         r(   c                     dS )z'Handles an attribute on the given node.Nr+   )r   r   	attr_name	attr_valsdepsr   s         r"   r_   zBaseVisitor.attr   ry   r(   Tc                     dS )a9  Account for some amount of whitespace.

    Arguments:
      max_lines: (int) Maximum number of newlines to consider.
      semicolon: (boolean) If True, parse up to the next semicolon (if present).
      comment: (boolean) If True, look for a trailing comment even when not in
        a parenthesized scope.
    r   r+   )r   r   r   r   s       r"   r\   zBaseVisitor.ws   s	     2r(   c                     d|z  S )zAccount for a number of dots..r+   )r   num_dotss     r"   dotszBaseVisitor.dots   s    >r(   c                 .    |                      d          S )z)Account for up to one line of whitespace.r9   r   r[   rQ   s    r"   
ws_onelinezBaseVisitor.ws_oneline   s    77Q7r(   c                     dS )z/Account for a suffix that may or may not occur.Nr+   )r   r   r{   rw   r   s        r"   optional_tokenzBaseVisitor.optional_token   ry   r(   c                     |d         S )%Account for one of the given symbols.r   r+   )r   symbolss     r"   one_of_symbolszBaseVisitor.one_of_symbols   s    1:r(   c                 0    |                      |           d S r*   )generic_visitr   r   s     r"   visit_ModulezBaseVisitor.visit_Module   s    tr(   c                    t          j        |d          rdnd}|                     |d|| j        g|dz              |                     |j                   |                     |d| j        d| j        gd	           |                     |d
          D ]}|                     |           |j        r&t          |j                  dk    rt          |j        d         t          j                  rc|                     |j        d                   rCt          j        |j        d         dd           |                     |j        d                    d S |                     |d| j        g           |                     d           |                     |d| j        d| j        gd	           |                     |d          D ]}|                     |           d S d S )Nis_elifelififopen_if r   
open_block::
bodyr9   r   T
elseprefixelse	open_elseorelse)rE   rF   r_   r\   rV   testr   rl   r   len
isinstanceastIfcheck_is_elifsetrx   )r   r   tokstmts       r"   visit_IfzBaseVisitor.visit_If   s   GD),,
6&&$CIIdITW~sSyIAAAJJtyIIdL47C"A     dF++  
jj{ 
dk

a

Jt{1~sv$F$F



T[^
,
,  A	4000

4;q>"""""		$twi000

6		$dgsDO%D 	 	! 	! 	!MM$11 	 	D
**T



 	 	r(   c                     dS )a  Return True if the node continues a previous `if` statement as `elif`.

    In python 2.x, `elif` statments get parsed as If nodes. E.g, the following
    two syntax forms are indistinguishable in the ast in python 2.

    if a:
      do_something()
    elif b:
      do_something_else()

    if a:
      do_something()
    else:
      if b:
        do_something_else()

    This method should return True for the 'if b' node if it has the first form.
    Nr+   r   s     r"   r   zBaseVisitor.check_is_elif   ry   r(   c           	         |                      |dd| j        gd           |                     |j                   |                      |d| j        d| j        gd           |                     |d          D ]}|                     |           |j        rc|                      |d	| j        d	| j        d| j        g| j        d
z              |                     |d          D ]}|                     |           d S d S )Nwhile_keywordwhilezwhile r   r   r   r   r   r   else:
r   )r_   r\   rV   r   r   rl   r   r   r   r   r   s      r"   visit_WhilezBaseVisitor.visit_While  s$   IIdOgtw%7IJJJJJtyIIdL47C"A    dF++  
jj{ 
iiftwdoNy0  2 2 2--h//  $

4	  r(   c           	      (   t          t          d          rBt          |t          j                  r(|                     |dd| j        d| j        gd           n |                     |dd| j        gd           |                     |j                   |                     |d| j        d	| j        gd
           |                     |j                   |                     |d| j        d| j	        gd           | 
                    |d          D ]}|                     |           |j        rc|                     |d| j        d| j        d| j	        g| j        dz              | 
                    |d          D ]}|                     |           d S d S )NAsyncForfor_keywordasyncforz
async for r   zfor for_inin in r   r   r   r   r   r   r   )rB   r   r   r   r_   r\   rV   targetiterr   rl   r   r   r   s      r"   	visit_ForzBaseVisitor.visit_For  s   sJ GJtS\$B$B G
iimgtwtw%G$  & & & & iimeTW%5viFFFJJt{IIdHtwdg6IGGGJJtyIIdL47C"A    dF++  

4{ 
iiftwdoNy0  2 2 2 --h//  $

4  r(   c                 ,    |                      |          S r*   )r   r   s     r"   visit_AsyncForzBaseVisitor.visit_AsyncFor5  s    >>$r(   c                    t          |d          r|                     |          S t          |dd          s |                     |dd| j        gd           |                     |j                   |j        r@|                     |d| j        d| j        gd	           |                     |j                   t          |j	                  d
k    rY| 
                    |j	        d                   r9d|j	        d         _        |                     |d| j        d| j        gd           n&|                     |d| j        d| j        gd           |                     |d          D ]}|                     |           d S )Nitemsis_continuedFwithwith r   with_asas as r9   r   T
with_comma,, r   r   r   r   )rB   visit_With_3rD   r_   r\   rV   context_exproptional_varsr   r   check_is_continued_withr   r   rl   r   s      r"   
visit_WithzBaseVisitor.visit_With8  s   tW %t$$$4// B
iifvtw/iAAAJJt !!! %
iii$'4!96iJJJ
jj#$$$
49~~t;;DIaLII"&dil
iilTWc47$;TiJJJJ
iilTWc4?$C    dF++  
jj r(   c                 ,    |                      |          S r*   )r   r   s     r"   visit_AsyncWithzBaseVisitor.visit_AsyncWithL  s    ??4   r(   c                     d S r*   r+   r   s     r"   check_is_continued_tryz"BaseVisitor.check_is_continued_tryO  s    Dr(   c                     dS )a  Return True if the node continues a previous `with` statement.

    In python 2.x, `with` statments with many context expressions get parsed as
    a tree of With nodes. E.g, the following two syntax forms are
    indistinguishable in the ast in python 2.

    with a, b, c:
      do_something()

    with a:
      with b:
        with c:
          do_something()

    This method should return True for the `with b` and `with c` nodes.
    Nr+   r   s     r"   r   z#BaseVisitor.check_is_continued_withS  ry   r(   c                 N   t          t          d          rBt          |t          j                  r(|                     |dd| j        d| j        gd           n |                     |dd| j        gd           t          |j                  D ]J\  }}|                     |           |t          |j                  dz
  k    r| 
                    d           K|                     |d	d
| j        gd           |                     |d          D ]}|                     |           d S )N	AsyncWithr   r   zasync with r   r   r9   r   with_body_openr   r   r   )rB   r   r   r   r_   r\   	enumerater   rV   r   rx   r   rl   )r   r   iwithitemr   s        r"   r   zBaseVisitor.visit_With_3f  s7   sK   BZcm%D%D B
iifwA%  ' ' ' ' iifvtw/iAAA ,,  8
jj	
c$*oo!	!	!

3IId$sDO&<eILLLdF++  
jj r(   c                     |                      |j                   |j        rB|                     |d| j        d| j        gd           |                      |j                   d S d S )Nr   r   r   )rV   r   r   r_   r\   r   s     r"   visit_withitemzBaseVisitor.visit_withitemv  sl    JJt !!! %
iidTWdDG4fiEEE
jj#$$$$$% %r(   c                    t          |j                  D ]g\  }}|                     |d|z  | j        dgd           |                     |           |                     |d|z  | j        gd| j        z              h|                     |dd| j        |j        | j        gd|j        z  d	
           t          |dg           t          |dg           z   }|                     |dt          |          d          5  t          |j
                  D ]i\  }}|                     |           |                     |d|z  | j        g           ||d         k    r#|                     |d|z  d| j        gd           jt          |d          rt          |j                  D ]n\  }}|                     |           |                     |d|z  | j        g           ||j        d         k    r#|                     |d|z  d| j        gd           od d d            n# 1 swxY w Y   |                     |d| j        d| j        gd           |                     |d          D ]}|                     |           d S )Nzdecorator_prefix_%d@r   decorator_suffix_%dr   	class_defclasszclass %snamer   r}   baseskeywordsTr   ru   zbase_suffix_%dr@   zbase_sep_%dr   r   zkeyword_suffix_%dzkeyword_sep_%dr   r   r   r   )r   decorator_listr_   r\   rV   r   r   rD   r   boolr   rB   r   r   rl   )r   r   r   	decorator
class_argsbasekeywordr   s           r"   visit_ClassDefzBaseVisitor.visit_ClassDef}  s   !$"566 - -9
ii+a/$'3iMMM
jj
ii+a/$'t|+  - - - -IIdK'47DItw!G 49,9  > > >w++gdJ.K.KKJ	D'$z2B2B#' 
 
) 
) P Ptz** K K'!T

4		$(1,twi888:b>!!
))D-!+c47^T)
J
J
J	z	"	" P#DM22 	P 	PJAw
**W



))D-1DG9
=
=
=b)))IId,q03.$IOOOP P P P P P P P P P P P P P P 	IIdL47C"A    dF++  
jj s   ;DHH Hc                 
   t          |j                  D ]m\  }}|                     |d|z  | j        d| j        gd           |                     |           |                     |d|z  | j        gd| j        z              nt          t          d          r]t          |t          j
                  rC|                     |d| j        d| j        d	| j        |j        | j        gd
d|j        z             n;|                     |d| j        d	| j        |j        | j        gd
d|j        z             t          |j        dg           }t          t          |j        j        |z             |j        j        rdnd|j        j        rdndf          }|                     |d|dk    d          5  |                     |j                   d d d            n# 1 swxY w Y   t          |dd           rA|                     |d| j        d| j        gdd           |                     |j                   |                     |d| j        d| j        gd           |                     |d          D ]}|                     |           d S )Nzdecorator_symbol_%dr   r   r   r   AsyncFunctionDeffunction_defr   defr   zasync def %sr}   r   zdef %s
kwonlyargsr9   r   r   Tr   returnsreturns_prefixz->)r   z -> r   r   r   r   )r   r   r_   r\   rV   r   r   rB   r   r   r   r   rD   r   sumr   varargkwargr   r   rl   )r   r   r   r   r   
args_countr   s          r"   visit_FunctionDefzBaseVisitor.visit_FunctionDef  s   !$"566 - -9
ii+a/$'31H    
jj
ii+a/$/1Bt|+  - - - -'(( >4-..>
iin'47E47DItwO(B  D D D D iin%$)TW=49(<  > > > L"55Jc$).:5669+2aa9?1aa3 4 4J 
D&a#' 
 
) 
)  
jj               tY%% 
ii&$(@!6  3 3 3
jjIIdL47C"A    dF++  
jj s   +GGGc                 ,    |                      |          S r*   )r   r   s     r"   visit_AsyncFunctionDefz"BaseVisitor.visit_AsyncFunctionDef  s    !!$'''r(   c           	      <   |                      |dd| j        d| j        gd           t          |j                  dk    rS|                     |j        d                   r3d|j        d         _        |                     |j        d                    n.|                     |d	          D ]}|                     |           |                      |d
| j        d| j        d| j        gd           |                     |d          D ]}|                     |           d S )Nopen_trytryr   try:
r   r9   r   Tr   open_finallyfinally	finally:
	finalbody)	r_   r\   r   r   r   r   r   rV   rl   r   s      r"   visit_TryFinallyzBaseVisitor.visit_TryFinally  s2    	IIdJdo F        49~~t::49Q<HH"&dil
jj1--f--  $

4IIdNw	47CA"  $ $ $ dK00  
jj r(   c           	         t          |dd          s'|                     |dd| j        d| j        gd           |                     |d          D ]}|                     |           |j        D ]}|                     |           |j        r[|                     |d	| j        d
| j        d| j        gd           |                     |d          D ]}|                     |           d S d S )Nr   Fr   r   r   r   r   r   r   r   r   r   )rD   r_   r\   r   rl   rV   handlersr   r   r   r   handlers       r"   visit_TryExceptzBaseVisitor.visit_TryExcept  s'   4// "
iij5$'3"H   " " "dF++  
jj=  
jj{ 
iik&$'3@!  # # # --h//  $

4  r(   c           	         |                      |d| j        d| j        d| j        gd           |                     |d          D ]}|                     |           |j        D ]}|                     |           |j        r[|                      |d| j        d| j        d| j        gd	           |                     |d
          D ]}|                     |           |j        r[|                      |d| j        d| j        d| j        gd           |                     |d          D ]}|                     |           d S d S )Nr   r   r   r   r   r   r   r   r   r   r   r   r   r  )r_   r\   r   rl   rV   r  r   r  r  s       r"   	visit_TryzBaseVisitor.visit_Try  s    	IIdJ%#t O       dF++  
jj=  
jj{ 
iik&$'3@!  # # # --h//  $

4~ 
iin)TWc4?C$  & & & --k22  $

4  r(   c           	      `   |                      d           |j        r|                     |j                   |j        rA|j        r:|                     |d| j        |                     dd          | j        gd           |j        rTt          |j        t          j	                  r|                     |j                   n|                      |j                   |                     |d| j        d| j
        gd           |                     |d	          D ]}|                     |           d S )
Nexceptr   r   r   r   r   r   r   r   )rx   typerV   r   r_   r\   r   r   r   ASTr   rl   r   s      r"   visit_ExceptHandlerzBaseVisitor.visit_ExceptHandler  s:   JJxy 
jjy  TY  
iidTWd&9&9$&D&DdgN       y 	DIsw	'	' 

49

49IIdL47C"A    dF++  
jj r(   c                    t          |d          r|                     |          S |                     d           |j        r9|                     |d| j        gd           |                     |j                   |j        r@|                     |d| j        d| j        gd           |                     |j                   |j        rB|                     |d	| j        d| j        gd           |                     |j                   d S d S )
Ncauseraisetype_prefixr   r   inst_prefixr   r   tback_prefix)	rB   visit_Raise_3rx   r  r_   r\   rV   insttbackr   s     r"   visit_RaisezBaseVisitor.visit_Raise  s   tW &%%%JJwy 
iimdgYi<<<
jjy 
iimdgsDG%<diKKK
jjz 
iintwTW&=tiLLL
jj r(   c                 H   |j         r|                     |dd| j        gd           |                     |j                    |j        rB|                     |d| j        d| j        gd           |                     |j                   d S d S |                     d           d S )N
open_raiser  zraise r   cause_prefixfromz from )excr_   r\   rV   r  rx   r   s     r"   r  zBaseVisitor.visit_Raise_3  s    x 
iilWdg$6iIII
jj	 		$&$'(B" 	 	$ 	$ 	$

4: 
 jjr(   c                     |                      |dd| j        gd           |                     |j                   |j        r<|                      |dd| j        gd           |                     |j                   d S d S )Nassert_openassertzassert r   
msg_prefixr   r   )r_   r\   rV   r   msgr   s     r"   visit_AssertzBaseVisitor.visit_Assert*  s    IIdMHdg#6	IJJJJJtyx 
iilS$'NDiAAA
jj r(   c                     t          |j                  D ]C\  }}|                     |           |                     |d|z  | j        d| j        gd           D|                     |j                   d S )Nzequal_%d= = r   )r   targetsrV   r_   r\   valuer   r   r   r   s       r"   visit_AssignzBaseVisitor.visit_Assign2  sy    t|,, N N	6
jj
iij1ntwTW&=uiMMMMJJtzr(   c                    |                      |j                   dt          j        t	          |j                           d         z  }|                     |d| j        || j        gd|z             |                      |j                   d S )Nz%s=r   operator %s r   )	rV   r   r   NODE_TYPE_TO_TOKENSr  opr_   r\   r(  )r   r   op_tokens      r"   visit_AugAssignzBaseVisitor.visit_AugAssign9  s    JJt{}8dgGJJHIIdJ(DG <x'  ) ) )JJtzr(   c                 L   |                      |j                   |                     |d| j        d| j        gd           |                      |j                   |j        rB|                     |d| j        d| j        gd           |                      |j                   d S d S )Ncolonr   : r   equalr%  r&  )rV   r   r_   r\   
annotationr(  r   s     r"   visit_AnnAssignzBaseVisitor.visit_AnnAssignA  s     	JJt{IIdGdgsDG4dICCCJJtz 
iigdg6iFFF
jj r(   c                 z    |                      |dd| j        gd           |                     |j                   d S )Nawaitzawait r   r_   r\   rV   r(  r   s     r"   visit_AwaitzBaseVisitor.visit_AwaitK  s=    IIdGgtw/IBBBJJtzr(   c                 0    |                      d           d S )Nbreakrx   r   s     r"   visit_BreakzBaseVisitor.visit_BreakP  s    JJwr(   c                 0    |                      d           d S )Ncontinuer>  r   s     r"   visit_ContinuezBaseVisitor.visit_ContinueT  s    JJzr(   c                    |                      |dd| j        gd           t          |j                  D ]R\  }}|                     |           ||j        d         ur)|                      |d|z  | j        d| j        gd           Sd S )Ndelzdel r   r@   comma_%dr   r   )r_   r\   r   r'  rV   r)  s       r"   visit_DeletezBaseVisitor.visit_DeleteX  s    IIdEE47+VI<<<t|,, O O	6
jj	t|B'	'	'		$
Q#tw(?	NNNO Or(   c           
      "   |                      |dd| j        gd           |                     |ddd          5  |                     |j                   |j        r|                      |d| j        |                     dd	          | j        gd
           |                     |j                   |j        r@|                      |d| j        d	| j        gd
           |                     |j                   d d d            d S # 1 swxY w Y   d S )Nexecr   r   FTr   
in_globalsr   r   r   	in_locals)r_   r\   r   rV   r   globalsr   localsr   s     r"   
visit_ExeczBaseVisitor.visit_Exec`  sZ    	IIdFVTW-vI>>>	D&t	L	L 	" 	"
jj	 "		$7D//c::DGD 	 	  	  	  	

4<   ; 	"
))D+dg'>)
M
M
M
**T[
!
!
!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s   B=DDDc                 :    |                      |j                   d S r*   rV   r(  r   s     r"   
visit_ExprzBaseVisitor.visit_Expro      JJtzr(   c                    |                      d           g }|j        D ]K}||j        d         k    r|                    | j        dg           |                    | j        |g           L|                     |d|           d S )Nglobalr   r   namesrx   rT  extendr\   r_   r   r   identifiersidents       r"   visit_GlobalzBaseVisitor.visit_Globals  s    JJxK + +	$*Q-		DGS>***$'5)****IIdG[)))))r(   c                 :   |                      d           t          |j                  D ]p\  }}|                     |d|z  | j        gd           |                     |           ||j        d         k    r#|                     |d|z  | j        dgd           qd S )Nimportalias_prefix_%dr   r   r@   alias_sep_%dr   )rx   r   rT  r_   r\   rV   )r   r   r   aliass       r"   visit_ImportzBaseVisitor.visit_Import}  s    JJxdj)) I I5
ii'!+dgYiDDD
jj	$*R.	 	 		$*TWcNC	HHH	I Ir(   c                    |                      d           |                     |d| j        gd           g }|j        dk    r4|                    |                     |j                  | j        g           |j        rL|j                            d          }|d d         D ]}|| j        || j        dgz  }|| j        |d         gz  }|                     |d|d	d|j        z  |j        pd
z              |                     |d| j        gd           |                      d           |                     |dd          5  t          |j
                  D ]n\  }}|                     |d|z  | j        gd           |                     |           ||j
        d         ur#|                     |d|z  | j        dgd           o	 d d d            d S # 1 swxY w Y   d S )Nr  module_prefixr   r   r   r   r@   r;   )levelr;   r   r   module_suffixr\  rT  Tr   r]  r^  r   )rx   r_   r\   rc  rV  r   r;   splitr   r   rT  rV   )r   r   module_patternpartspartr   r_  s          r"   visit_ImportFromzBaseVisitor.visit_ImportFrom  s]   JJvIIdOdgYI<<<NzA~~TYYtz22DG<==={ -k$$e* 8 8$47D$'377%),,nIIdHn&DJ&$+*;<  > > > 	IIdOdgYI<<<JJx	D'$	7	7 K K
++ K K(!U		$)A-y#	FFF

5
2&&
))D.1,twnc)
J
J
J	KK K K K K K K K K K K K K K K K K Ks   BGGGc                     |                      t                     |                     |dt          z  | j        d| j        gd           |                      |j                   d S )Nr5  z:=z := r   )rV   r   r_   r   r\   r(  r   s     r"   visit_NamedExprzBaseVisitor.visit_NamedExpr  sW    JJvIIdGaK$'4!96IJJJJJtzr(   c                    |                      d           g }|j        D ]K}||j        d         k    r|                    | j        dg           |                    | j        |g           L|                     |d|           d S )Nnonlocalr   r   rT  rU  rW  s       r"   visit_NonlocalzBaseVisitor.visit_Nonlocal  s    JJzK + +	$*Q-		DGS>***$'5)****IIdG[)))))r(   c                 0    |                      d           d S )Npassr>  r   s     r"   
visit_PasszBaseVisitor.visit_Pass  s    JJvr(   c                    |                      |dd| j        gd           |j        r|                      |dd| j        gd           |                     |j                   |j        r'|                      |d| j        d| j        gd	           n'|j        s |                      |d
| j        dgd           t          |j                  D ]z\  }}|                     |           ||j        d         ur*|                      |d|z  | j        d| j        gd	           S|j        s |                      |d
| j        dgd           {d S )N
print_openprintzprint r   redirectionz>>values_prefixr   r   r   r@   rE  )r_   r\   destrV   valuesnlr   )r   r   r   r(  s       r"   visit_PrintzBaseVisitor.visit_Print  sh   IIdL7DG"4hIGGGy G
iimdDG_diCCC
jj	 G		$$'3)@$	OOOOw G		$(47C.#	FFFdk** G G5
jj	dk"o	%	%		$
Q#tw(?	NNNNw G		$(47C.#	FFFG Gr(   c                     |                      d           |j        r;|                     |d| j        gd           |                     |j                   d S d S )Nreturnreturn_value_prefixr   r   rx   r(  r_   r\   rV   r   s     r"   visit_ReturnzBaseVisitor.visit_Return  sa    JJxz 
ii+dgYiDDD
jj r(   c                     |                      d           |j        r;|                     |d| j        gd           |                     |j                   d S d S )Nyieldyield_value_prefixr   r   r~  r   s     r"   visit_YieldzBaseVisitor.visit_Yield  sa    JJwz 
ii*TWIsiCCC
jj r(   c                     |                      |dd| j        d| j        gd           |                     |j                   d S )N
yield_fromr  r  zyield from r   r:  r   s     r"   visit_YieldFromzBaseVisitor.visit_YieldFrom  sM    IIdL7DGVTW"E#  % % %JJtzr(   c                     |                      |j                   |                     |d| j        d| j        gd           |                     |j                   d S )Ndotr   r   )rV   r(  r_   r\   rx   r   s     r"   visit_AttributezBaseVisitor.visit_Attribute  sU    JJtzIIdEDGS$'2CI@@@JJtyr(   c                    t           j        t          |j                           d         }|                     |j                   |                     |d| j        || j        gd|z  d           |                     |j                   d S )Nr   r/  r-  r/  r   )	r   r.  r  r/  rV   leftr_   r\   rightr   r   	op_symbols      r"   visit_BinOpzBaseVisitor.visit_BinOp  s    1$tw--@CIJJtyIIdD47Itw7y(w  8 8 8JJtzr(   c                 0   t           j        t          |j                           d         }t	          |j                  D ]V\  }}|                     |           ||j        d         ur-|                     |d|z  | j        || j        gd|z  d           Wd S )Nr   r@   zop_%dr-  r  r   )	r   r.  r  r/  r   rx  rV   r_   r\   )r   r   r  r   r(  s        r"   visit_BoolOpzBaseVisitor.visit_BoolOp  s    1$tw--@CIdk** < <5
jj	dk"o	%	%		$!dgy$'%B 9,7 	 	< 	< 	<< <r(   c                 T   |                      |j                   |                     |dd          5  t          j        d d         dk    r|                     |          }n|                     |          }|r|                     |dd           d d d            d S # 1 swxY w Y   d S )N	argumentsTru      )      r   r   )rV   funcr   sysversion_infovisit_Call_arguments35visit_Call_argumentsr   )r   r   any_argss      r"   
visit_CallzBaseVisitor.visit_Call  s    JJty	D+d	;	; 	9 	9 
	"1"		'	'..t44,,T22	 9D"2C888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9s   ABB!$B!c                 2   d }|j         r,t          d |j        D             d|j         fgz   |          }nd |j        D             }d |j        D             |z   }|j        r|                    d|j        f           t          |          D ]{\  }\  }}|#|                     |d|z  | j        |g|	           | 	                    |           ||d
         d         ur)|                     |d|z  | j        d| j        gd	           |t          |          S )Nc                     | d         }t          |t          j                  r|j        }t	          |dd          t	          |dd          fS )Nr9   r?   r   
col_offsetr   r   r   r(  rD   )tupargs     r"   arg_locationz6BaseVisitor.visit_Call_arguments.<locals>.arg_location  sI    Fc	C	%	% ic8Q''lA)F)FGGr(   c                     g | ]}d |fS r*   r+   .0kws     r"   
<listcomp>z4BaseVisitor.visit_Call_arguments.<locals>.<listcomp>  s    
.
.
."D":
.
.
.r(   *keyc                     g | ]}d |fS r*   r+   r  s     r"   r  z4BaseVisitor.visit_Call_arguments.<locals>.<listcomp>  s    <<<$<<<r(   c                     g | ]}d |fS r*   r+   )r  ns     r"   r  z4BaseVisitor.visit_Call_arguments.<locals>.<listcomp>  s    ---aq	---r(   **z	%s_prefixr   r@   r9   rE  r   r   )starargssortedr   r   r   rT   r   r_   r\   rV   r   )r   r   r  sorted_keywordsall_argsr   r   r  s           r"   r  z BaseVisitor.visit_Call_arguments  sU   H H H } =
.
.
.
.
.32F1G
G  oo =<dm<<<o--49---?H{ +ootT[)***%h// O O=FC				$f,tw.?	PPP
jjooo	HRLO	#	#		$
Q#tw(?	NNN>>r(   c                 @   d }t          |j        |j        z   t          j        |                    }t          |          D ]M\  }}|                     |           ||d         ur)|                     |d|z  | j        d| j        gd           Nt          |          S )Nc                    d } ||           rt          |t          j                  rdS  ||          rt          | t          j                  rdS d } ||           } ||          }d|v sd|v rdS ||k     rdn	||k    rdndS )z&Old-style comparator for sorting args.c                 P    t          | t          j        t          j        f           S r*   )r   r   r   Starredas    r"   is_argzGBaseVisitor.visit_Call_arguments35.<locals>.arg_compare.<locals>.is_arg!  s    a#+s{!;<<<<r(   r@   r9   c                     t          | t          j                  r| j        } t	          | dd           t	          | dd           fS )Nr?   r  r  r  s    r"   get_poszHBaseVisitor.visit_Call_arguments35.<locals>.arg_compare.<locals>.get_pos-  s@    a%% 	g!8T**GA|T,J,JKKr(   Nr   )r   r   r   )a1a2r  r  pos1pos2s         r"   arg_comparez7BaseVisitor.visit_Call_arguments35.<locals>.arg_compare  s    = = = 
 
2s{33 r6":: *R55 q
L L L
 WR[[dWR[[d	q $;;RRAA1<r(   r  r@   rE  r   r   r   )
r  r   r   	functools
cmp_to_keyr   rV   r_   r\   r   )r   r   r  r  r   r  s         r"   r  z"BaseVisitor.visit_Call_arguments35  s    = = => di$-/#.{;;= = =H H%% O O3
jjooo	HRL	 	 		$
Q#tw(?	NNN>>r(   c                 z    |                      |dd| j        gd           |                     |j                   d S )Nstarr  r   r:  r   s     r"   visit_StarredzBaseVisitor.visit_StarredG  s<    IIdFS$'NCI888JJtzr(   c                 v   |                      |j                   t          t          |j        |j                            D ]v\  }\  }}|                     |d|z  | j        gd           |                      |           |                     |d|z  | j        gd           |                      |           wd S )Nzop_prefix_%dr   r   zop_suffix_%d)rV   r  r   r   opscomparatorsr_   r\   )r   r   r   r/  
comparators        r"   visit_ComparezBaseVisitor.visit_CompareK  s    JJty(TXt7G)H)HII  B

iinq(47)SiAAA
jjnnn
iinq(47)SiAAA
jj	 r(   c                    |                      d           t          t          t          |j                            |j        |j                  D ]\  }}}|$|                     |d|z  | j        dgd           n>|                     |           |                     |d|z  | j        d| j        gd           |                     |           ||j        d         ur)|                     |d	|z  | j        d
| j        gd           | 	                    |dd
d           |                     |d| j        dgd           d S )N{zstarstar_%dr  r   zkey_val_sep_%dr   r4  r@   rE  r   r   
extracommaTallow_whitespace_prefixclose_prefix})
rx   r   ranger   keysrx  r_   r\   rV   r   )r   r   r   r  r(  s        r"   
visit_DictzBaseVisitor.visit_DictT  sI   JJsOOOU3ty>>22DIt{KK 
O 
O3			$)DGT?D	IIII

3		$(1,twTW.E 	 	  	  	 
jj	dk"o	%	%		$
Q#tw(?	NNNlCNNNIIdNTWcNCI@@@@@r(   c                 x   |                      |dd| j        gd           |                     |j                   |                      |d| j        d| j        gd           |                     |j                   |j        D ]}|                     |           |                      |d| j        dgd           d S )	N	open_dictr  r   key_val_sepr   r4  
close_dictr  )r_   r\   rV   r  r(  
generators)r   r   comps      r"   visit_DictCompzBaseVisitor.visit_DictCompe  s    IIdK#twI===JJtxIIdMDGS$'#:DIIIIJJtz  
jjIIdL47C.#I>>>>>r(   c                 0    |                      |           d S r*   	_comp_expr   s     r"   visit_GeneratorExpzBaseVisitor.visit_GeneratorExpo  s    NN4r(   c                 :   |                      |j                   |                     |d| j        d| j        gd           |                      |j                   |                     |d| j        d| j        gd           |                      |j                   d S )Nr    if r   r   z else )rV   r   r_   r\   r   r   r   s     r"   visit_IfExpzBaseVisitor.visit_IfExps  s    JJtyIIdD47D$'2FICCCJJtyIIdFTWfdg6IIIIJJt{r(   c                     |                      |dd| j        gd           |                     |j                   |                      |d| j        d| j        gd           |                     |j                   d S )N
lambda_deflambdazlambda r   open_lambdar   r4  )r_   r\   rV   r   r   r   s     r"   visit_LambdazBaseVisitor.visit_Lambda{  sv    IIdL8TW"5yIIIIJJtyIIdMDGS$'#:DIIIIJJtyr(   c                    |                      |dd| j        gd           t          |j                  D ]R\  }}|                     |           ||j        d         ur)|                      |d|z  | j        d| j        gd           S|j        r|                     |ddd	
           |                      |d| j        dgd           d S )N	list_open[r   r@   rE  r   r   r  Tr  
list_close]r_   r\   r   eltsrV   r   r   r   r   elts       r"   
visit_ListzBaseVisitor.visit_List  s    IIdK#twI===DI&& O O3
jjooo	DIbM	!	!		$
Q#tw(?	NNNy Q
$c4PPPIIdL47C.#I>>>>>r(   c                 6    |                      |dd           d S )Nr  r  
open_braceclose_bracer  r   s     r"   visit_ListCompzBaseVisitor.visit_ListComp       NN4CSN99999r(   c                 $   |r |                      |d|| j        g|           |                     |j                   t	          |j                  D ]\  }}|                     |           |r"|                      |d| j        |g|           d S d S )Ncompexp_openr   compexp_close)r_   r\   rV   r  r   r  )r   r   r  r  r   r  s         r"   r  zBaseVisitor._comp_exp  s     Q
iinz47&;ZiPPPJJtxT_--  4
jj %
iio'=#  % % % % %% %r(   c                 :    |                      |j                   d S r*   )rx   idr   s     r"   
visit_NamezBaseVisitor.visit_Name  s    JJtwr(   c                 T    |                      t          |j                             d S r*   )rx   strr(  r   s     r"   visit_NameConstantzBaseVisitor.visit_NameConstant  s"    JJs4:r(   c                     |                      |dd| j        gd           |                     |j                   |                      |d| j        dgd           d S )N	repr_open`r   
repr_closer:  r   s     r"   
visit_ReprzBaseVisitor.visit_Repr  s\    IIdK#twI===JJtzIIdL47C.#I>>>>>r(   c                    |                      |dd| j        gd           t          |j                  D ]l\  }}|                     |           ||j        d         ur*|                      |d|z  | j        d| j        gd           S|                     |ddd	
           m|                      |d| j        dgd           d S )Nset_openr  r   r@   rE  r   r   r  Tr  	set_closer  r  r  s       r"   	visit_SetzBaseVisitor.visit_Set  s    IIdJdgI<<<DI&& : :3
jjooo	DIbM	!	!		$
Q#tw(?	NNNND,48 	 	: 	: 	: 	: 	IIdK$'3I=====r(   c                 6    |                      |dd           d S )Nr  r  r  r  r   s     r"   visit_SetCompzBaseVisitor.visit_SetComp  r  r(   c                     |                      |j                   |                     |d| j        d| j        gd           |                      |j                   |                     |d| j        dgd           d S )N
slice_openr  r   slice_closer  )rV   r(  r_   r\   slicer   s     r"   visit_SubscriptzBaseVisitor.visit_Subscript  su    JJtzIIdL47C"93IGGGJJtzIIdMDGS>3I?????r(   c                    |                      |dd          5  t          |j                  D ]\  }}|                     |           ||j        d         ur*|                     |d|z  | j        d| j        gd           S|                     |d	ddt          |j                  d
k               	 d d d            d S # 1 swxY w Y   d S )Nr  Tr  r@   rE  r   r   r   r  r9   )r  r   )r   r   r  rV   r_   r\   r   r   r  s       r"   visit_TuplezBaseVisitor.visit_Tuple  s5   	D&	6	6 	; 	;di(( ; ;&!S

3dim##
))D*q.47C*A   " " " " 

dL#6:&)$)nn&9  ; ; ; ;;	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s   BC  CCc                     t           j        t          |j                           d         }|                     |d|| j        g|d           |                     |j                   d S )Nr   r/  r  r   )r   r.  r  r/  r_   r\   rV   operandr  s      r"   visit_UnaryOpzBaseVisitor.visit_UnaryOp  sY    1$tw--@CIIIdD9dg.	IPPPJJt|r(   c                 0    |                      d           d S )N...r>  r   s     r"   visit_EllipsiszBaseVisitor.visit_Ellipsis  s    JJur(   c                 v    |                      t          j        t          |                   d                    d S Nr   rx   r   r.  r  r   s     r"   	visit_AddzBaseVisitor.visit_Add  -    JJ}0d<Q?@@@@@r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   	visit_SubzBaseVisitor.visit_Sub  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   
visit_MultzBaseVisitor.visit_Mult  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   	visit_DivzBaseVisitor.visit_Div  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   	visit_ModzBaseVisitor.visit_Mod  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   	visit_PowzBaseVisitor.visit_Pow  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_LShiftzBaseVisitor.visit_LShift  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_RShiftzBaseVisitor.visit_RShift  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_BitAndzBaseVisitor.visit_BitAnd  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_BitOrzBaseVisitor.visit_BitOr  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_BitXorzBaseVisitor.visit_BitXor  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_FloorDivzBaseVisitor.visit_FloorDiv   r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_InvertzBaseVisitor.visit_Invert  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   	visit_NotzBaseVisitor.visit_Not  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   
visit_UAddzBaseVisitor.visit_UAdd	  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   
visit_USubzBaseVisitor.visit_USub  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_EqzBaseVisitor.visit_Eq  r!  r(   c                 ^    |                      |d|                     dd          g           d S )Nr,  z!=z<>)r_   r   r   s     r"   visit_NotEqzBaseVisitor.visit_NotEq  s1    IIdJ!4!4T4!@!@ ABBBBBr(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_LtzBaseVisitor.visit_Lt  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   	visit_LtEzBaseVisitor.visit_LtE  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_GtzBaseVisitor.visit_Gt  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   	visit_GtEzBaseVisitor.visit_GtE  r!  r(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_IszBaseVisitor.visit_Is!  r!  r(   c                 H    |                      |dd| j        dgd           d S )Ncontentisnotzis notr   r_   r\   r   s     r"   visit_IsNotzBaseVisitor.visit_IsNot$  s+    IIdIdgu5xIHHHHHr(   c                 v    |                      t          j        t          |                   d                    d S r  r  r   s     r"   visit_InzBaseVisitor.visit_In'  r!  r(   c                 H    |                      |dd| j        dgd           d S )NrO  rQ  r   znot inr   rR  r   s     r"   visit_NotInzBaseVisitor.visit_NotIn*  s+    IIdItw5xIHHHHHr(   c                 r   g }|j                             d          }|d d         D ]}|| j        || j        dgz  }|| j        |d         gz  }|                     |d|d|j                    |j        B|                     |d| j        d| j        gd	           |                     |j                   d S d S )
Nr   r@   r   r   r   asnamer   r   r   )r   re  r\   r_   rY  rx   )r   r   name_patternrg  rh  s        r"   visit_aliaszBaseVisitor.visit_alias1  s    LIOOC  Ecrc
 4 4twdgs33llTWeBi((LIIdFLi  ! ! ! {
iih$ 8&iIII
jj r(   c                     |                      |j                   |j        B|                     |d| j        d| j        gd           |                     |j                   d S d S )Nannotation_prefixr   r4  r   )rx   r  r6  r_   r\   rV   r   s     r"   	visit_argzBaseVisitor.visit_arg>  sp    JJtx"
ii)DGS$'+B    
jj!!!!! #"r(   c           
      2	   t          |dg           }t          |dg           }t          |          t          |          k    sJ t          t          |j        |z             t          t          |dg                     |j        rdnd|j        rdndf          }d}t          |dg           |j        z   }|j        r|d t          |j                            n|}|j        r"|j        t          |j                   d          n|j        }|D ]}	|                     |	           |dz  }||k     r)|                     |d|z  | j	        d| j	        gd	           |t          t          |dg                     k    r-|                     |d
| j	        d| j	        d| j	        gd	           t          t          ||j                            D ]\  }
\  }	}|                     |	           |                     |d|
z  | j	        d| j	        gd	           |                     |           |dz  }||k     r)|                     |d|z  | j	        d| j	        gd	           |j        r|                     |d| j	        d| j	        gd	           t          |j        t          j                  r|                     |j                   n7|                     |j                   |                     |d| j	        g           |dz  }||k     r|                     d           n-|r+|                     |d| j	        d| j	        d| j	        g           t          t          ||                    D ]\  }
\  }	}|                     |	           |>|                     |d|
z  | j	        d| j	        gd	           |                     |           |dz  }||k     r)|                     |d|z  | j	        d| j	        gd	           |j        r|                     |d| j	        d| j	        gd	           t          |j        t          j                  r|                     |j                   d S |                     |j                   |                     |d| j	        g           d S d S )Nr   kw_defaultsposonlyargsr9   r   rE  r   r   r   posonly_sep/z/, z
default_%dr%  vararg_prefixr  vararg_suffix
kwonly_sepzkw_default_%dkwarg_prefixr  kwarg_suffix)rD   r   r   r   r   r   defaultsrV   r_   r\   r   r   r   r   r  rx   )r   r   r   r`  
total_argsarg_ipos_args
positionalr   r  r   r   s               r"   visit_argumentszBaseVisitor.visit_argumentsF  s    |R00J$r22Kz??c+......c$)j011'$r::;;;-aaA:,aa1. / /J Et]B//$);H37=N.C....//hJ15MdiT]+++,,--DIG ! !
jjoooqje					$
U*TWc47,C 	 	  	  	 	#gdM26677	7	7		$dgsDG'L 	 	! 	! 	! 's7DM'B'BCC    >C
jjooo
iilQ&#tw(?    
jjqje					$
U*TWc47,C 	 	  	  	  { L
iiodg'>iLLL	DK	)	) 4

4;

4;		$$'333qje			

3	 L iilTWc47C$IJJJ&s:{'C'CDD 	  	 >C
jjooo				$!+dgsDG-D 	 	 	 	

7qje					$
U*TWc47,C 	 	  	  	  z 3
iintwdg&>iMMM	DJ	(	( 3

4:

4:		$	222223 3r(   c           	      4   t          |dd          r.|                     |d| j        d| j        d| j        gd           n&|                     |d| j        d| j        gd           |                     |j                   |                     |d| j        d| j        gd	           |                     |j                   t          |j                  D ]C\  }}|                     |d
|z  | j        d| j        gd           |                     |           Dd S )Nis_asyncFr   r   z async for r   z for r   r   zif_%dr   r  )rD   r_   r\   rV   r   r   r   ifs)r   r   r   if_exprs       r"   visit_comprehensionzBaseVisitor.visit_comprehension  s*   tZ'' I
iiedgwH%  ' ' ' ' iiedgudg6iHHHJJt{IIdD47D$'2FICCCJJty))  
7
iigkDGT47#;ViLLL
jj r(   c                     |j         !|                     |dd| j        gd           n:|                     |j                    |                     |d| j        dgd           |                     |j                   d S )Nstarsr  r   eqr%  )r  r_   r\   rx   rV   r(  r   s     r"   visit_keywordzBaseVisitor.visit_keyword  s{    x
iigdgi====
jj
iidTWcNCi888JJtzr(   c                 :    |                      |j                   d S r*   rO  r   s     r"   visit_IndexzBaseVisitor.visit_Index  rQ  r(   c                    t          |j                  D ]R\  }}|                     |           ||j        d         ur)|                     |d|z  | j        d| j        gd           S|                     |ddd           d S )Nr@   z
dim_sep_%dr   r   r   r   F)r   dimsrV   r_   r\   r   )r   r   r   dims       r"   visit_ExtSlicezBaseVisitor.visit_ExtSlice  s    DI&& Q Q3
jjooo	DIbM	!	!		$q(47C*A4	PPP.UCCCCCr(   c                 6   |j         r|                     |j                    |                     |d| j        d| j        gd           |j        r|                     |j                   |                     |d| j        g           |                     |dd           |                     |d| j        g           |j        rV|                     |          rC|                     |ddd           d|j        _        |                     |j                   d S d S d S )	N
lowerspacer   r   
stepspace1
step_colon
stepspace2step_colon_2T)	lowerrV   r_   r\   upperr   stepcheck_slice_includes_stepis_explicit_stepr   s     r"   visit_SlicezBaseVisitor.visit_Slice  s#   z 
jjIIdL47C"93IGGGz 
jjIIdL47),,,lC000IIdL47),,,y T33D99 
$TBBB#'di 
jj   r(   c                     |j         sdS t          |j         dd          rdS t          |j         t          j                  o|j         j        dk     S )FHelper function for Slice node to determine whether to visit its step.Fr  TNone)r  rD   r   r   Namer   r   s     r"   r  z%BaseVisitor.check_slice_includes_step  sT    
 9 Uty,e44 T49ch//JDILF4JKKr(   c           	      Z   |                      |j                   |j        dk    r<|                     |d| j        dt          |j                  gdd|j        z             |j        rB|                     |d| j        d| j        gd	           |                      |j                   d S d S )
Nr@   
conversion!)r  z!%cr   format_spec_prefixr   r   )rV   r(  r  r_   r\   chrformat_specr   s     r"   visit_FormattedValuez BaseVisitor.visit_FormattedValue  s    JJtz"
iil#s4?334?/  1 1 1  #
ii*TWc47,C    
jj!"""""# #r(   )r   )NFFr   NFFNNNFT)F)__name__
__module____qualname____doc__abcABCMeta__metaclass__rR   rV   r   r   rl   rn   r%   contextmanagerr   rx   r_   r\   r   r   r   r   r;   r   rJ   r   abstractmethodr   r   r   r   r   r   r   r   r   r5   r   r   r   r   r  r  r	  r  r!   r  r  r#  r*  r1  r7  r/   r;  r?  rB  rF  rM  rP  rZ  r`  ri  rk  rn  rq  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r  r   r#  r%  r'  r)  r+  r-  r/  r1  r3  r5  r7  r9  r;  r=  r?  rA  rC  rE  rG  rI  rK  rM  rS  rU  rW  r[  r^  rn  rs  rw  r7   ry  r}  r  r  r2   r  __classcell__rX   s   @r"   rL   rL   o   s
       	 	 +-% % %% % % % %
P P P P CH6 6 6 6) ) )' ' ' 7 7 7 7(( ( (2 2 2 2	 	 	 	       : : : :   
  
6   ?.   (   ?   ?*        ?&! ! ! 	 	 	   $    % % <%   ?6 ! ! ?!F( ( (   ?$   ?   ?*   ?"   9	 	 	   9   9   9   9   :   9   9 O O 9O " " 9"   9 * * 9* I I 9I K K 9K4   :
 * * 9*   9 G G 9G"   9   :   :   :
   : < < :< 9 9 :9  2' ' 'R     : A A :A  ? ? :?   :   :   : 
? 
? :
? : : ::% % % %   :     :  ? ? :?
 > > :> : : :: @ @ :@ 
; 
; :
;   :   <A A AA A AA A AA A AA A AA A AA A AA A AA A AA A AA A AA A AA A AA A AA A AA A AA A AC C CA A AA A AA A AA A AA A AI I IA A AI I I   " " <" D3 D3 <D3L   <   <   : D D :D   :	L 	L 	L 	# 	# 	# 	# 	# 	# 	#r(   rL   c                       e Zd ZdZdS )AnnotationErrorz5An exception for when we failed to annotate the tree.N)r  r  r  r  r+   r(   r"   r  r    s        ====r(   r  c                        e Zd Z fdZ fdZd Zed             Zed             Zed             Z	ed             Z
ed             Zd	 Zd
 Zd Zd ZddZd Zd Zd Z	 ddZd ZddZddZd Z xZS )AstAnnotatorc                     t          t          |                                            t          j        |          | _        d S r*   )rU   r  rR   r
   TokenGeneratortokens)r   sourcerX   s     r"   rR   zAstAnnotator.__init__  s5    	,&&(((!088DKKKr(   c                 .   	 t          j        |d| j                   t          j        |d| j                   t	          t
          |                               |           d S # t          t          t          t          f$ r}t          |          d }~ww xY w)NrI   rd   )rE   r   r   rO   rU   r  rV   	TypeError
ValueError
IndexErrorKeyErrorr  )r   r   erX   s      r"   rV   zAstAnnotator.visit  s    	gdHdl+++	gdM4#4555L$%%d+++++z:x8   As   AA# #B BBc              #   h  K   t          ||          }| j        j        }| j                                        j        }|d         |d         k    r | j        }d| _        |D ]}|V  || _        dS | j        }| j        }	| j                            d           }
|
j        }t          ||          }|s&d}t          d|d         z  t          j                   || _        || _        |D ]}|V  t          j        |d|z  | j                            | j                             || _        |	| _        dS )zCGenerator which annotates child nodes with their indentation level.r   Nc                 6    | j         t          j        j        k    S r*   )r  r
   TOKENSINDENT)ts    r"   r]   z'AstAnnotator.indented.<locals>.<lambda>  s    !&O299 r(   z    zbIndent detection failed (line %d); inner indentation level is not more than the outer indentation.)filere   )rD   r  _locpeek_non_whitespacestartrO   r   peek_conditionalsrc_get_indent_diffrt  r  stderrrE   r   block_whitespace)r   r   rf   rg   cur_locnext_locrd   rk   rh   ri   indent_token
new_indentrj   s                r"   rl   zAstAnnotator.indented  s{     t]++HkG{..006H qzXa[  %kd  %%df,K( ;//99; ;L!JZ88H Nh /18<BE*N N N N DL D  kkkkGD#m3K((668 8 8 DL(Dr(   c           	          t           j        j         fdg} j                                        j        dk    r|                    dd                                |d|dt          |j	                             dS )z1Annotate a Num node with the exact number format.c                  B     j                                       j        S r*   )r  next_of_typer  )r   token_number_types   r"   r]   z(AstAnnotator.visit_Num.<locals>.<lambda>  s    4;334EFFJ r(   -r   rO  )r  r   N)
r
   r  NUMBERr  peekr  insertr_   r  r  )r   r   contentargsr  s   `  @r"   	visit_NumzAstAnnotator.visit_Num  s     (.5JJJJJKK{$$C   IIdI{TVIMMMMMr(   c                 Z    |                      |d| j        j        gd|j                   dS )z1Annotate a Str node with the exact string format.rO  sr   Nr_   r  r  r  r   s     r"   	visit_StrzAstAnnotator.visit_Str  /     	IIdI0vtvINNNNNr(   c                 P    | j                                                     }dd |j        D             }	 t          |          \  }}|z  |n8| j         }|| _         |                     t          |                     || _         R|                     |dfdg           dS )z<Annotate a JoinedStr node with the fstr formatting metadata.r   c              3   N   K   | ] }t          |t          j                  |V  !d S r*   )r   r   FormattedValue)r  vs     r"   	<genexpr>z/AstAnnotator.visit_JoinedStr.<locals>.<genexpr>&  s4      JJA
1c6H(I(IJaJJJJJJr(   TNrO  c                       S r*   r+   )ress   r"   r]   z.AstAnnotator.visit_JoinedStr.<locals>.<lambda>1  s     r(   r   )r  fstrrx  nextrV   r_   )r   r   	fstr_iterrx  res_parttgprev_tokensr  s          @r"   visit_JoinedStrzAstAnnotator.visit_JoinedStr!  s     #  ""$$I
CJJJJJF )__lh	Xoc	Kkdk
jjfdk  	IIdI}cI:::::r(   c                 Z    |                      |d| j        j        gd|j                   dS )z3Annotate a Bytes node with the exact string format.rO  r  r   Nr  r   s     r"   visit_ByteszAstAnnotator.visit_Bytes3  r  r(   c                     | j                                         j        dk    r|                     d           d S t	          d          D ]}|                     d           d S )Nr  r  r   )r  r  r  rx   r  )r   r   r   s      r"   r  zAstAnnotator.visit_Ellipsis8  sh     {&&
jjQxx  !

3 r(   c                 ~    | j                                         }t          |t          j                  o
|j        dk    S )z7Return True iff the If node is an `elif` in the source.r   )r  	next_namer   r   r   r  )r   r   next_toks      r"   r   zAstAnnotator.check_is_elifB  s3    {$$&&HdCF##>(>>r(   c                 z    t          |t          j                  o!| j                                        j        dk    S )zFReturn True iff the TryExcept node is a continued `try` in the source.r   )r   r   	TryExceptr  r  r  r   s     r"   r   z#AstAnnotator.check_is_continued_tryG  s4    tS]++ ;K++--1U:<r(   c                 z    t          |t          j                  o!| j                                        j        dk    S )zBReturn True iff the With node is a continued `with` in the source.r   )r   r   Withr  r  r  r   s     r"   r   z$AstAnnotator.check_is_continued_withL  s/    dCH%%G$+*:*:*<*<*@C*GGr(   c                 B    | j                                         j        dvS )r  z],)r  r  r  r   s     r"   r  z&AstAnnotator.check_slice_includes_stepP  s     
 ;**,,0<<r(   NFTc                    | j                                         }|r|r|j        dk    r| j                                         |                     d          z   }| j                                         }|j        t          j        j        t          j        j	        fv r|| j                             d          z  }|S | j                             ||          S )z;Parse some whitespace from the source tokens and return it.;r9   r   )r   r   )
r  r  r  
whitespacerx   r  r
   r  NLNEWLINE)r   r   r   r   
next_tokenresults         r"   r\   zAstAnnotator.wsW  s    !!##J Z JNc$9$9{%%''$**S//9f;##%%j	_36,3;= 
= 
=$+((1(555m;!!Iw!GGGr(   c                       fd}|S )zParse a number of dots.c                  8    j                                        S r*   )r  r   )r   r   s   r"   _parse_dotsz&AstAnnotator.dots.<locals>._parse_dotse  s    [h'''r(   r+   )r   r   r  s   `` r"   r   zAstAnnotator.dotsc  s(    ( ( ( ( ( (r(   c                 b    t          j        |d| j                            |                     d S )Nr   )rE   r   r  r  )r   r   indent_levels      r"   r>   zAstAnnotator.block_suffixi  s,    GD(DK88FFGGGGGr(   c                 8   | j                                         }|j        |k    r+t          d||j        |j        d         |j        fz            |j        dv r| j                                          n"|j        dv r| j                                          |j        S )z2Parse a single token with exactly the given value.z$Expected %r but found %r
line %d: %sr   z({[z)}])r  r  r  r  r  line	hint_openhint_closed)r   rw   rx   s      r"   rx   zAstAnnotator.tokenl  s    KEyIC
UYA
G< < = = = yE
k	e		
k9r(   c                    ~t          j        ||d           |r| j                                        n| j                                        }|rr|j        |k    rid}|r||                                 z  }t          j        |||| j                                        j        z   |                                 z              dS dS dS )z/Try to parse a token and attach it to the node.r   N)rE   rT   r  r  r  r  r\   r  )r   r   r{   rw   r  r   rx   parseds           r"   r   zAstAnnotator.optional_token{  s     	JtY###'@T[,,...-1[-=-=-?-? 
 Hi''f	  $''))	jy!DK$4$4$6$6$::TWWYYFH H H H H	H H''r(   c                       fd}|S )r   c                      j                                         t          fdD             d           } | t          ddj                  | S )Nc              3   2   K   | ]}|j         k    |V  d S r*   )r  )r  r  r  s     r"   r  zGAstAnnotator.one_of_symbols.<locals>._one_of_symbols.<locals>.<genexpr>  s/      >>!!z~*=*=A*=*=*=*=>>r(   zExpected one of: z, but found: )r  r  r  r  )foundr  r   r   s    @r"   _one_of_symbolsz4AstAnnotator.one_of_symbols.<locals>._one_of_symbols  sl    ;##%%j>>>>w>>>EEe	o4;GGZ^^LN N 	Nlr(   r+   )r   r   r  s   `` r"   r   zAstAnnotator.one_of_symbols  s*          r(   c           
         ~|r-|D ]*}t          j        ||dz   t          ||d                     +g }|D ]b}t          |t          j                  r)|                    |                     |                     E|                     |                       ct          j        ||d                    |                     dS )a7  Parses some source and sets an attribute on the given node.

    Stores some arbitrary formatting information on the node. This takes a list
    attr_vals which tell what parts of the source to parse. The result of each
    function is concatenated onto the formatting data, and strings in this list
    are a shorthand to look for an exactly matching token.

    For example:
      self.attr(node, 'foo', ['(', self.ws, 'Hello, world!', self.ws, ')'],
                deps=('s',), default=node.s)

    is a rudimentary way to parse a parenthesized string. After running this,
    the matching source code for this node will be stored in its formatting
    dict under the key 'foo'. The result might be `(
  'Hello, world!'
)`.

    This also keeps track of the current value of each of the dependencies.
    In the above example, we would have looked for the string 'Hello, world!'
    because that's the value of node.s, however, when we print this back, we
    want to know if the value of node.s has changed since this time. If any of
    the dependent values has changed, the default would be used instead.

    Arguments:
      node: (ast.AST) An AST node to attach formatting information to.
      attr_name: (string) Name to store the formatting information under.
      attr_vals: (list of functions/strings) Each item is either a function
        that parses some source and return a string OR a string to match
        exactly (as a token).
      deps: (optional, set of strings) Attributes of the node which attr_vals
        depends on.
      default: (string) Unused here.
    __srcNr   )	rE   r   rD   r   sixstring_typesrT   rx   join)	r   r   r{   r|   r}   r   dep
attr_partsattr_vals	            r"   r_   zAstAnnotator.attr  s    @ 	 ? ? ?#cGmWT3%=%=>>>>J & &	Hc.	/	/ &$**X..////((**%%%%GD)RWWZ0011111r(   c                 >    ~| j                             |||          S )aK  Return a context manager to handle a parenthesized scope.

    Arguments:
      node: (ast.AST) Node to store the scope prefix and suffix on.
      attr: (string, optional) Attribute of the node contained in the scope, if
        any. For example, as `None`, the scope would wrap the entire node, but
        as 'bases', the scope might wrap only the bases of a class.
      trailing_comma: (boolean) If True, allow a trailing comma at the end.
      default_parens: (boolean) If True and no formatting information is
        present, the scope would be assumed to be parenthesized.
    )r_   r   )r  r   rt   s        r"   r   zAstAnnotator.scope  s$     	;T^LLLr(   c                     | j                                         }|r|j        |k    s|j        |k    rdS | j                                          |j        |                                 z   S )Nr   )r  r  r  r  r  r\   )r   
token_typerw   rx   s       r"   _optional_tokenzAstAnnotator._optional_token  sc    KE #EJ*,,	Y0F0FR
kY""r(   r  )FFr  r  )r  r  r  rR   rV   rl   r/   r  r  r  r  r5   r  r   r   r   r  r\   r   r>   rx   r   r   r_   r   r  r  r  s   @r"   r  r    s       9 9 9 9 9    ') ') ')R N N :N O O :O ; ; :;" O O :O   <? ? ?
< < <
H H H= = =
H 
H 
H 
H  H H H    =BH H H H	 	 	*2 *2 *2 *2XM M M M# # # # # # #r(   r  c                 N    d}| D ]}|dk    r|dz  }|dk    r|d|dz  z
  z  } |S Nr   r   r9   	   r+   )rI   widthcs      r"   _get_indent_widthr    sK    
%  aCxxqjee	
dqEAIe	,r(   c                     d}t          |           D ]U\  }}||k    r nI|dk    r|dz  }|dk    r6|dz   |dz  z
  |k    r|d|dz  z
  z  }:d|dz   |z
  z  | |dz   d          z   c S V| |d          S r  )r   )rI   remove_widthr  r   r  s        r"   _ltrim_indentr    s    
% 	A 	AdaeCxxqjee	
d	eai	 L	0	0eai eai,./&Q.@@@@	 

 
r(   c                 ~    t          |           }t          |          }||z
  }|dk    rdS t          |||z
            S )aK  Computes the whitespace added to an indented block.

  Finds the portion of an indent prefix that is added onto the outer indent. In
  most cases, the inner indent starts with the outer indent, but this is not
  necessarily true. For example, the outer block could be indented to four
  spaces and its body indented with one tab (effectively 8 spaces).

  Arguments:
    outer: (string) Indentation of the outer block.
    inner: (string) Indentation of the inner block.
  Returns:
    The string whitespace which is added to the indentation level when moving
    from outer to inner.
  r   N)r  r  )outerinnerouter_winner_wdiff_ws        r"   r  r    sK     e$$'e$$'W&q[[4	ug.	/	//r(   )TTTNFFF)&r  
__future__r   r   r   r  r   r%   r  	itertoolsr  	six.movesr   r  
pasta.baser   r   r	   rE   r
   r'   r  r   r/   r2   r5   r7   r!   r;   rJ   NodeVisitorrL   	Exceptionr  r  r  r  r  r+   r(   r"   <module>r%     sT   H H ' & & & & &       % % % % % % 



 



             



       



 $ $ $ $ $ $             ( ( ( ( ( ( & & & & & & LP;@      - - -
& & &
& & &
4 4 4
4 4 44 4 4
  *f# f# f# f# f##/ f# f# f#R#> > > > >i > > >y# y# y# y# y#; y# y# y#x    0 0 0 0 0r(   