Skip to content

Latest commit

 

History

History
34 lines (21 loc) · 940 Bytes

README.rst

File metadata and controls

34 lines (21 loc) · 940 Bytes

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

Copyright

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