============
AST Unparser
============
.. image:: https://badge.fury.io/py/astunparse.png
:target: http://badge.fury.io/py/astunparse
.. image:: https://travis-ci.org/simonpercivall/astunparse.png?branch=master
:target: https://travis-ci.org/simonpercivall/astunparse
.. image:: https://readthedocs.org/projects/astunparse/badge/
:target: https://astunparse.readthedocs.org/
An AST unparser for Python.
This is a factored out version of ``unparse`` found in the Python
source distribution; under Demo/parser in Python 2 and under Tools/parser
in Python 3.
Basic example::
import inspect
import ast
import astunparse
# get back the source code
astunparse.unparse(ast.parse(inspect.getsource(ast)))
# get a pretty-printed dump of the AST
astunparse.dump(ast.parse(inspect.getsource(ast)))
This library is single-source compatible with Python 2.6 through Python 3.5. It
is authored by the Python core developers; I have simply merged the Python 2.7
and the Python 3.5 source and test suites, and added a wrapper. This factoring
out is to provide a library implementation that supports both versions.
Added to this is a pretty-printing ``dump`` utility function.
The test suite both runs specific tests and also roundtrips much of the
standard library.
Extensions and Alternatives
---------------------------
Similar projects include:
* codegen_
* astor_
* astmonkey_
* astprint_
None of these roundtrip much of the standard library and fail several of the basic
tests in the ``test_unparse`` test suite.
This library uses mature and core maintained code instead of trying to patch
existing libraries. The ``unparse`` and the ``test_unparse`` modules
are under the PSF license.
Extensions include:
* typed-astunparse: extends astunparse to support type annotations.
* Documentation: http://astunparse.rtfd.org.
Features
--------
* unparses Python AST.
* pretty-prints AST.
.. _codegen: https://github.com/andreif/codegen
.. _astor: https://github.com/berkerpeksag/astor
.. _astmonkey: https://github.com/konradhalas/astmonkey
.. _astprint: https://github.com/Manticore/astprint
Changelog
=========
Here's the recent changes to AST Unparser.
1.6.3 - 2019-12-22
~~~~~~~~~~~~~~~~~~
* Add full support for Python 3.8
1.6.2 - 2019-01-19
~~~~~~~~~~~~~~~~~~
* Add support for the Constant node in Python 3.8
* Add tests to the sdist
1.6.1 - 2018-10-03
~~~~~~~~~~~~~~~~~~
* Fix the roundtripping of very complex f-strings.
1.6.0 - 2018-09-30
~~~~~~~~~~~~~~~~~~
* Python 3.7 compatibility
1.5.0 - 2017-02-05
~~~~~~~~~~~~~~~~~~
* Python 3.6 compatibility
* bugfix: correct argparser option type
1.4.0 - 2016-06-24
~~~~~~~~~~~~~~~~~~
* Support for the ``async`` keyword
* Support for unparsing "Interactive" and "Expression" nodes
1.3.0 - 2016-01-17
~~~~~~~~~~~~~~~~~~
* Python 3.5 compatibility
1.2.0 - 2014-04-03
~~~~~~~~~~~~~~~~~~
* Python 2.6 through 3.4 compatibility
* A new function ``dump`` is added to return a pretty-printed version
of the AST. It's also available when running ``python -m astunparse``
as the ``--dump`` argument.
1.1.0 - 2014-04-01
~~~~~~~~~~~~~~~~~~
* ``unparse`` will return the source code for an AST. It is pretty
feature-complete, and round-trips the stdlib, and is compatible with
Python 2.7 and Python 3.4.
Running ``python -m astunparse`` will print the round-tripped source
for any python files given as argument.
Raw data
{
"_id": null,
"home_page": "https://github.com/simonpercivall/astunparse",
"name": "astunparse",
"maintainer": "Simon Percivall",
"docs_url": null,
"requires_python": "",
"maintainer_email": "percivall@gmail.com",
"keywords": "astunparse",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/f3/af/4182184d3c338792894f34a62672919db7ca008c89abee9b564dd34d8029/astunparse-1.6.3.tar.gz",
"platform": "",
"description": "============\nAST Unparser\n============\n\n.. image:: https://badge.fury.io/py/astunparse.png\n :target: http://badge.fury.io/py/astunparse\n\n.. image:: https://travis-ci.org/simonpercivall/astunparse.png?branch=master\n :target: https://travis-ci.org/simonpercivall/astunparse\n\n.. image:: https://readthedocs.org/projects/astunparse/badge/\n :target: https://astunparse.readthedocs.org/\n\nAn AST unparser for Python.\n\nThis is a factored out version of ``unparse`` found in the Python\nsource distribution; under Demo/parser in Python 2 and under Tools/parser\nin Python 3.\n\nBasic example::\n\n import inspect\n import ast\n import astunparse\n\n # get back the source code\n astunparse.unparse(ast.parse(inspect.getsource(ast)))\n\n # get a pretty-printed dump of the AST\n astunparse.dump(ast.parse(inspect.getsource(ast)))\n\n\nThis library is single-source compatible with Python 2.6 through Python 3.5. It\nis authored by the Python core developers; I have simply merged the Python 2.7\nand the Python 3.5 source and test suites, and added a wrapper. This factoring\nout is to provide a library implementation that supports both versions.\n\nAdded to this is a pretty-printing ``dump`` utility function.\n\nThe test suite both runs specific tests and also roundtrips much of the\nstandard library.\n\nExtensions and Alternatives\n---------------------------\n\nSimilar projects include:\n\n * codegen_\n * astor_\n * astmonkey_\n * astprint_\n\nNone of these roundtrip much of the standard library and fail several of the basic\ntests in the ``test_unparse`` test suite.\n\nThis library uses mature and core maintained code instead of trying to patch\nexisting libraries. The ``unparse`` and the ``test_unparse`` modules\nare under the PSF license.\n\nExtensions include:\n\n * typed-astunparse: extends astunparse to support type annotations.\n\n* Documentation: http://astunparse.rtfd.org.\n\nFeatures\n--------\n\n* unparses Python AST.\n* pretty-prints AST.\n\n\n.. _codegen: https://github.com/andreif/codegen\n.. _astor: https://github.com/berkerpeksag/astor\n.. _astmonkey: https://github.com/konradhalas/astmonkey\n.. _astprint: https://github.com/Manticore/astprint\n\n\nChangelog\n=========\n\nHere's the recent changes to AST Unparser.\n\n1.6.3 - 2019-12-22\n~~~~~~~~~~~~~~~~~~\n\n* Add full support for Python 3.8\n\n1.6.2 - 2019-01-19\n~~~~~~~~~~~~~~~~~~\n\n* Add support for the Constant node in Python 3.8\n* Add tests to the sdist\n\n1.6.1 - 2018-10-03\n~~~~~~~~~~~~~~~~~~\n\n* Fix the roundtripping of very complex f-strings.\n\n1.6.0 - 2018-09-30\n~~~~~~~~~~~~~~~~~~\n\n* Python 3.7 compatibility\n\n1.5.0 - 2017-02-05\n~~~~~~~~~~~~~~~~~~\n\n* Python 3.6 compatibility\n* bugfix: correct argparser option type\n\n1.4.0 - 2016-06-24\n~~~~~~~~~~~~~~~~~~\n\n* Support for the ``async`` keyword\n* Support for unparsing \"Interactive\" and \"Expression\" nodes\n\n1.3.0 - 2016-01-17\n~~~~~~~~~~~~~~~~~~\n\n* Python 3.5 compatibility\n\n1.2.0 - 2014-04-03\n~~~~~~~~~~~~~~~~~~\n\n* Python 2.6 through 3.4 compatibility\n* A new function ``dump`` is added to return a pretty-printed version\n of the AST. It's also available when running ``python -m astunparse``\n as the ``--dump`` argument.\n\n1.1.0 - 2014-04-01\n~~~~~~~~~~~~~~~~~~\n\n* ``unparse`` will return the source code for an AST. It is pretty\n feature-complete, and round-trips the stdlib, and is compatible with\n Python 2.7 and Python 3.4.\n\n Running ``python -m astunparse`` will print the round-tripped source\n for any python files given as argument.\n\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "An AST unparser for Python",
"version": "1.6.3",
"split_keywords": [
"astunparse"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "d24e46166555fe1917398f6d7c016dad",
"sha256": "c2652417f2c8b5bb325c885ae329bdf3f86424075c4fd1a128674bc6fba4b8e8"
},
"downloads": -1,
"filename": "astunparse-1.6.3-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "d24e46166555fe1917398f6d7c016dad",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 12732,
"upload_time": "2019-12-22T18:12:11",
"upload_time_iso_8601": "2019-12-22T18:12:11.297519Z",
"url": "https://files.pythonhosted.org/packages/2b/03/13dde6512ad7b4557eb792fbcf0c653af6076b81e5941d36ec61f7ce6028/astunparse-1.6.3-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "2cea4d8e49beba7684bac890e73d6a40",
"sha256": "5ad93a8456f0d084c3456d059fd9a92cce667963232cbf763eac3bc5b7940872"
},
"downloads": -1,
"filename": "astunparse-1.6.3.tar.gz",
"has_sig": false,
"md5_digest": "2cea4d8e49beba7684bac890e73d6a40",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 18290,
"upload_time": "2019-12-22T18:12:13",
"upload_time_iso_8601": "2019-12-22T18:12:13.129415Z",
"url": "https://files.pythonhosted.org/packages/f3/af/4182184d3c338792894f34a62672919db7ca008c89abee9b564dd34d8029/astunparse-1.6.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2019-12-22 18:12:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "simonpercivall",
"github_project": "astunparse",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "wheel",
"specs": [
[
"<",
"1.0"
],
[
">=",
"0.23.0"
]
]
},
{
"name": "six",
"specs": [
[
"<",
"2.0"
],
[
">=",
"1.6.1"
]
]
}
],
"test_requirements": [
{
"name": "coverage",
"specs": [
[
"==",
"3.7.1"
]
]
}
],
"tox": true,
"lcname": "astunparse"
}