| 1 |
Metadata-Version: 1.2 |
| 2 |
Name: astor |
| 3 |
Version: 0.8.1 |
| 4 |
Summary: Read/rewrite/write Python ASTs |
| 5 |
Home-page: https://github.com/berkerpeksag/astor |
| 6 |
Author: Patrick Maupin |
| 7 |
Author-email: [email protected] |
| 8 |
License: BSD-3-Clause |
| 9 |
Description: ============================= |
| 10 |
astor -- AST observe/rewrite |
| 11 |
============================= |
| 12 |
|
| 13 |
:PyPI: https://pypi.org/project/astor/ |
| 14 |
:Documentation: https://astor.readthedocs.io |
| 15 |
:Source: https://github.com/berkerpeksag/astor |
| 16 |
:License: 3-clause BSD |
| 17 |
:Build status: |
| 18 |
.. image:: https://secure.travis-ci.org/berkerpeksag/astor.svg |
| 19 |
:alt: Travis CI |
| 20 |
:target: https://travis-ci.org/berkerpeksag/astor/ |
| 21 |
|
| 22 |
astor is designed to allow easy manipulation of Python source via the AST. |
| 23 |
|
| 24 |
There are some other similar libraries, but astor focuses on the following areas: |
| 25 |
|
| 26 |
- Round-trip an AST back to Python [1]_: |
| 27 |
|
| 28 |
- Modified AST doesn't need linenumbers, ctx, etc. or otherwise |
| 29 |
be directly compileable for the round-trip to work. |
| 30 |
- Easy to read generated code as, well, code |
| 31 |
- Can round-trip two different source trees to compare for functional |
| 32 |
differences, using the astor.rtrip tool (for example, after PEP8 edits). |
| 33 |
|
| 34 |
- Dump pretty-printing of AST |
| 35 |
|
| 36 |
- Harder to read than round-tripped code, but more accurate to figure out what |
| 37 |
is going on. |
| 38 |
|
| 39 |
- Easier to read than dump from built-in AST module |
| 40 |
|
| 41 |
- Non-recursive treewalk |
| 42 |
|
| 43 |
- Sometimes you want a recursive treewalk (and astor supports that, starting |
| 44 |
at any node on the tree), but sometimes you don't need to do that. astor |
| 45 |
doesn't require you to explicitly visit sub-nodes unless you want to: |
| 46 |
|
| 47 |
- You can add code that executes before a node's children are visited, and/or |
| 48 |
- You can add code that executes after a node's children are visited, and/or |
| 49 |
- You can add code that executes and keeps the node's children from being |
| 50 |
visited (and optionally visit them yourself via a recursive call) |
| 51 |
|
| 52 |
- Write functions to access the tree based on object names and/or attribute names |
| 53 |
- Enjoy easy access to parent node(s) for tree rewriting |
| 54 |
|
| 55 |
.. [1] |
| 56 |
The decompilation back to Python is based on code originally written |
| 57 |
by Armin Ronacher. Armin's code was well-structured, but failed on |
| 58 |
some obscure corner cases of the Python language (and even more corner |
| 59 |
cases when the AST changed on different versions of Python), and its |
| 60 |
output arguably had cosmetic issues -- for example, it produced |
| 61 |
parentheses even in some cases where they were not needed, to |
| 62 |
avoid having to reason about precedence. |
| 63 |
|
| 64 |
Other derivatives of Armin's code are floating around, and typically |
| 65 |
have fixes for a few corner cases that happened to be noticed by the |
| 66 |
maintainers, but most of them have not been tested as thoroughly as |
| 67 |
astor. One exception may be the version of codegen |
| 68 |
`maintained at github by CensoredUsername`__. This has been tested |
| 69 |
to work properly on Python 2.7 using astor's test suite, and, as it |
| 70 |
is a single source file, it may be easier to drop into some applications |
| 71 |
that do not require astor's other features or Python 3.x compatibility. |
| 72 |
|
| 73 |
__ https://github.com/CensoredUsername/codegen |
| 74 |
|
| 75 |
Keywords: ast,codegen,PEP 8 |
| 76 |
Platform: Independent |
| 77 |
Classifier: Development Status :: 5 - Production/Stable |
| 78 |
Classifier: Environment :: Console |
| 79 |
Classifier: Intended Audience :: Developers |
| 80 |
Classifier: License :: OSI Approved :: BSD License |
| 81 |
Classifier: Operating System :: OS Independent |
| 82 |
Classifier: Programming Language :: Python |
| 83 |
Classifier: Programming Language :: Python :: 2 |
| 84 |
Classifier: Programming Language :: Python :: 2.7 |
| 85 |
Classifier: Programming Language :: Python :: 3 |
| 86 |
Classifier: Programming Language :: Python :: 3.4 |
| 87 |
Classifier: Programming Language :: Python :: 3.5 |
| 88 |
Classifier: Programming Language :: Python :: 3.6 |
| 89 |
Classifier: Programming Language :: Python :: 3.7 |
| 90 |
Classifier: Programming Language :: Python :: 3.8 |
| 91 |
Classifier: Programming Language :: Python :: Implementation |
| 92 |
Classifier: Programming Language :: Python :: Implementation :: CPython |
| 93 |
Classifier: Programming Language :: Python :: Implementation :: PyPy |
| 94 |
Classifier: Topic :: Software Development :: Code Generators |
| 95 |
Classifier: Topic :: Software Development :: Compilers |
| 96 |
Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7 |