| 1 |
import json |
| 2 |
import os |
| 3 |
|
| 4 |
script_dir = os.path.dirname(__file__) |
| 5 |
properties_path = os.path.join(script_dir, "../../docs/misra/function-macro-properties.json") |
| 6 |
output_path = os.path.join(script_dir, "ECLAIR/call_properties.ecl") |
| 7 |
|
| 8 |
with open(properties_path) as fp: |
| 9 |
properties = json.load(fp)['content'] |
| 10 |
|
| 11 |
ecl = open(output_path, 'w') |
| 12 |
|
| 13 |
for 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 |
|
| 37 |
ecl.close() |