{"id":25636211,"url":"https://github.com/carglglz/mpy-yaml","last_synced_at":"2026-05-08T06:46:47.182Z","repository":{"id":278965050,"uuid":"934002523","full_name":"Carglglz/mpy-yaml","owner":"Carglglz","description":"MicroPython YAML parser / emitter","archived":false,"fork":false,"pushed_at":"2025-02-22T22:55:56.000Z","size":45,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T21:16:25.287Z","etag":null,"topics":["micropython","yaml","yaml-emitter","yaml-parser"],"latest_commit_sha":null,"homepage":"","language":"C","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/Carglglz.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-17T05:35:16.000Z","updated_at":"2025-05-02T06:52:30.000Z","dependencies_parsed_at":"2025-08-25T00:43:47.604Z","dependency_job_id":"c194879d-25b7-4054-8970-7151dfffabef","html_url":"https://github.com/Carglglz/mpy-yaml","commit_stats":null,"previous_names":["carglglz/mpy-yaml"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Carglglz/mpy-yaml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fmpy-yaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fmpy-yaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fmpy-yaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fmpy-yaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Carglglz","download_url":"https://codeload.github.com/Carglglz/mpy-yaml/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fmpy-yaml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005410,"owners_count":26083883,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["micropython","yaml","yaml-emitter","yaml-parser"],"created_at":"2025-02-23T00:35:37.865Z","updated_at":"2025-10-10T21:16:27.806Z","avatar_url":"https://github.com/Carglglz.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## mpy-yaml \n\n\u003e [!NOTE]\n\u003e This is a proof of concept, so it may support only a subset of yaml specs.\n\nMicroPython YAML parser/emitter `USER_C_MODULE` using [libyaml](https://github.com/yaml/libyaml)\n\n\n### API\n\n- `yaml.loads(\"yaml_string\")`: parses a YAML string and returns a dictionary (same as `json.loads`)\n\n- `yaml.load(stream)`: parses a stream YAML file and returns a dictionary (same as `json.load`) \n\n- `yaml.loadf(filename)`: parses a YAML file and returns a dictionary. \n\n- `yaml.dumps(dict)`: dump a dict object into a YAML string.\n\n- `yaml.dump(dict, stream)`: dump a dict object into a YAML string and writes it to a file stream (same as `json.dump`)\n\n- `yaml.dumpf(dict, filename)`: dump a dict object into a YAML string and saves it in `filename`\n\n\n\n### Example \n\n```yaml\n# public.yaml\ntitle   : Finex 2011\nimg_url : /finex/html/img/\ncss_url : /finex/html/style/\njs_url  : /finex/html/js/\n\ntemplate_dir: html/templ/\n\ndefault_act : idx    # used for invalid/missing act=\n\npages:\n  - act   : idx\n    title : Welcome\n    html  : public/welcome.phtml\n  - act   : reg\n    title : Register\n    html  : public/register.phtml\n  - act   : log\n    title : Log in\n    html  : public/login.phtml\n  - act   : out\n    title : Log out\n    html  : public/logout.phtml\n\n```\n\n\n```py \nimport yaml \n\njson_string = yaml.load(\"public.yaml\")\nprint(json_string)\n\n```\n\n```py\n{\"title\": \"Finex 2011\", \"img_url\": \"/finex/html/img/\", \"css_url\": \"/finex/html/style/\", \"js_url\": \"/finex/html/js/\", \"template_dir\": \"html/templ/\", \"default_act\": \"idx\", \"pages\": [{\"act\": \"idx\", \"title\": \"Welcome\", \"html\": \"public/welcome.phtml\"}, {\"act\": \"reg\", \"title\": \"Register\", \"html\": \"public/register.phtml\"}, {\"act\": \"log\", \"title\": \"Log in\", \"html\": \"public/login.phtml\"}, {\"act\": \"out\", \"title\": \"Log out\", \"html\": \"public/logout.phtml\"}]}\n```\n\n### Tests \n\nTested ports: \n - unix (macos) \n - stm32 (pybV1.1)\n - esp32 (ESP32-WROOM-32)\n\nIn `./tests/` run `micropython test_parser.py`\n\n```bash\n$ micropython test_parser.py\n\n\n--- YAML PARSER TEST: base.yaml ---\n\n{'john': {'hates': 'meetings', 'loves': 'dogs', 'writes': 'Coding Challenges'}, 'size': [{'hi': 'hello', 'chao': 'bye'}, 10], 'hello': 'world', 'key': 'value', 'name': 'Coding Challenges', 'enable': True, 'challenge': {'name': 'YAML Parser'}, 'array': [1, 2], 'arrayinline': [1, 2]}\n\n--- YAML: base.yaml [ OK ] ---\n\n\n--- YAML PARSER TEST: public.yaml ---\n\n{'js_url': '/finex/html/js/', 'pages': [{'html': 'public/welcome.phtml', 'title': 'Welcome', 'act': 'idx'}, {'html': 'public/register.phtml', 'title': 'Register', 'act': 'reg'}, {'html': 'public/login.phtml', 'title': 'Log in', 'act': 'log'}, {'html': 'public/logout.phtml', 'title': 'Log out', 'act': 'out'}], 'img_url': '/finex/html/img/', 'css_url': '/finex/html/style/', 'template_dir': 'html/templ/', 'title': 'Finex 2011', 'default_act': 'idx'}\n\n--- YAML: public.yaml [ OK ] ---\n\n\n--- YAML PARSER TEST: services.yaml ---\n\n{'aiomqtt_sensor_bme280': {'enabled': False, 'kwargs': {'hostname': '${SERVER}'}}, 'hello': {'enabled': True, 'args': [3, 5], 'kwargs': {'service_logger': True, 'loglevel': 'INFO'}}, 'unittest_core': {'enabled': True, 'kwargs': {'debug': False, 'root': '', 'require': [], 'save_report': True, 'modules': ['/home/${USERNAME}/.micropython/lib', 'mymodule.py']}}, 'network': {'enabled': True, 'kwargs': {'rsyslog': False, 'webrepl_on': False}}, 'ping': {'enabled': False, 'kwargs': {'host': '192.168.1.1'}}, 'mip': {'enabled': True, 'kwargs': {'packages': {}, 'schedule': {'repeat': 60, 'start_in': 30}, 'restart': False, 'autoupdate': True}}, 'watcher': {'enabled': True, 'kwargs': {'wdfeed': 60000, 'save_report': True, 'max_errors': 0}}, 'powermg': {'enabled': False}, 'aiomqtt': {'enabled': True, 'kwargs': {'server': '${SERVER}', 'ssl': True, 'ssl_params': {'cert': 'broker.crt', 'key': 'broker-key.pem', 'ca': 'ca.crt'}, 'hostname': '${SERVER}', 'port': 8883, 'keepalive': 300, 'stats': True, 'topics': ['device/gkesp32/resp', 'homeassistant/sensor/especg/state', 'homeassistant/sensor/gkesp32/state']}}, 'gui_lvgl': {'enabled': True, 'kwargs': {'width': 320, 'banner': True, 'lib': 'display_driver', 'driver': 'get_display', 'app': 'asyncmd', 'height': 480, 'app_config': 'configs/asyncmd/gui_lvgl.config', 'loglevel': 'INFO'}}, 'microdot_ws': {'enabled': False}, 'devop': {'enabled': False}, 'microdot': {'enabled': False}, 'webfile': {'enabled': True, 'kwargs': {'ssl': False, 'cert': 'broker.crt', 'hostname': '${SERVER}', 'key': 'broker-key.pem'}}, 'stats': {'enabled': True, 'kwargs': {'port': 8234}}, 'unittest': {'enabled': False, 'kwargs': {'debug': False, 'save_report': True, 'root': '', 'schedule': {'repeat': 30, 'start_in': 2}, 'modules': ['/home/cgg/.micropython/lib', 'mymodule.py']}}, 'certbot': {'enabled': True, 'kwargs': {'certificate': 'broker.crt', 'schedule': {'repeat': 300, 'start_in': 60}, 'loglevel': 'DEBUG'}}, 'aiomqtt_sensor_ina219': {'enabled': False, 'kwargs': {'hostname': '${SERVER}'}}}\n\n--- YAML: services.yaml [ OK ] ---\n```\n\nor run MicroPython test suite e.g. :\n\n```bash\n$ ./tests/run-tests.py ../user_modules/mpy-yaml/tests/*.py\nplatform=darwin arch=x64\npass  ../user_modules/mpy-yaml/tests/test_stress_emitter.py\npass  ../user_modules/mpy-yaml/tests/test_stress_parser.py\npass  ../user_modules/mpy-yaml/tests/test_parser.py\npass  ../user_modules/mpy-yaml/tests/test_loads_dumps.py\n4 tests performed (8032 individual testcases)\n4 tests passed\n```\n\n### Debug\n\nEnable with `#define MICROPY_DEBUG_YAML (1)` in `mpconfigboard.h` or `mpconfigvariant.h`\n\n### Memory Usage\n\nThe yaml parser and emitter requires two buffers each. Defaults are:\n\n```make\nMICROPY_YAML_INPUT_BUFFER  512\nMICROPY_YAML_OUTPUT_BUFFER  2048\n\n```\nSee `mod_libyaml.h` for more information and change defaults settings in `mpconfigboard.h` or `mpconfigvariant.h` if needed.\n\n\n#### References \n\nhttps://www.wpsoftware.net/andrew/pages/libyaml.html\n\nhttps://codingchallenges.fyi/challenges/challenge-yaml/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarglglz%2Fmpy-yaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarglglz%2Fmpy-yaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarglglz%2Fmpy-yaml/lists"}