Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyastest

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.

Quick Start

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!

Documentation

Options

Only one option must be specified.

Diff

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

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

About

a command line tool to parse, modify, and compare Python Abstract Syntax Trees

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.