{"id":16015631,"url":"https://github.com/aarant/xylem","last_synced_at":"2025-04-05T03:22:32.924Z","repository":{"id":62590245,"uuid":"133923989","full_name":"aarant/xylem","owner":"aarant","description":"Convert Python Abstract Syntax Trees (ASTs) to readable source code.","archived":false,"fork":false,"pushed_at":"2018-11-12T10:58:17.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-23T07:46:06.682Z","etag":null,"topics":["abstract-syntax-tree","ast","code-generator","python","python-3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aarant.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-18T08:09:56.000Z","updated_at":"2024-01-19T10:25:27.000Z","dependencies_parsed_at":"2022-11-03T22:45:59.066Z","dependency_job_id":null,"html_url":"https://github.com/aarant/xylem","commit_stats":null,"previous_names":["arantonitis/xylem"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarant%2Fxylem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarant%2Fxylem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarant%2Fxylem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarant%2Fxylem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aarant","download_url":"https://codeload.github.com/aarant/xylem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247281629,"owners_count":20913208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abstract-syntax-tree","ast","code-generator","python","python-3"],"created_at":"2024-10-08T15:41:26.113Z","updated_at":"2025-04-05T03:22:32.901Z","avatar_url":"https://github.com/aarant.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. |pypi| image:: https://img.shields.io/pypi/v/xylem.svg\n.. _pypi: https://pypi.python.org/pypi/xylem\n.. |license| image:: https://img.shields.io/github/license/arantonitis/xylem.svg\n.. _license: https://github.com/arantonitis/xylem/tree/master/LICENSE\n\nXylem\n*****\n|pypi|_ |license|_\n\nConvert Python Abstract Syntax Trees (ASTs) to readable source code.\n\nXylem is useful for when you want to make dynamic changes to Python code/ASTs, but also need to write those changes back as source code.\n\nIt's also very small (\u003c500 lines), pure-Python, and produces (mostly) readable source code.\n\nIn writing this, I made heavy use of the unofficial AST documentation at `Green Tree Snakes`_.\n\n.. _Green Tree Snakes: https://greentreesnakes.readthedocs.io\n\nInstallation\n============\nXylem will work on Python 3.4 or later. I'll eventually get around to testing it on Python 2.7-3.3.\n\nFrom PyPI\n---------\nInstall Xylem by running ``pip3 install xylem`` from the command line.\n\n.. note::\n\n   On some Linux systems, installation may require running pip with root permissions, or running ``pip3 install xylem --user``. The latter may require exporting `~/.local/bin` to PATH.\n   \nFrom GitHub\n-----------\nClone or download the `git repo`_, navigate to the directory, and run::\n\n    python3 setup.py sdist\n    cd dist\n    pip3 install xylem-\u003cversion\u003e.tar.gz\n    \n.. _git repo: https://github.com/arantonitis/xylem\n\nUsage\n=====\n``to_source`` is likely the only method you'll need to use:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from xylem import to_source\n    \u003e\u003e\u003e import ast\n    \u003e\u003e\u003e tree = ast.parse(\"print('hello world')\")\n    \u003e\u003e\u003e ast.dump(tree)\n    \"Module(body=[Expr(value=Call(func=Name(id='print', ctx=Load()), args=[Str(s='Hello world')], keywords=[]))])\"\n    \u003e\u003e\u003e to_source(tree)\n    \"print('hello world')\"\n\n``compare_ast`` may also be useful for determining if two ASTs are functionally equivalent.\n\nDevelopment\n===========\nXylem versioning functions on a ``MAJOR.MINOR.PATCH.[DEVELOP]`` model. Only stable, non development releases will be published to PyPI. Because Xylem is still a beta project, the ``MAJOR`` increment will be 0. Minor increments represent new features. Patch increments represent problems fixed with existing features.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarant%2Fxylem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faarant%2Fxylem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarant%2Fxylem/lists"}