
    `iU                     @   d 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m	Z	 ddl
mZmZmZmZ dZej        d         dk    fdZed	d	d	d	fd
Zd Zedk    rddlZej        dd         Zdev Zere                    d           es ej                            ej                  gZ ee          dk    r ed           e\  Zd	Zej                             e          sedk    p edez            Z ej!        dej"                    eeepee           dS dS )zr
Part of the astor library for Python AST manipulation.

License: 3-clause BSD

Copyright (c) 2015 Patrick Maupin
    N)	to_source)code_to_ast)allow_ast_comparison	dump_tree
strip_treefast_compare	tmp_rtrip   c                 4    |r| n|                      d          S )Nzutf-8)encode)spre_encodeds     _/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/astor/rtrip.pyout_prepr      s    211'!2!22    Fc                    |rt                       t          j        }t          j        }t          j                            |           } |s_t          j                            |          }t          j        d           t          j        d|z              t          j
        |d           t                      }t                      }	t                      }
g }d} || |rdn|          }|D ]\  }}|s|||k    rv|}|| k    rA|                    | |d          }|                    |          st          |d|          n|                     |          sJ |}t	          j        |           t          j                            ||          }t          j        d|z             	  ||          }n%# t"          $ r |
                    |           Y w xY w	 t'          |          }n# t(          $ r |s d}Y nw xY w|st          j                            ||          }	 t+          |d          5 }|                    t/          |                     ddd           n# 1 swxY w Y   n%# t0          $ r |
                    |           Y nw xY w	 |rt3          j        |          n
 ||          }n# t"          $ r g }Y nw xY w|rK|                    t9          |                     |	                    t9          |                     ||k    }nt;          ||           }|s|rt=          |          }t=          |          }t          j        d	|rd
ndz             |r|                     |           |s|r3|s	 t+          |dd         dz   d          5 }|                    t/          |                     ddd           n# 1 swxY w Y   n0# t0          $ r# |
                    |dd         dz              Y nw xY w	 t+          |dd         dz   d          5 }|                    t/          |                     ddd           n# 1 swxY w Y   u# t0          $ r$ |
                    |dd         dz              Y w xY w|rtB          j"                            d           tB          j"                            |                    dd                     tB          j"                            d           tB          j"                            |                    dd                     tB          j"                            d           tB          j"                            ||k    rdn|                    dd                     tB          j"                            d           |
r=t          j        d           tG          |
          D ]}t          j        d|z             |r0t          j        d           |D ]}t          j        d|z             d}t          |$                                          }|	|z  |z
  }|rt          j%        d|z             t          j        d           |S )zNWalk the srctree, and convert/copy all python files
    into the dsttree

     z	Trashing TN   z not a subdirectory of zConverting %swbz    calculating dump -- %sbadOKz.srcdmpz.dstdmpz

AST:

    
z
    z

Decompile:

    z

New AST:

    z(same as old)z*
Files not processed due to syntax errors:z    %sz#
Files failed to round-trip to AST:z3col_offset _precedence _use_parens lineno _p_op _ppz$
ERROR -- UNKNOWN NODES STRIPPED: %s)&r   r   
parse_filefind_py_filesospathnormpathlogginginfoshutilrmtreesetreplace
startswith
ValueErrormakedirsjoinSyntaxErroraddr   	Exceptionopenwriter   UnicodeEncodeErrorastparseupdater   r   r   warningappendsysstdoutsortedspliterror)srctreedsttreereadonlydumpallignore_exceptionsfullcompr   r   unknown_src_nodesunknown_dst_nodesbadfilesbrokenoldpathallfilessrcpathfnamedstpathsrcfnamesrcastdsttxtdstfnamefdstastr   srcdumpdstdumpok_to_strip	bad_nodess                               r   convertrR       s     'J-Mgw''G %'""7++R[7*+++gt$$$uuHFG}Wh&CddGDDH" L+ L+ 
	!Gw..G'!!!//'7A>>))'22 9$&-ggww&8 9 9 99 ))'22222!K   7<<//_x/000	Z))FF 	 	 	LL"""H		v&&FF 	 	 	$ FFF	
  	'w||GU33H'(D)) .QGGHV,,---. . . . . . . . . . . . . . .% ' ' 'X&&&&&'
	*2LSYv&&&

88L8LFF 	 	 	FFF	 	3$$Z%7%7888$$Z%7%7888F"CC"66222C 	+c 	+''G''GO8&)3UUt5 6 6 6 (h''' +# + +@!(3B3-)";TBB 7aGGHW$5$56667 7 7 7 7 7 7 7 7 7 7 7 7 7 7- @ @ @ Xcrc]Y%>?????@@!(3B3-)";TBB 7aGGHW$5$56667 7 7 7 7 7 7 7 7 7 7 7 7 7 7- @ @ @ Xcrc]Y%>?????@ +J$$%7888J$$W__T8%D%DEEEJ$$%=>>>J$$V^^D(%C%CDDDJ$$%;<<<J$$78J8J__*1//$*I*IK K KJ$$T*** .EFFFH%% 	. 	.EOHu,---- 1>??? 	1 	1HOHx/0000GKk''))**K"%66+EI K=	IJJJLMs   %F11GGG''G98G9I*/#II*I"	"I*%I"	&I**JJ!J22K K O#O
>O
O	OO	O*PPQ"#QQQ	QQ	Q*RRc                 J    t          t          j        d          | z            )Na  

        Error: %s

        Usage:

            python -m astor.rtrip [readonly] [<source>]


        This utility tests round-tripping of Python source to AST
        and back to source.

        If readonly is specified, then the source will be tested,
        but no files will be written.

        if the source is specified to be "stdin" (without quotes)
        then any source entered at the command line will be compiled
        into an AST, converted back to text, and then compiled to
        an AST again, and the results will be displayed to stdout.

        If neither readonly nor stdin is specified, then rtrip
        will create a mirror directory named tmp_rtrip and will
        recursively round-trip all the Python source from the source
        into the tmp_rtrip dir, after compiling it and then reconstituting
        it through code_gen.to_source.

        If the source is not specified, the entire Python library will be used.

        )
SystemExittextwrapdedent)msgs    r   usagerX      s1    
X_ &  8 9   r   __main__r   r;   zToo many argumentsstdinzCannot find directory %sz%(msg)s)formatlevel)r;   r<   )#__doc__r4   r   r/   r!   r   astor.code_genr   astor.file_utilr   astor.node_utilr   r   r   r   r:   version_infor   rR   rX   __name__rU   argvargsr;   remover   dirname__file__lenrF   r<   existsbasicConfigINFO r   r   <module>rm      s    


 				 



   $ $ $ $ $ $ ' ' ' ' ' '7 7 7 7 7 7 7 7 7 7 7 7 
 !-a0A5 3 3 3 3 %ue#ey y y yx  @ zOOO8ABB<DT!H  J 4 1223
s4yy1}}"###FEG7>>%   P7"Oee,F,N&O&OGy====GEH/AAAAAA+ r   