{"id":20180570,"url":"https://github.com/sauci/pya2l","last_synced_at":"2025-04-05T23:05:33.614Z","repository":{"id":57455651,"uuid":"126212352","full_name":"Sauci/pya2l","owner":"Sauci","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-12T08:14:11.000Z","size":2231,"stargazers_count":37,"open_issues_count":3,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T22:04:25.260Z","etag":null,"topics":["a2l","asam-mcd-2mc","automotive","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sauci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-21T16:56:36.000Z","updated_at":"2025-03-14T16:34:49.000Z","dependencies_parsed_at":"2023-12-13T12:38:53.540Z","dependency_job_id":"4eced152-d60b-4f2b-9048-2ae143dacc6a","html_url":"https://github.com/Sauci/pya2l","commit_stats":{"total_commits":108,"total_committers":3,"mean_commits":36.0,"dds":0.08333333333333337,"last_synced_commit":"0c0d433396492260e40d32a53f6a49b1de44ed07"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sauci%2Fpya2l","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sauci%2Fpya2l/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sauci%2Fpya2l/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sauci%2Fpya2l/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sauci","download_url":"https://codeload.github.com/Sauci/pya2l/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411226,"owners_count":20934653,"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":["a2l","asam-mcd-2mc","automotive","python3"],"created_at":"2024-11-14T02:31:44.204Z","updated_at":"2025-04-05T23:05:33.591Z","avatar_url":"https://github.com/Sauci.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"|                         branch                         |                                                                                build                                                                                 |                                                                         coverage                                                                         |\n|:------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------:|\n|  [master](https://github.com/Sauci/pya2l/tree/master)  | [![Python package](https://github.com/Sauci/pya2l/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/Sauci/pya2l/actions/workflows/build.yml)  |  [![code coverage](https://codecov.io/gh/Sauci/pya2l/branch/master/graphs/badge.svg?token=Q5aceZRFXh)](https://codecov.io/gh/Sauci/pya2l?branch=master)  |\n| [develop](https://github.com/Sauci/pya2l/tree/develop) | [![Python package](https://github.com/Sauci/pya2l/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/Sauci/pya2l/actions/workflows/build.yml) | [![code coverage](https://codecov.io/gh/Sauci/pya2l/branch/develop/graphs/badge.svg?token=Q5aceZRFXh)](https://codecov.io/gh/Sauci/pya2l?branch=develop) |\n\n[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://raw.githubusercontent.com/Sauci/pya2l/master/LICENSE.md) [![Gitter](https://img.shields.io/gitter/room/Sauci/pya2l.svg)](https://gitter.im/pya2l/Lobby)\n\n## Package description\n\nthe purpose of this package is to provide an easy way to access and navigate\nin [a2l](https://www.asam.net/standards/detail/mcd-2-mc/) formatted file.  \nonce the file has been loaded, a tree of Python objects is generated, allowing the user to access nodes.\n\n## Installation\n\n### Using *pip*\n\nInstall the last released version of the package by running the following command:\n`pip install pya2l`\n\nor install the most recent version of the package (master branch) by running the following command:\n`pip install git+https://github.com/Sauci/pya2l.git@master`\n\n## Example of usage\n\n### Command line tool\n\nOnce the package installed, the `pya2l` command will be available. It provides several different commands:\n\n- Convert an A2L file to JSON with `pya2l -v \u003csource\u003e.a2l to_json -o \u003coutput.json\u003e -i 2`\n- Convert an A2L file to A2L with `pya2l -v \u003csource.a2l\u003e to_a2l -o \u003coutput.a2l\u003e -i 2`\n- Convert a JSON-formatted A2L file to JSON with `pya2l -v \u003csource\u003e.json to_json -o \u003coutput.json\u003e -i 2`\n- Convert a JSON-formatted A2L file to A2L with `pya2l -v \u003csource\u003e.json to_a2l -o \u003coutput.a2l\u003e -i 2`\n\n### Python API\n\nthe bellow code snippet shows how properties of a node in an a2l string can be retrieved using this package.\n\n```python\nfrom pya2l.parser import A2lParser as Parser\n\na2l_string = \"\"\"/begin PROJECT project_name \"example project\"\n    /begin MODULE first_module \"first module long identifier\"\n        /begin CHARACTERISTIC\n            example_of_characteristic\n            \"first characteristic long identifier\"\n            VALUE\n            0\n            DAMOS_SST\n            0\n            first_characteristic_conversion\n            -4.5\n            12.0\n        /end CHARACTERISTIC\n    /end MODULE\n/end PROJECT\n\"\"\"\n\nwith Parser() as p:\n    # get the AST.\n    ast = p.tree_from_a2l(a2l_string.encode())\n\n    # get a list of available properties for a specific node.\n    assert set(ast.PROJECT.properties) == {'Name', 'LongIdentifier', 'HEADER', 'MODULE'}\n\n    # access nodes explicitly.\n    assert ast.PROJECT.MODULE[0].CHARACTERISTIC[0].Name.Value == 'example_of_characteristic'\n    assert ast.PROJECT.MODULE[0].CHARACTERISTIC[0].LowerLimit.Value == -4.5\n    assert ast.PROJECT.MODULE[0].CHARACTERISTIC[0].UpperLimit.Value == 12.0\n\na2l_string = \"\"\"/begin PROJECT project_name \"example project\"\n    /begin MODULE first_module \"first module long identifier\"\n    /end MODULE\n/end PROJECT\n\"\"\"\n\nwith Parser() as p:\n    # get the AST.\n    ast = p.tree_from_a2l(a2l_string.encode())\n\n    # convert node to json-formatted string.\n    assert p.json_from_tree(ast, indent=2).decode() == \"\"\"{\n  \"PROJECT\": {\n    \"Name\": {\n      \"Value\": \"project_name\"\n    },\n    \"LongIdentifier\": {\n      \"Value\": \"example project\"\n    },\n    \"MODULE\": [\n      {\n        \"Name\": {\n          \"Value\": \"first_module\"\n        },\n        \"LongIdentifier\": {\n          \"Value\": \"first module long identifier\"\n        }\n      }\n    ]\n  }\n}\"\"\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsauci%2Fpya2l","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsauci%2Fpya2l","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsauci%2Fpya2l/lists"}