Ad

astor: Python AST manipulation

astor facilitates easy Python AST modification and round-tripping. It allows users to manipulate Python source code by working directly with its Abstract Syntax Tree (AST).

astor enables developers to easily manipulate Python source code by leveraging the Abstract Syntax Tree (AST) representation. The project focuses on providing tools for reading, writing, and transforming Python code through its AST. It addresses challenges associated with code analysis, manipulation, and regeneration, especially in scenarios involving code refactoring or automated code generation. astor uses Python's built-in ast module to provide a flexible and accessible way to work with the AST.

astor excels in enabling round-tripping of ASTs back to Python code, even when the AST lacks standard attributes. It provides a convenient way to pretty-print ASTs for deeper code understanding. The library offers non-recursive tree traversal, allowing for fine-grained control over node visitation and manipulation, making it suitable for complex code transformations.

  • Round-trip AST: Converts modified ASTs back to Python code with options for code formatting and preservation of original structure.
  • AST Pretty-printing: Generates readable, formatted representations of the AST for detailed analysis.
  • Non-recursive Traversal: Offers flexible traversal options, allowing customization of node visitation behavior.
  • Tree Access: Provides easy access to parent nodes and allows for function execution during tree traversal.
  • Code Transformation: Enables programmatic modification of Python code by manipulating the AST directly.
  • Integration with Tools: Facilitates the development of tools for code analysis, refactoring, and generation.
  • Extensible: Provides hooks for extending the traversal process and implementing custom node handling.

astor is an active project with ongoing development and maintenance. It has a significant number of stars and forks, suggesting community interest and usage. Recent commit activity indicates continued development. The project has comprehensive documentation and a stable release history, indicating a reliable and well-supported tool.

astor is beneficial for developers needing fine-grained control over Python code manipulation, such as those working on code analysis tools, automated refactoring, or code generation. It provides a powerful alternative to regular expression-based code parsing, offering a more robust and flexible approach. astor simplifies tasks like performing complex code transformations and understanding code structure at a deeper level.

Languages:
Summarize:
Share:
Stars
865
Forks
104
Issues
20
Created
13 years ago
Commit
6 months ago
License
BSD-3-CLAUSE
Archived
No
Updated 1 month ago

Similar Repositories