human-oriented ast parser/unparser
Project description
Attempt at a human-oriented abstract syntax tree (AST) parser/unparser for Python 3.
This package provides new AST node types which inherit from nodes in typed_ast.ast3 module. Additionally, it provides implementation of parser and unparser for the extended ASTs.
Simple example of how to use this package:
from horast import parse, unparse
tree = parse("""a = 1 # a equals one after this""")
print(unparse())
# this will print the code with original comment
More examples in examples.ipynb.
Parser is based on built-in tokenize module and typed_ast.ast3.parse() function.
Unparser is essentially an extension of Unparser class from typed_astunparse package.
Nodes provided and handled by horast are listed below.
Comment
Full line as well as end-of-line comments are parsed/unparsed correctly when they are outside of multi-line expressions.
Currently, handling of comments within multi-line expressions is implemented only partially.
Docstring
To do.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for horast-0.2.0.dev1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f75269867cd1e3487c23d9049e7163df84c45780d068b50e39c1a7b36a21ad3 |
|
MD5 | e2832e8d832a731c946b7660a1ec0d23 |
|
BLAKE2b-256 | d7ae8d943bca8db3e00d789c492a6bbabe169945ac5a26f33662c2beb4b29dd0 |