RedBaron
tbpatch
RedBaron | tbpatch | |
---|---|---|
2 | 1 | |
686 | 0 | |
0.7% | - | |
0.0 | 0.0 | |
over 2 years ago | almost 3 years ago | |
Python | Rust | |
GNU Lesser General Public License v3.0 or later | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
RedBaron
-
Show HN: Codemodder – A new codemod library for Java and Python
https://github.com/PyCQA/redbaron
E.g. PyCQA/bandit does static analysis for security issues in Python code:
- Our Engineering Team Used Python's AST to Patch 100,000s of Lines of Code
tbpatch
-
Our Engineering Team Used Python's AST to Patch 100,000s of Lines of Code
I had a problem of applying patches to the files that got indented differently meantime.
So I wrote a tool that takes a context diff, rebuilds the before and after text, then parses both as vectors of (leading whitespaces, token), then creates a diff of those vectors ignoring the whitespaces, parses the target file as a similar vector, and applies this diff to such a vector (again with ignoring/copying whitespaces) - after which it reconstructs the text.
The results are surprisingly robust, despite the relatively naive tokenization heuristic.
https://github.com/ayourtch/tbpatch
What are some alternatives?
Rope - a python refactoring library
LibCST - A concrete syntax tree parser and serializer library for Python that preserves many aspects of Python's abstract syntax tree
Bowler - Safe code refactoring for modern Python.
pasta - Library to refactor python code through AST manipulation.
lib3to6 - Build universally compatible python packages from a substantial subset of Python 3.8.
pre-commit - A framework for managing and maintaining multi-language pre-commit hooks.