Skip to content

The ASTFormatter class accepts an AST tree and returns a valid source code representation of that tree.

License

Notifications You must be signed in to change notification settings

tilezen/python-astformatter

 
 

Repository files navigation

ASTFormatter

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

Latest Changes

version 0.6.2
Add missing newlines for two uses of raise

Copyright

Copyright © 2015-2016 by Johnson Earls. Some rights reserved. See the license for details.

About

The ASTFormatter class accepts an AST tree and returns a valid source code representation of that tree.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 64.9%
  • Gherkin 35.1%