The ASTFormatter class accepts an AST tree and returns a valid source code representation of that tree.
Project description
The ASTFormatter class accepts an AST tree and returns a valid source code representation of that tree.
Example Usage
from astformatter import ASTFormatter import ast tree = ast.parse(open('modulefile.py'), 'modulefile.py', mode='exec') src = ASTFormatter().format(tree, mode='exec')
Bugs
Currently, indentation is fixed at 4 spaces.
Too many methods are exposed that shouldn’t be, in order to properly subclass ast.NodeVisitor.
Need to make the statement visitor methods consistent about returning a list of strings; most still just return a string.
Code modified to work with 3.x needs cleanup
Copyright
Copyright © 2015 by Johnson Earls. Some rights reserved. See the license for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ASTFormatter-0.6.1.tar.gz
.
File metadata
- Download URL: ASTFormatter-0.6.1.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe91e9fd8b7dd9d9353381bd6e1aa2b5399840477c96e3b95cc664ec824e8021 |
|
MD5 | 503515c8e1d0945d12a4934fbe39e2b6 |
|
BLAKE2b-256 | 0cd930aadb1c5efa4f3404eed9b7b15d6824636204b37742cad450168eb2e49a |