python-code-parse


Namepython-code-parse JSON
Version 0.0.5 PyPI version JSON
download
home_page
SummaryParse code to get information about functions, etc.
upload_time2023-02-05 14:23:26
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT
keywords code parse python ast abstract syntax tree
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Code Parser

Parse Python code to extract information about functions, classes, methods, etc.

## Install with pip

```bash
pip install python_code_parse
```

## Usage

Below is the output of running the parser on the example `examples/basic_example.py`:

```python
from python_code_parse import get_all_function_info_from_code, FunctionInfo
from typing import List

with open("examples/basic_example.py", "r") as f:
    data = f.read()

function_infos: List[FunctionInfo] = get_all_function_info_from_code(data)

print(function_infos)

"""
[
  FunctionInfo(
    name='sum',
    args=[
      FunctionArg(name='a', annotation='int'),
      FunctionArg(name='b', annotation='')
      ],
      return_type='None',
      line=1
    ),
    FunctionInfo(
      name='subtract',
      args=[
        FunctionArg(name='a', annotation=''),
        FunctionArg(name='b', annotation='')
      ],
      return_type='int',
      line=4
    )
]
"""
```

## Setup for Development

```bash
python3 -m venv venv
source venv/bin/activate
pip install -e .
pip install -e .[dev]
```

## Upload to PyPi

First you have to build the wheel file:

```bash
python3 -m pip wheel .
```

Then the wheel file can be uploaded to PyPi with:

```bash
twine upload --skip-existing python_code_parse-*.whl
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "python-code-parse",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "code,parse,python,ast,abstract syntax tree",
    "author": "",
    "author_email": "Jake Cyr <cyrjake@gmail.com>",
    "download_url": "",
    "platform": null,
    "description": "# Python Code Parser\n\nParse Python code to extract information about functions, classes, methods, etc.\n\n## Install with pip\n\n```bash\npip install python_code_parse\n```\n\n## Usage\n\nBelow is the output of running the parser on the example `examples/basic_example.py`:\n\n```python\nfrom python_code_parse import get_all_function_info_from_code, FunctionInfo\nfrom typing import List\n\nwith open(\"examples/basic_example.py\", \"r\") as f:\n    data = f.read()\n\nfunction_infos: List[FunctionInfo] = get_all_function_info_from_code(data)\n\nprint(function_infos)\n\n\"\"\"\n[\n  FunctionInfo(\n    name='sum',\n    args=[\n      FunctionArg(name='a', annotation='int'),\n      FunctionArg(name='b', annotation='')\n      ],\n      return_type='None',\n      line=1\n    ),\n    FunctionInfo(\n      name='subtract',\n      args=[\n        FunctionArg(name='a', annotation=''),\n        FunctionArg(name='b', annotation='')\n      ],\n      return_type='int',\n      line=4\n    )\n]\n\"\"\"\n```\n\n## Setup for Development\n\n```bash\npython3 -m venv venv\nsource venv/bin/activate\npip install -e .\npip install -e .[dev]\n```\n\n## Upload to PyPi\n\nFirst you have to build the wheel file:\n\n```bash\npython3 -m pip wheel .\n```\n\nThen the wheel file can be uploaded to PyPi with:\n\n```bash\ntwine upload --skip-existing python_code_parse-*.whl\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Parse code to get information about functions, etc.",
    "version": "0.0.5",
    "split_keywords": [
        "code",
        "parse",
        "python",
        "ast",
        "abstract syntax tree"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3833efe3c9905138ccf73f5b9f1f7e4139157c36746a61578609aebec68ac43a",
                "md5": "710a9160e4f9b8c6692e54460aebb6cf",
                "sha256": "71f7660636beaac725a922ff911f33ba61570d8e570032e57ca13224db3e6457"
            },
            "downloads": -1,
            "filename": "python_code_parse-0.0.5-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "710a9160e4f9b8c6692e54460aebb6cf",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 6645,
            "upload_time": "2023-02-05T14:23:26",
            "upload_time_iso_8601": "2023-02-05T14:23:26.413190Z",
            "url": "https://files.pythonhosted.org/packages/38/33/efe3c9905138ccf73f5b9f1f7e4139157c36746a61578609aebec68ac43a/python_code_parse-0.0.5-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-05 14:23:26",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "python-code-parse"
}
        
Elapsed time: 0.06479s