Skip to main content

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

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

ASTFormatter-0.6.1.tar.gz (6.9 kB view details)

Uploaded Source

File details

Details for the file ASTFormatter-0.6.1.tar.gz.

File metadata

File hashes

Hashes for ASTFormatter-0.6.1.tar.gz
Algorithm Hash digest
SHA256 fe91e9fd8b7dd9d9353381bd6e1aa2b5399840477c96e3b95cc664ec824e8021
MD5 503515c8e1d0945d12a4934fbe39e2b6
BLAKE2b-256 0cd930aadb1c5efa4f3404eed9b7b15d6824636204b37742cad450168eb2e49a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page