(program_json: str)
| 48 | |
| 49 | |
| 50 | def convert_to_flatbuffer(program_json: str) -> bytes: |
| 51 | with tempfile.TemporaryDirectory() as d: |
| 52 | # load given and common schema |
| 53 | write_schema(d, BUNDLED_PROGRAM_SCHEMA_NAME) |
| 54 | write_schema(d, SCALAR_TYPE_SCHEMA_NAME) |
| 55 | |
| 56 | schema_path = os.path.join(d, "{}.fbs".format(BUNDLED_PROGRAM_SCHEMA_NAME)) |
| 57 | json_path = os.path.join(d, "{}.json".format(BUNDLED_PROGRAM_SCHEMA_NAME)) |
| 58 | with open(json_path, "wb") as json_file: |
| 59 | json_file.write(program_json.encode("ascii")) |
| 60 | _flatc_compile(d, schema_path, json_path) |
| 61 | output_path = os.path.join(d, "{}.bpte".format(BUNDLED_PROGRAM_SCHEMA_NAME)) |
| 62 | with open(output_path, "rb") as output_file: |
| 63 | return output_file.read() |
| 64 | |
| 65 | |
| 66 | def convert_from_flatbuffer(program_flatbuffer: bytes) -> bytes: |
no test coverage detected