{"id":20140270,"url":"https://github.com/outpost-os/python-dts-utils","last_synced_at":"2026-02-08T23:35:30.613Z","repository":{"id":247912622,"uuid":"826865240","full_name":"outpost-os/python-dts-utils","owner":"outpost-os","description":"a python utility package that aims to ease dts handling","archived":false,"fork":false,"pushed_at":"2024-09-26T11:21:27.000Z","size":94,"stargazers_count":0,"open_issues_count":4,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-05T10:42:22.474Z","etag":null,"topics":["device-tree","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/outpost-os.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":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-10T14:31:00.000Z","updated_at":"2024-09-26T11:21:31.000Z","dependencies_parsed_at":"2025-04-09T18:41:41.749Z","dependency_job_id":"c9d93d3c-0a14-4db0-b6f8-3c8fe887f44f","html_url":"https://github.com/outpost-os/python-dts-utils","commit_stats":null,"previous_names":["outpost-os/python-dts-utils"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/outpost-os/python-dts-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outpost-os%2Fpython-dts-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outpost-os%2Fpython-dts-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outpost-os%2Fpython-dts-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outpost-os%2Fpython-dts-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/outpost-os","download_url":"https://codeload.github.com/outpost-os/python-dts-utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outpost-os%2Fpython-dts-utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29249492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T22:49:53.206Z","status":"ssl_error","status_checked_at":"2026-02-08T22:49:51.384Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["device-tree","python"],"created_at":"2024-11-13T21:49:56.782Z","updated_at":"2026-02-08T23:35:30.597Z","avatar_url":"https://github.com/outpost-os.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nSPDX-FileCopyrightText: 2024 Ledger SAS\n\nSPDX-License-Identifier: Apache-2.0\n--\u003e\n\n[![REUSE status](https://api.reuse.software/badge/github.com/outpost-os/python-dts-utils)](https://api.reuse.software/info/github.com/outpost-os/python-dts-utils)\n\n![PyPI - Version](https://img.shields.io/pypi/v/dts-utils)\n![PyPI - License](https://img.shields.io/pypi/l/dts-utils)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dts-utils)\n\n[![codecov](https://codecov.io/gh/outpost-os/python-dts-utils/graph/badge.svg?token=SGQPBE40UI)](https://codecov.io/gh/outpost-os/python-dts-utils)\n![lint](https://github.com/outpost-os/python-dts-utils/actions/workflows/lint.yml/badge.svg)\n![unittest](https://github.com/outpost-os/python-dts-utils/actions/workflows/unittest.yml/badge.svg)\n![doc](https://github.com/outpost-os/python-dts-utils/actions/workflows/doc.yml/badge.svg)\n![quality](https://github.com/outpost-os/python-dts-utils/actions/workflows/quality.yml/badge.svg)\n\n# dts-utils python package\n`dts-utils` is an utility python package that aims to ease dts handling in python and source code\ngeneration based on dts files. Dts file parsing, preprocessing, validation are **out of scope** of\nthis package. This package is built on top of [Zephyr](https://github.com/zephyrproject-rtos/zephyr)\n[devicetree](https://pypi.org/project/devicetree/) package.\n\nThis package was built to fit OutpostOS needs but was designed to be generic enough and code\ngeneration language agnostic. Thus, this package can be used by any project which need to use\ndts files and generate code source or anything else based on it.\n\nProvided [dts2src entrypoint](#dts2src-entrypoint) is based on Jinja2 template processing, allowing\nusers to fully controlled generated output by providing his/her very own templates.\n\n## Dependencies\n - Python \u003e= 3.10\n - Jinja2 \u003e= 3\n - devicetree \u003e= 0.0.2\n - rich\n\n## Prerequisites\nOne may read, as an introduction, the following documentation:\n - [Jinja2 template writing](https://jinja.palletsprojects.com/en/3.1.x/templates/)\n - [Devicetree specification](https://www.devicetree.org/)\n - [Zephyr devicetree.dtlib](https://python-devicetree.readthedocs.io/en/latest/dtlib.html)\n\n## Usage\n`dts_utils.Dts` is the based class, it uses internally `devicetree.dtlib.Dts` and ease handling\nby extending class attributes with `__getattr__`. For `Dts` object, attributes are resolved, in\norder, from aliases and then in root `Node`. For `Node`, attribute are resolved from child node,\nlabel and, then, property. `Property` are  converted according to internal dtlib value type.\n\nAccessing a property or child node is straightforward and simply need to use the dot (`.`)\nnotation. If node or property contain special characters (e.g. `@`, `,`, `#`, `-`) in their name, one\nshould use [`getattr`](https://docs.python.org/3/library/functions.html#getattr) python built-in.\n\n```python\nimport dts_utils\n\ndts = dts_utils.Dts('/path/to/dts/file')\n\n# get root node\nroot = dts.root\n\n# get soc node\nsoc = dts.soc\n\n# get usart1 device node by label\n# labeled node are accessible from dts file or parent node\nusart1 = dts.usart1\n# OR\nusart1 = soc.usart1\n\n# get usart1 device node by name\nusart1 = getattr(dts, 'usart@4xxxxxxx')\n```\n\n### dts_dump entrypoint\n\nCommand line entrypoint that can dump in a pretty formatted form the dts file.\n\n```console\n$ dts_dump --help\nusage: dts_dump [-h] [-s] [-v] dts [node]\n\ndump a dts in a human readable format\n\npositional arguments:\n  dts                dts file\n  node               filter on node name or label\n\noptions:\n  -h, --help         show this help message and exit\n  -s, --status-okay  dump only status=okay nodes, except clocks\n  -v, --version      show program's version number and exit\n```\nExample:\n```console\n$ dts_dump /path/to/dts usart1\nusart1: serial@40013800 {\n        compatible = \"st,stm32-usart\", \"st,stm32-uart\";\n        reg = \u003c 0x40013800 0x400 \u003e;\n        clocks = \u003c \u0026rcc 0xa4 0x4000 \u003e;\n        resets = \u003c \u0026rctl 0xf8e \u003e;\n        interrupts = \u003c 0x3d 0x0 \u003e;\n        status = \"okay\";\n        pinctrl-0 = \u003c \u0026usart1_tx_pc1 \u003e, \u003c \u0026usart1_rx_pc0 \u003e;\n        phandle = \u003c 0x7 \u003e;\n};\n```\n\n### dts2src entrypoint\n`dts2src` entrypoint is a helper command line tool that process Jinja2 templates with the given\ndts file. To ease template writing, built-in jinja extension `loopcontrol` is enabled, dts object\nand environment variables are pass to the jinja environment along with custom jinja filters and\ntests\n\n```console\n$ dts2src --help\nusage: dts2src [-h] -d DTS -t TEMPLATE [-v] output\n\nrender jinja2 template using dts as data source\n\npositional arguments:\n  output                output filename\n\noptions:\n  -h, --help            show this help message and exit\n  -d DTS, --dts DTS     dts file to use as data source\n  -t TEMPLATE, --template TEMPLATE\n                        source template in jinja2 syntax\n  -v, --version         show program's version number and exit\n```\n\n\n#### access to dts node and property\nFrom Jinja environment, `dts_utils.Dts` is available as `dts`.\nEach nodes and/or properties are available using the dot (`.`) operator or `[]` operator (this is\nrequired if node or porperty name contains special characters).\n\ne.g.\n```jinja\n{{ dts.soc }}\n```\nor\n```jinja\n{{ dts.usart1['pinctrl-0'] }}\n```\n\n#### access to environment variable\nEnvironment variables are available, without external jinja extensions. Those are available as a\ndictionary named `env`.\n\ne.g.\n```jinja\n{{ env.USER }}\n```\n\n\u003c!--\n   Add custom filters/tests ref\n   do not duplicate documentation entries\n   Those are documented with pythondoc and generated with sphinx\n--\u003e\n\n\u003c!-- TODO\n## Contributing\n--\u003e\n\n## License\n```\nCopyright 2023 - 2024 Ledger SAS\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutpost-os%2Fpython-dts-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutpost-os%2Fpython-dts-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutpost-os%2Fpython-dts-utils/lists"}