
    A                     r    S r SSKrSSKrSSKrSSKrSSKJrJr  SSKJ	r	  SSK
Jr  S r\S:X  a  \" 5         gg)	aD  
This script recursively converts hcl2 files to json

Usage:
    hcl2tojson [-s] PATH [OUT_PATH]

Options:
    -s          Skip un-parsable files
    PATH        The path to convert
    OUT_PATH    The path to write files to
    --with-meta If set add meta parameters to the output_json like __start_line__ and __end_line__
    N)UnexpectedCharactersUnexpectedToken   )load)__version__c            	      	   [         R                  " SS9n U R                  SSSSS9  U R                  SS	S
9  U R                  SSSS9  U R                  SS[        S9  U R                  SSSS9  U R	                  5       n[
        [        [        4n[        R                  R                  UR                  5      (       a  [        UR                  SSS9 nUR                  c  [        R                  O[        UR                  SSS9n[!        UR                  [        R"                  SS9  [$        R&                  " [)        X1R*                  S9U5        UR                  c!  UR-                  S5        UR/                  5         SSS5        g[        R                  R1                  UR                  5      (       Gae  [3        5       nUR                  c  [5        S5      e[        R                  R7                  UR                  5      (       d   [        R8                  " UR                  5        [        R:                  " UR                  5       GH  u  pgn[        R                  R=                  UR                  U/5      n	[        R                  R?                  Xi5      n
[        R                  RA                  [        R                  RC                  UR                  U
5      5      n[        R                  R7                  U5      (       d  [        R8                  " U5        U H  n[        R                  RC                  Xl5      n[        R                  RC                  X5      n[        R                  RE                  U5      S   S -   nX;   d  X;   a  Mr  URG                  U5        URG                  U5        [        USSS9 n[!        U[        R"                  SS9   [)        U5      n[        USSS9 n[$        R&                  " X5        SSS5        SSS5        M     GM     g[5        S!UR                  5      e! , (       d  f       g= f! U a    URH                  (       a   SSS5        GMK  e f = f! , (       d  f       No= f! , (       d  f       GMq  = f)"z!The `console_scripts` entry pointz3This script recursively converts hcl2 files to json)descriptionz-sskip
store_truezSkip un-parsable files)destactionhelpPATHz The file or directory to convert)r   OUT_PATH?zwThe path where to write files to. Optional when parsing a single file. Output is printed to stdout if OUT_PATH is blank)nargsr   z	--versionversion)r   r   z--with-metazRIf set add meta parameters to the output_json like __start_line__ and __end_line__)r   r   rzutf-8)encodingNwT)fileflush)	with_meta
z0Positional OUT_PATH parameter shouldn't be emptyr   z.jsonzInvalid Path)%argparseArgumentParseradd_argumentr   
parse_argsr   r   UnicodeDecodeErrorospathisfiler   openr   sysstdoutprintstderrjsondumpr   r   writecloseisdirsetRuntimeErrorexistsmkdirwalk
commonpathrelpathnormpathjoinsplitextaddr
   )parserargsskippable_exceptionsin_fileout_fileprocessed_filescurrent_dir_files
dir_prefixrelative_current_dircurrent_out_path	file_namein_file_pathout_file_pathparsed_datas                    lib/third_party/hcl2/__main__.pymainrI      s    $$IF 6,5M   %GH
;   I{K
a   D+-ACUV	ww~~dii  $))S73w ==( 

$--w? 
 $))#**D9IId7nn=xH}}$t$  43 
tyy	!	!%== QRRww~~dmm,,HHT]]#%'WWTYY%7!KE++TYY,DEJ#%77??;#K !ww//T]],@A  77>>"233)*"	!ww||KC "-= I " 0 0 ? BW L  2m6V##L1##M2,g>',SZZtD&*7m
 mS7Cx		+8 D ?> # &8> >49955c 43T 0 99$ ?>  DC ?>sU   B,P19Q;QQ;*Q*	Q;1
P?Q'	Q;%Q'	'Q;*
Q84Q;;
R__main__)__doc__r   r(   r    r$   larkr   r    r   r   r   rI   __name__     rH   <module>rQ      s<      	 
 6   M6` zF rP   