cmvr_head/packages/erpc-1.14.0/examples/hello_world/py/config.py
2025-12-30 15:44:41 +08:00

19 lines
465 B
Python

#
# Copyright 2023 NXP
#
# SPDX-License-Identifier: BSD-3-Clause
#
def lead_config(path: str = "config.h") -> dict:
""" Load config macros from C header file"""
result = {}
with open(path, "r") as file:
context = file.read().split("#define ")[1:]
for c in context:
cfg = c.split(" ")
if len(cfg) > 1:
val = cfg[1].strip().replace("\"", "")
result[cfg[0]] = val
return result