{"id":16391738,"url":"https://github.com/williamfzc/planter","last_synced_at":"2026-05-10T05:04:46.229Z","repository":{"id":57453303,"uuid":"247082567","full_name":"williamfzc/planter","owner":"williamfzc","description":"compile dict (json/yaml/toml/everything) to tree","archived":false,"fork":false,"pushed_at":"2020-03-31T13:15:17.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-02T11:18:38.580Z","etag":null,"topics":["data-structures","dictionary","json","python","tree","tree-structure","yaml"],"latest_commit_sha":null,"homepage":null,"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/williamfzc.png","metadata":{"files":{"readme":"README.md","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":"2020-03-13T13:52:04.000Z","updated_at":"2020-03-31T13:15:19.000Z","dependencies_parsed_at":"2022-08-29T08:41:45.621Z","dependency_job_id":null,"html_url":"https://github.com/williamfzc/planter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/williamfzc/planter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fplanter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fplanter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fplanter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fplanter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williamfzc","download_url":"https://codeload.github.com/williamfzc/planter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fplanter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265499868,"owners_count":23777364,"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":["data-structures","dictionary","json","python","tree","tree-structure","yaml"],"created_at":"2024-10-11T04:47:12.405Z","updated_at":"2026-05-10T05:04:46.162Z","avatar_url":"https://github.com/williamfzc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# planter\n\ncompile dict (json/yaml/toml/everything) to tree\n\n## what is it?\n\nDictionary is quite a good data structure, but not programmable enough.\n\n```python\ndata = {\n    \"a\": {\"b\": {\"e\": {\"x\": {\"y\": {\"z\": \"ok\"}}}}, \"c\": \"d\"},\n    \"g\": \"h\",\n    \"i\": {\"j\": {\"k\": {\"l\": \"m\"}}},\n}\n```\n\nand if i gonna call `z`, i need to:\n\n```python\ndata[\"a\"][\"b\"][\"e\"][\"x\"][\"y\"][\"z\"]\n```\n\nor loop:\n\n```python\nfor k, v in data.items():\n    for i, j in v.items():\n        for k, l in j.items():\n            # ...\n```\n\nlooks very weird. However, with this repo:\n\n```python\nfrom planter import Compiler, Tree\n\nc = Compiler()\n# Node object\nroot_node = c.compile(data)\n# Tree object\ntree = Tree(root_node)\n```\n\nnow you have already converted it into a `Tree` object which was built with some `Node`s.\nand you can operate these nodes easily, eg: depth first search?\n\n```python\nfor each_node in tree.dfs(root):\n    print(each_node.name)\n\n    # and its depth\n    print(each_node.depth)\n    # ...\n```\n\noutput:\n\n```text\nroot\n0\na\n1\nb\n2\ne\n3\nx\n4\ny\n5\ni\n1\nj\n2\nk\n3\n```\n\nit is flexible and extendable.\n\nWhat's more, actually JSON/YAML or something like that, can be easily converted into python dictionary.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamfzc%2Fplanter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliamfzc%2Fplanter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamfzc%2Fplanter/lists"}