
    Vh                    P    d Z ddlmZ ddlZdZdZd Zd Zd Ze	d	k(  r e        yy)
z0Python syntax checker with lint friendly output.    )annotationsNzutf-8replacec                     t         j                  dd xs, t         j                  j                         j	                         D ]  } t        |         y)zMain program entry point.   N)sysargvstdinread
splitlinescompile_source)paths    `/home/dcms/DCMS/lib/python3.12/site-packages/ansible_test/_util/target/sanity/compile/compile.pymainr   
   s<    =		 0 ; ; = t    c                   t        | d      5 }|j                         }ddd       	 t        | dd       y# 1 sw Y   xY w# t        $ r<}t	        |      |j
                  |j                  |j                  f\  }}}}Y d}~n6d}~wt        $ r'}t	        |      t        |      ddf\  }}}}Y d}~nd}~ww xY wd| |||j                  t        |      fz  }t        |       y)zCCompile the specified source file, printing an error if one occurs.rbNexecT)dont_inheritr   z%s:%d:%d: %s: %s)openr
   compileSyntaxErrortypetextlinenooffsetBaseExceptionstr__name__safe_messageprint)	r   	source_fdsourceexextypemessager   r   results	            r   r   r      s    	dD	 "Y!"f48 	" "
  R*.r(BGGRYY		*Q' B*.r(CGQ*A'B
  4,W^J_"``F	&Ms,   7A A 	B62BB6B11B6c                    t        | t              r| j                  t        t              } | j                  t        t              } | j                         j                         d   j                         } | S )zxGiven an input value as str or bytes, return the first non-empty line as str, ensuring it can be round-tripped as UTF-8.r   )
isinstancer   encodeENCODINGERRORSdecodestripr   )values    r   r   r   #   sS    %Xv.LL6*EKKM$$&q)//1ELr   __main__)
__doc__
__future__r   r   r*   r+   r   r   r   r    r   r   <module>r3      s;    6 " 
	& zF r   