RedBaron is a Python library enabling easy and simple code modification. It allows writing custom and generic refactorings, tools, or directly manipulating source code within IPython with a higher-level abstraction than standard text editors. It relies on Baron, a tool providing losslessly convertible Abstract Syntax Trees (ASTs), guaranteeing code integrity during modification.
RedBaron offers a BeautifulSoup-inspired API, prioritising simplicity and intuitive usage. The public API is designed to be retro-compatible up to version 2.0. It provides a powerful abstraction for modifying source code, going beyond basic text manipulation in editors.
- Code Modification: Enables programmatic modification of Python source code.
- AST-Based: Leverages a reliable Abstract Syntax Tree (AST) for code manipulation.
- IPython Integration: Designed for use within IPython environments.
- API Simplicity: Offers a clean and intuitive API, inspired by BeautifulSoup.
- Retro-compatible API: Public API guaranteed to remain backward compatible.
- Lossless Transformation: Ensures code is transformed without altering semantics.
- Flexible Usage: Supports custom refactorings, tools, and direct code changes.
RedBaron is currently in alpha, with a stable core but limited battle testing. It’s considered a work in progress, benefiting from contributions to improve stability and quality. Documentation is available, and the public API is designed to remain compatible. Feedback is encouraged.
RedBaron benefits developers who need to automate code modifications, create code analysis tools, or build IDE extensions. It provides a safer and more powerful alternative to manual code editing, streamlining repetitive tasks and facilitating complex refactoring processes.
