Various AST utils
Project description
astate
Various AST utils
To install: pip install astate
Examples
re_find_in_body
Recursively find elements in an ast body that satisfy a condition
>>> from astate import re_find_in_body
>>> def foo(x):
... def bar(y):
... y * 1
... return bar(x)
>>>
>>> [x.name for x in re_find_in_body(foo)]
['foo', 'bar']
>>> [x.name for x in re_find_in_body(foo, max_levels=1)]
['foo']
remove_docstrings
Remove docstrings from the given Python code.
>>> from astate import remove_docstrings
>>> code = '''
... def foo():
... """This is a docstring."""
... print("Hello")
...
... class Bar:
... """Class docstring."""
... def baz(self):
... """Method docstring."""
... pass
... '''
>>> print(remove_docstrings(code))
def foo():
print('Hello')
<BLANKLINE>
class Bar:
<BLANKLINE>
def baz(self):
pass
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
astate-0.0.7.tar.gz
(7.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file astate-0.0.7.tar.gz.
File metadata
- Download URL: astate-0.0.7.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0f3092089184bd27f566e2390a48c88fbcd0793c2eef23666a9d3d9f06596e7
|
|
| MD5 |
0dfed6a9f6a08d14bce4393927cdc879
|
|
| BLAKE2b-256 |
54271fde86da3ffa36c32a48c3d048fb15c3dc66897397c0118fb6c923535d40
|
File details
Details for the file astate-0.0.7-py3-none-any.whl.
File metadata
- Download URL: astate-0.0.7-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c497e98ad587238a07bb349f41e35be51301a3a419faf3ce2b39767b63d28959
|
|
| MD5 |
f5fe098a26a8dd0b7d5702b761520896
|
|
| BLAKE2b-256 |
c44fc922f3949d588e0df97866a25da8dcd159b08400c807e019e0225f752fec
|