1import json 2import os 3 4script_dir = os.path.dirname(__file__) 5properties_path = os.path.join(script_dir, "../../docs/misra/function-macro-properties.json") 6output_path = os.path.join(script_dir, "ECLAIR/call_properties.ecl") 7 8with open(properties_path) as fp: 9 properties = json.load(fp)['content'] 10 11ecl = open(output_path, 'w') 12 13for record in properties: 14 15 string = "-call_properties+={\"" 16 if record['type'] == "function": 17 string += f"{record['value']}\", {{".replace("\\", "\\\\") 18 else: 19 string += f"{record['type']}({record['value']})\", {{".replace("\\", "\\\\") 20 21 i=0 22 for prop in record['properties'].items(): 23 if prop[0] == 'attribute': 24 string += prop[1] 25 i+=1 26 else: 27 string += f"\"{prop[0]}({prop[1]})\"" 28 i+=1 29 30 if i<len(record['properties']): 31 string += ", " 32 else: 33 string +="}}\n" 34 35 ecl.write(string) 36 37ecl.close() 38