# 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
```python
>>> 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.
```python
>>> 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
```
Raw data
{
"_id": null,
"home_page": "https://github.com/thorwhalen/astate",
"name": "astate",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Thor Whalen",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/e7/58/300598d1f7dcc2b5292973452479dafad226d33cf66a9c3d49219b2e2549/astate-0.0.3.tar.gz",
"platform": "any",
"description": "# astate\n\nVarious AST utils\n\nTo install:\t```pip install astate```\n\n# Examples\n\n\n## re_find_in_body\n\nRecursively find elements in an ast body that satisfy a condition\n\n```python\n>>> from astate import re_find_in_body\n>>> def foo(x):\n... def bar(y):\n... y * 1\n... return bar(x)\n>>>\n>>> [x.name for x in re_find_in_body(foo)]\n['foo', 'bar']\n>>> [x.name for x in re_find_in_body(foo, max_levels=1)]\n['foo']\n```\n \n## remove_docstrings\n\nRemove docstrings from the given Python code.\n\n```python\n>>> from astate import remove_docstrings\n>>> code = '''\n... def foo():\n... \"\"\"This is a docstring.\"\"\"\n... print(\"Hello\")\n...\n... class Bar:\n... \"\"\"Class docstring.\"\"\"\n... def baz(self):\n... \"\"\"Method docstring.\"\"\"\n... pass\n... '''\n>>> print(remove_docstrings(code))\ndef foo():\n print('Hello')\n<BLANKLINE>\nclass Bar:\n<BLANKLINE>\n def baz(self):\n pass\n```\n",
"bugtrack_url": null,
"license": "apache-2.0",
"summary": "Various AST utils",
"version": "0.0.3",
"project_urls": {
"Homepage": "https://github.com/thorwhalen/astate"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3db21cebf45bd3785730839eef50e4d1f009bdd7ada1dcee29d92425a3f47d86",
"md5": "af2ec5e345a4d8c6593fdf2c7333d8d0",
"sha256": "b4aaae5352104f9a9a5adef67453a1f1043adf80ec0cb6bffd01c12351393637"
},
"downloads": -1,
"filename": "astate-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "af2ec5e345a4d8c6593fdf2c7333d8d0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7747,
"upload_time": "2024-11-26T13:40:11",
"upload_time_iso_8601": "2024-11-26T13:40:11.693719Z",
"url": "https://files.pythonhosted.org/packages/3d/b2/1cebf45bd3785730839eef50e4d1f009bdd7ada1dcee29d92425a3f47d86/astate-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e758300598d1f7dcc2b5292973452479dafad226d33cf66a9c3d49219b2e2549",
"md5": "cf6cd6ebfef478bb67a1c8263f4255a8",
"sha256": "a32276fbc3352a751625512542627e8c649ea53d5bfaf5a944e85f2fcad62ef2"
},
"downloads": -1,
"filename": "astate-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "cf6cd6ebfef478bb67a1c8263f4255a8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6830,
"upload_time": "2024-11-26T13:40:12",
"upload_time_iso_8601": "2024-11-26T13:40:12.715416Z",
"url": "https://files.pythonhosted.org/packages/e7/58/300598d1f7dcc2b5292973452479dafad226d33cf66a9c3d49219b2e2549/astate-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-26 13:40:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thorwhalen",
"github_project": "astate",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "astate"
}