Giter Site home page Giter Site logo

jwiaduck / pyastest Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 30 KB

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

License: MIT License

Python 100.00%
python python-ast abstract-syntax-tree ast-comparison ast-diff-tool ast ast-py

pyastest's Introduction

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

pyastest's People

Contributors

jwiaduck avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

pyastest's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.