AST Selector
Query AST elements by using CSS Selector-like syntax
"Query AST elements 🌲 by using CSS Selector-like 💅 syntax."
Installation and usage
Installation
pip install ast_selector
Usage
from ast_selector import AstSelector
tree = load_python_code_as_ast_tree()
query = "FunctionDef Raise $FunctionDef"
# Query all functions that raises at least an exception
functions_raising_exceptions = AstSelector(query, tree).all()
Use Cases
Functions that return int
from ast_selector import AstSelector
tree = load_python_code_as_ast_tree()
query = "FunctionDef.returns[id=int] $FunctionDef"
# Query all functions that return ints e.g. def sum() -> int
function_element = AstSelector(query, tree).first()
License
MIT
Credits
It's extremely hard to keep hacking on open source like that while keeping a full-time job. I thank God from the bottom of my heart for both the inspiration and the energy.
Metadata
Release files for ast-selector 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ast_selector-0.1.3.tar.gz | 6.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ast_selector-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.1 kB
Release files / ast_selector-0.1.3.tar.gz
| Download URL | ast_selector-0.1.3.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82147160cc6940a44b34a7969d7ad88376d84e296f7129cbeb96525989845574
|
|
BLAKE2b-256 checksum How to use checksums |
9d65aae8bd83642042825cd1535375a6c39fce2dff95e202099f28f49db55cca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.4 Linux/5.15.0-35-generic
|
Release files / ast_selector-0.1.3-py3-none-any.whl
| Download URL | ast_selector-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef145ca95823ea1aec3595b5cd1cd5c42ea18def3cef86983782942ca0999227
|
|
BLAKE2b-256 checksum How to use checksums |
ca3af7e5c697b6563e4fe02af2770826303e1490e338047a47ad710028e0ef3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.4 Linux/5.15.0-35-generic
|