a command line tool to parse, modify, and compare Python ASTs
sort of providing an interface to ast.py. initially to provide some better scripting capabilities, but it might evolve into a suite of tools.
Note: Developed with Python 3.9.10!
Note: Rudimentally tested. Proceed with caution!
Currently, only Abstract Syntax Tree equality check between two files is supported.
$ git clone <this repo>
$ cd pyastest
$ python3 pyastest.py diff <path/to/file1> <path/to/file2>
Starting...
...
True: ASTs are equal!
Finished!
Only one option must be specified.
diff
command, followed by the files to be diffed, path/to/ORIGINAL.py
and path/to/CHANGED.py
diff
will read in and generate an AST for each file, then do an equality check on the two ASTs.
Ex: $ python3 pyastest.py diff ~/dev/source.py ~/dev/source_changed.py
info
command, followed by one file to be analyzed, path/to/SOURCE.py
info
will read in and generate an AST for the given file, then visit the AST to gather info on the nodes.
prints a summary of node type information.
Ex: $ python3 pyastest.py info ~/dev/source.py
The output is currently long (flags to come). Pipe to a txt file:
$ python3 pyastest.py info ~/dev/source.py > output