{ "info": { "author": "Ben Hauser", "author_email": "b.hauser@zerolaw.tech", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# solc-ast\n\n[![Pypi Status](https://img.shields.io/pypi/v/py-solc-ast.svg)](https://pypi.org/project/py-solc-ast/) [![Build Status](https://img.shields.io/travis/com/iamdefinitelyahuman/py-solc-ast.svg)](https://travis-ci.com/iamdefinitelyahuman/py-solc-ast) [![Coverage Status](https://coveralls.io/repos/github/iamdefinitelyahuman/py-solc-ast/badge.svg?branch=master)](https://coveralls.io/github/iamdefinitelyahuman/py-solc-ast?branch=master)\n\nA tool for exploring the Solidity abstrax syntrax tree as generated by the [solc](https://github.com/ethereum/solidity) compiler.\n\n## Installation\n\nYou can install the latest release via ``pip``:\n\n```bash\n$ pip install py-solc-ast\n```\n\nOr clone the repo and use ``setuptools``:\n\n```bash\n$ python setup.py install\n```\n\n## Usage\n\nFirst, use [py-solc-x](https://github.com/iamdefinitelyahuman/py-solc-x) to compile your contracts to the [standard JSON output format](https://solidity.readthedocs.io/en/latest/using-the-compiler.html#output-description).\n\n```python\n>>> import json\n>>> import solcx\n>>> input_json = json.load(open('input.json'))\n>>> output_json = solcx.compile_standard(input_json)\n```\n\nNext, import ``solcast`` and initialize using ``from_standard_output_json`` or ``from_standard_output``. This returns a list of ``SourceUnit`` objects, which each represent the base AST node in a Solidity source file.\n\n```python\n>>> import solcast\n>>> nodes = solcast.from_standard_output(output_json)\n>>> nodes\n[, ]\n```\n\n### Interacting with Nodes\n\nEach node has the following attributes:\n\n```python\n>>> node\n\n\n>>> node.depth # Number of nodes between this node and the SourceUnit\n2\n\n>>> node.offset # Absolute source offsets as a (start, stop) tuple\n(1693, 2151)\n\n>>> node.contract_id # Contract ID as given by the standard compiler JSON\n2\n\n>>> node.fields # List of fields for this node\n['baseNodeType', 'documentation', 'id', 'implemented', 'kind', 'modifiers', 'name', 'nodeType', 'nodes', 'parameters', 'returnParameters', 'scope', 'src', 'stateMutability', 'superFunction', 'visibility']\n\n```\n\nFields mostly follow the expected [AST grammar](https://solidity.readthedocs.io/en/latest/miscellaneous.html#language-grammar). One notable difference: `Block` nodes are omitted and the body of each `Block` is available within it's parent as the attribute `nodes`. Nodes containing a body are iterable and can be accessed with list-like syntax. Additionally, any child node with a `name` field is accessible using dict-like syntax.\n\nThe following additional fields are also available:\n\n* Most nodes have a `baseNodeType` field as defined in [grammar.py](solcast/grammar.py)\n* `ContractDefinition` nodes have `dependencies` and `libraries` fields that point to related `ContractDefition` nodes\n\nWhen a node has a `nodes` field,\n\nSome Examples:\n\n```python\n>>> source_node\n\n\n>>> source_node.keys()\n['absolutePath', 'children', 'contract_id', 'depth', 'exportedSymbols', 'id', 'is_child_of', 'is_parent_of', 'keys', 'nodeType', 'nodes', 'offset', 'parent', 'parents', 'src']\n\n>>> source_node.nodes\n[, ]\n\n>>> source_node[1]\n\n\n>>> source_node['SafeMath']\n\n\n>>> source_node['SafeMath'].keys()\n['baseContracts', 'children', 'contractDependencies', 'contractKind', 'contract_id', 'dependencies', 'depth', 'documentation', 'fullyImplemented', 'id', 'is_child_of', 'is_parent_of', 'keys', 'libraries', 'linearizedBaseContracts', 'name', 'nodeType', 'nodes', 'offset', 'parent', 'parents', 'scope', 'src']\n\n>>> source_node['SafeMath'].nodes\n[, , , , ]\n\n>>> source_node['SafeMath']['mul']\n\n\n>>> source_node['SafeMath']['mul']\n[, , , ]\n```\n\n### Exploring the Tree\n\nThe `Node.children()` method is used to search and filter through child nodes of a given node. It takes any of the following keyword arguments:\n\n* `depth`: Number of levels of children to traverse. `0` returns only this node.\n* `include_self`: Includes this node in the results.\n* `include_parents`: Includes nodes that match in the results, when they also have child nodes that match.\n* `include_children`: If True, as soon as a match is found it's children will not be included in the search.\n* `required_offset`: Only match nodes with a source offset that contains this offset.\n* `offset_limits`: Only match nodes when their source offset is contained inside this source offset.\n* `filters`: Dictionary of `{'attribute': \"value\"}` that children must match. Can also be given as a list of dicts, children that match any of the dicts will be returned.\n* `exclude_filter`: Dictionary of `{'attribute': \"value\"}` that children cannot match.\n\n```python\n>>> node = s['Token']['transfer']\n>>> node.children(\n include_children=False,\n filters={'nodeType': \"FunctionCall\", \"expression.name\": \"require\"}\n)\n[]\n```\n\n`Node.parent()` and `Node.parents()` are used to travel back up the tree. They take the following arguments:\n\n* `depth`: Depth limit. If given as a negative value, it will be subtracted from this object's depth.\n* `filters`: Dictionary of `{'attribute': \"value\"}` that parents must match.\n\n`Node.parent()` returns one result, `Node.parents()` returns a list of matches.\n\n```python\n>>> node.parents()\n[, ]\n```\n\n## Tests\n\nTo run the test suite:\n\n```bash\n$ tox\n```\n\n## Development\n\nComments, questions, criticisms and pull requests are welcomed! Feel free to open an issue if you encounter a problem or would like to suggest a new feature.\n\n## License\n\nThis project is licensed under the [MIT license](LICENSE).\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/iamdefinitelyahuman/py-solc-ast", "keywords": "ethereum,solidity,solc,ast", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "py-solc-ast", "package_url": "https://pypi.org/project/py-solc-ast/", "platform": "", "project_url": "https://pypi.org/project/py-solc-ast/", "project_urls": { "Homepage": "https://github.com/iamdefinitelyahuman/py-solc-ast" }, "release_url": "https://pypi.org/project/py-solc-ast/1.0.2/", "requires_dist": null, "requires_python": ">=3.6, <4", "summary": "A tool for exploring the abstrax syntrax tree generated by solc.", "version": "1.0.2" }, "last_serial": 5905525, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "b2a764a2bfa04a73327b5c27adaeffce", "sha256": "818f41c877301ecf72dc72d59bc2b7cc40caf5ee6cf4748d7a6ae504670265e4" }, "downloads": -1, "filename": "py_solc_ast-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b2a764a2bfa04a73327b5c27adaeffce", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5, <4", "size": 9371, "upload_time": "2019-06-06T03:21:20", "url": "https://files.pythonhosted.org/packages/c5/79/219a20f6e1b21e529c647a82a04a1b2e77c03fdb4c72677584a4bbab2be5/py_solc_ast-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b2151970bb891d91ae267ae655546a8c", "sha256": "8a44f03287948dbcee5ade493d706095a3f865aa4e32c7e24f92bb4c5d3a8236" }, "downloads": -1, "filename": "py-solc-ast-0.1.0.tar.gz", "has_sig": false, "md5_digest": "b2151970bb891d91ae267ae655546a8c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5, <4", "size": 7950, "upload_time": "2019-06-06T03:21:22", "url": "https://files.pythonhosted.org/packages/9f/ad/f68e1cb610c613c463f7c7c0efbc5c86cde87590be17aab4a9599d413d70/py-solc-ast-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "7255fd4c708d84d2a732b5bfe3e8a04c", "sha256": "313e0336fe6fb1f841658328e887fba0f9b2254aee392f1fa068d81e95db95fe" }, "downloads": -1, "filename": "py_solc_ast-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7255fd4c708d84d2a732b5bfe3e8a04c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5, <4", "size": 9378, "upload_time": "2019-06-30T12:38:26", "url": "https://files.pythonhosted.org/packages/55/63/b8fa88695d3555d723b03f01ebbd879b8e2f23482b790a1c515cf11bd9c9/py_solc_ast-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "09000cede1d61f7249605cefc7790edd", "sha256": "7c8ba1a0d26d7f09a274236ccadd95057b55481cba6ad9cc7558e2d3205622ef" }, "downloads": -1, "filename": "py-solc-ast-0.1.1.tar.gz", "has_sig": false, "md5_digest": "09000cede1d61f7249605cefc7790edd", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5, <4", "size": 8039, "upload_time": "2019-06-30T12:38:28", "url": "https://files.pythonhosted.org/packages/5a/fc/cbdd71cb261b3b9ae1059eef169a341f360007aab04ee72bedf3ff5ca2b1/py-solc-ast-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "80d8c2908dbc30aa287dc2fec5ddc141", "sha256": "e3fdb06601f1480fa3366ab4b794380a6ef4714dea93c9d489c46f1a5d172537" }, "downloads": -1, "filename": "py_solc_ast-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "80d8c2908dbc30aa287dc2fec5ddc141", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5, <4", "size": 10988, "upload_time": "2019-07-01T16:47:19", "url": "https://files.pythonhosted.org/packages/96/e5/b68c1ddb77566390fe4a7b31b9f2e4119cbe832572fc9128ad3920fdf761/py_solc_ast-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6f88460f9217b7563e01e3f718dcf791", "sha256": "cb759d8de33b79cbc2d344a17fd8b4a07768230455ee820cf09a898ca067cd4f" }, "downloads": -1, "filename": "py-solc-ast-0.1.2.tar.gz", "has_sig": false, "md5_digest": "6f88460f9217b7563e01e3f718dcf791", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5, <4", "size": 9857, "upload_time": "2019-07-01T16:47:21", "url": "https://files.pythonhosted.org/packages/04/60/bf09a6872ca7366b082645983df0d480b6819c281554db2dd7528af386a9/py-solc-ast-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "eb1335e97928243c269f0ed7f05f7598", "sha256": "2abe822446d8d3ae626124fc4cd61d3592f18e004dfae3f042aa61640b257c18" }, "downloads": -1, "filename": "py_solc_ast-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "eb1335e97928243c269f0ed7f05f7598", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5, <4", "size": 11045, "upload_time": "2019-07-01T17:52:00", "url": "https://files.pythonhosted.org/packages/99/3e/69ce29c50946adc7bcf05244348236e2d913c5e150ee1f48b7d9e35edbfa/py_solc_ast-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e805790e7df28ef10758521fa4751212", "sha256": "bd984eac68240000a5506e5047cbc46b5f203df2bf81e46c61b69fff8c069b74" }, "downloads": -1, "filename": "py-solc-ast-0.1.3.tar.gz", "has_sig": false, "md5_digest": "e805790e7df28ef10758521fa4751212", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5, <4", "size": 9894, "upload_time": "2019-07-01T17:52:03", "url": "https://files.pythonhosted.org/packages/a3/db/34f0de85bf2f7d83038fe0f130a457c3bb403bfd060375c519ca23a97388/py-solc-ast-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "d9d22081f11d089614cb5a56f63a6341", "sha256": "4af97e8a328255ea5b2d7e353220b77ebe73ed3866ac9c0df6615b5e4c095b64" }, "downloads": -1, "filename": "py_solc_ast-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "d9d22081f11d089614cb5a56f63a6341", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5, <4", "size": 11058, "upload_time": "2019-07-27T19:34:29", "url": "https://files.pythonhosted.org/packages/8a/84/f6f34fd81fb3c95f19493a5ec7f0032ee377574fdf132c79b456e1baee27/py_solc_ast-0.1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "341403a14ddf5ed3d4b544e41c760408", "sha256": "1c358a46597106c6f4b1a5ec0f4f7e289343c7eb35bfa576ac4178df62c3db75" }, "downloads": -1, "filename": "py-solc-ast-0.1.4.tar.gz", "has_sig": false, "md5_digest": "341403a14ddf5ed3d4b544e41c760408", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5, <4", "size": 9895, "upload_time": "2019-07-27T19:34:31", "url": "https://files.pythonhosted.org/packages/f0/60/5e00fe1b0a93db89bfaa363c69a6882acf2fcbc8a2a1c7b666be5b7f4e10/py-solc-ast-0.1.4.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "d7db4762842f5523a242851afcf9ffc1", "sha256": "f79c4fd10dbc64b06d47bbc48bb73061d995416cae1834247cca4553789e930e" }, "downloads": -1, "filename": "py_solc_ast-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d7db4762842f5523a242851afcf9ffc1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6, <4", "size": 9399, "upload_time": "2019-09-19T06:09:44", "url": "https://files.pythonhosted.org/packages/f5/89/4ae3ef2fff977675de7c731f6ee34337dad0f7efb0b05b3c40cb047d9279/py_solc_ast-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "75a270b0452d116a5c666aa5454aaf42", "sha256": "81f42b8b608a161e2281c0d1ae7ed39f0851a90a82ce9e254a3411a4964aed9a" }, "downloads": -1, "filename": "py-solc-ast-1.0.0.tar.gz", "has_sig": false, "md5_digest": "75a270b0452d116a5c666aa5454aaf42", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6, <4", "size": 8149, "upload_time": "2019-09-19T06:09:46", "url": "https://files.pythonhosted.org/packages/2d/e7/0b2696d48970613f84c3f705aee0b695c4c3951c9700f8552b4bbca07929/py-solc-ast-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "a7e82e90b5efc049d2f58eb63c38330b", "sha256": "fe9292a6135e9e4b381177d89423380671436946bbf988fb95fe34254825b998" }, "downloads": -1, "filename": "py_solc_ast-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a7e82e90b5efc049d2f58eb63c38330b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6, <4", "size": 9366, "upload_time": "2019-09-19T08:58:41", "url": "https://files.pythonhosted.org/packages/50/57/df9ea5c0b6a3700e7dab4d3b278cf6e783e4ffde17f111d7a216724613f9/py_solc_ast-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "19f636b4d9e58bbf9f0b3a3765d00d77", "sha256": "b177921e437cb39d53786edc7cdb053d8be595f1dbde284d4feeb06647c9a09c" }, "downloads": -1, "filename": "py-solc-ast-1.0.1.tar.gz", "has_sig": false, "md5_digest": "19f636b4d9e58bbf9f0b3a3765d00d77", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6, <4", "size": 8136, "upload_time": "2019-09-19T08:58:43", "url": "https://files.pythonhosted.org/packages/ca/3d/39581c5f2c7f743ddfd2b09b8d841725a5b67750d429c12c7313a5a3e0ee/py-solc-ast-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "96d41a91638745786f5ce3382bf24299", "sha256": "bd5033529634c442008a65d8766c69b183cd2bd9d2f13d08d51f148fb3e29318" }, "downloads": -1, "filename": "py_solc_ast-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "96d41a91638745786f5ce3382bf24299", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6, <4", "size": 9373, "upload_time": "2019-09-30T08:35:38", "url": "https://files.pythonhosted.org/packages/d2/5a/6ff41410285d8e1680ecb7c72a6ca0de1aa5922482b1e0264282869016a3/py_solc_ast-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a61f00fcf9f49fa6a5e2db91604a53f9", "sha256": "1c971da61ea23d08b83bd5dae53215de184a2db8b06b4fc562d466b3de7ab731" }, "downloads": -1, "filename": "py-solc-ast-1.0.2.tar.gz", "has_sig": false, "md5_digest": "a61f00fcf9f49fa6a5e2db91604a53f9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6, <4", "size": 8154, "upload_time": "2019-09-30T08:35:41", "url": "https://files.pythonhosted.org/packages/37/e0/3e8e69bc97bb420e0ebe2b53ba4ebe202502287a175f6ea61969000b4fbd/py-solc-ast-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "96d41a91638745786f5ce3382bf24299", "sha256": "bd5033529634c442008a65d8766c69b183cd2bd9d2f13d08d51f148fb3e29318" }, "downloads": -1, "filename": "py_solc_ast-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "96d41a91638745786f5ce3382bf24299", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6, <4", "size": 9373, "upload_time": "2019-09-30T08:35:38", "url": "https://files.pythonhosted.org/packages/d2/5a/6ff41410285d8e1680ecb7c72a6ca0de1aa5922482b1e0264282869016a3/py_solc_ast-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a61f00fcf9f49fa6a5e2db91604a53f9", "sha256": "1c971da61ea23d08b83bd5dae53215de184a2db8b06b4fc562d466b3de7ab731" }, "downloads": -1, "filename": "py-solc-ast-1.0.2.tar.gz", "has_sig": false, "md5_digest": "a61f00fcf9f49fa6a5e2db91604a53f9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6, <4", "size": 8154, "upload_time": "2019-09-30T08:35:41", "url": "https://files.pythonhosted.org/packages/37/e0/3e8e69bc97bb420e0ebe2b53ba4ebe202502287a175f6ea61969000b4fbd/py-solc-ast-1.0.2.tar.gz" } ] }