Asteria (Al2O3)
Missing AST features
Features
- Repr implementation to every node (uses
astprettyif it is available, if not fall backs to theast.dump) - AST Comparisons with other nodes
- Custom initializer with finding default values according to ASDL spec
- Shortcuts for
fix_missing_locations,compile(e.gast.parse("2+2").compile()) - Unparsing shortcuts,
ast.parse("2+2").to_source(). It uses astor if its available, if not it fallbacks to theast.unparseinterface. - Parent/Child relationships to nodes
- Helpers functions for mutating tree (like
add_globalmethod toModulenodes which inserts given node at the top of body) - Symbol table access with
get_symbol_tablemethod - and many more...
Demo
>>> import ast
>>> import asteria
>>> ast.parse("2+2") == ast.parse("2+2")
True
>>> ast.parse("2+2").body[0].value
BinOp(
left=Constant(value=2, kind=None),
op=Add(),
right=Constant(value=2, kind=None),
)
>>> ast.parse("print(2+2)").compile()
<code object <module> at 0x7f2602f21450, file "<ASTERIA>", line 1>
>>> eval(_)
4
>>> ast.parse("import asteria").to_source()
'import asteria'
>>> sample = ast.parse("2+2")
>>> sample.parentize()
>>> sample.body[0].value.left.parent
BinOp(
left=Constant(value=2, kind=None),
op=Add(),
right=Constant(value=2, kind=None),
)
>>> sample.body[0].value.parent
Expr(
value=BinOp(
left=Constant(value=2, kind=None),
op=Add(),
right=Constant(value=2, kind=None),
),
)
>>> some_try = ast.parse("""\
... try:
... def x():
... print(1)
... finally: pass
... """)
>>> some_try.parentize()
>>> some_try.body[0].body[0].body[0].value
Call(
func=Name(id='print', ctx=Load()),
args=[Constant(value=1, kind=None)],
keywords=[],
)
>>> len(tuple(some_try.body[0].body[0].body[0].value.until_parented_by(ast.Try)))
3
>>> some_try.add_global(ast.parse("print('lol')").body[0])
>>> print(some_try.to_source())
print('lol')
try:
def x():
print(1)
finally:
pass
Metadata
Release files for asteria 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| asteria-0.0.2.tar.gz | 4.8 kB | Without provenance | Details for asteria-0.0.2.tar.gz |
Release files / asteria-0.0.2.tar.gz
| Download URL | asteria-0.0.2.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
852ced0ee2bb064908b98748c0b4ddc2d0c7d8d71a4885b9efe0c1aff49a8e7b
|
|
BLAKE2b-256 checksum How to use checksums |
0445ef5cc71cdb44a91b4a0aa3fff8c6f660d082911ade053ca7bb2de0e1f940
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5
|
Security for asteria 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.