(etdump_json: str)
| 44 | |
| 45 | |
| 46 | def _convert_to_flatcc(etdump_json: str) -> bytes: |
| 47 | with tempfile.TemporaryDirectory() as d: |
| 48 | # load given and common schema |
| 49 | _write_schema(d, ETDUMP_FLATCC_SCHEMA_NAME) |
| 50 | _write_schema(d, SCALAR_TYPE_SCHEMA_NAME) |
| 51 | |
| 52 | schema_path = os.path.join(d, "{}.fbs".format(ETDUMP_FLATCC_SCHEMA_NAME)) |
| 53 | json_path = os.path.join(d, "{}.json".format(ETDUMP_FLATCC_SCHEMA_NAME)) |
| 54 | with open(json_path, "wb") as json_file: |
| 55 | json_file.write(etdump_json.encode("ascii")) |
| 56 | |
| 57 | _flatc_compile(d, schema_path, json_path) |
| 58 | output_path = os.path.join(d, "{}.etdp".format(ETDUMP_FLATCC_SCHEMA_NAME)) |
| 59 | with open(output_path, "rb") as output_file: |
| 60 | return output_file.read() |
| 61 | |
| 62 | |
| 63 | def _convert_from_flatcc(etdump_flatbuffer: bytes, size_prefixed: bool = True) -> bytes: |
no test coverage detected