
    ?d                     J    d Z ddlZddlZddlZddlZ G d de      Zd Zd Zy)zVerify that the generated code is valid code.

This takes a line of code and "normalizes" it. I.e., it transforms the snippet
into something that has the potential to compile.

    VerifyCode(): the main function exported by this module.
    Nc                       e Zd ZdZy)InternalErrorz+Internal error in verifying formatted code.N)__name__
__module____qualname____doc__     7/usr/lib/python3/dist-packages/yapf/yapflib/verifier.pyr   r      s    3r
   r   c                    	 t        t        j                  |       j                  d      dd       y# t        $ r 	 t        j                  t        j                  | j                  d            j                         dd       Y y# t        $ rZ 	 t        |       }t        |j                  d      dd       n-# t        $ r! t        t        j                         d         w xY wY Y yw xY ww xY w)zVerify that the reformatted code is syntactically correct.

  Arguments:
    code: (unicode) The reformatted code snippet.

  Raises:
    SyntaxError if the code was reformatted incorrectly.
  zUTF-8<string>exec
   N)compiletextwrapdedentencodeSyntaxErrorastparselstrip_NormalizeCoder   sysexc_info)codenormalized_codes     r   
VerifyCoder   !   s    
/HOOD!((1:vF	 //	iiD 1299;ZP //(.&&w/VD /CLLN1-../ 	E//s?   /2 	C,AB	C('B76C(7*C!!C($C,'C((C,c                    t        j                  | j                  d            j                         } | j                  d      }d}t	        |      D ]+  \  }}|j                         }|s|j                  d      r+ n dj                  ||d       dz   } t        j                  d|       r
| dz  } | dz   S t        j                  d|       rW	 d| z   dz   }t        j                  t        j                  |j                  d            j                         d	d
       |} | dz   S | j                  d      r
| dz  } | dz   S t        j                  d|       r
| dz  } | dz   S t        j                  d|       rd| z   dz   } | dz   S t        j                  d|       r
d| z   } | dz   S t        j                  d|       r
d| z   } | dz   S t        j                  d|       rd| z   } | dz   S # t        $ r d| z   } Y | dz   S w xY w)z.Make sure that the code snippet is compilable.r   r   #Nz+(if|while|for|with|def|class|async|await)\bz	
    passz(elif|else)\bzif True:
    pass
r   r   zif True: pass
@z
def _():
    passztry\bz
    pass
except:
    passz(except|finally)\bztry:
    pass
z(return|yield)\bzdef _():
    z(continue|break)\bzwhile True:
    zprint\bz&from __future__ import print_function
)r   r   r   split	enumeratestrip
startswithjoinrematchr   r   r   )r   linesilinetry_codes        r   r   r   7   s!   	T*	+	2	2	4$ **T
%!5! ga::<DDOOC( 
59		$$XX<dCLD. 
- 
xx $'&'$.=h	ii
//(//$/
0
7
7
9:vOd" 
 s""D 
 
xx$++D 
 
xx%t,$|3D 
 
xx#T*d"D 
 
xx%t,%D 
 
xx
D!4t;D	!  &%d 
!&s   AG! !G65G6)	r   r   r'   r   r   	Exceptionr   r   r   r	   r
   r   <module>r.      s.     	 
 I 
/,&r
   