diff --git a/src/caosadvancedtools/table_json_conversion/fill_xlsx.py b/src/caosadvancedtools/table_json_conversion/fill_xlsx.py index b9e1a93f3bf892b376cb07de4f1572dfa82e7120..3b22f1f9156f77165b0239d55941bf984e832c50 100644 --- a/src/caosadvancedtools/table_json_conversion/fill_xlsx.py +++ b/src/caosadvancedtools/table_json_conversion/fill_xlsx.py @@ -31,7 +31,8 @@ def _fill_leaves(json_doc: dict, workbook): for el in value: if isinstance(el, dict): _fill_leaves(el, workbook) - wb.cell(1,2, el) + wb.cell(1, 2, el) + def _get_row_type_column(worksheet): for col in worksheet.columns: @@ -40,6 +41,7 @@ def _get_row_type_column(worksheet): return cell.column raise ValueError("The column which defines row types (COL_TYPE, PATH, ...) is missing") + def _get_path_rows(worksheet): rows = [] rt_col = _get_row_type_column(worksheet) @@ -50,7 +52,6 @@ def _get_path_rows(worksheet): return rows - def _generate_path_col_mapping(workbook): rt_col = _get_row_type_column(workbook) @@ -58,7 +59,7 @@ def _generate_path_col_mapping(workbook): pass -def fill_template(template_path: str, json_path: str, result_path: str)-> None: +def fill_template(template_path: str, json_path: str, result_path: str) -> None: """ Fill the contents of the JSON document stored at ``json_path`` into the template stored at ``template_path`` and store the result under ``result_path``. diff --git a/unittests/table_json_conversion/create_jsonschema.py b/unittests/table_json_conversion/create_jsonschema.py index 8e1227183c931a12cec9d314b0a523fbfc51cc45..6f556863bf12e1c9001be95cc7213a3e875a766e 100755 --- a/unittests/table_json_conversion/create_jsonschema.py +++ b/unittests/table_json_conversion/create_jsonschema.py @@ -30,15 +30,16 @@ import tomli # TODO why do I need a running LA instance? + def prepare_datamodel(): model = parser.parse_model_from_yaml("./model.yml") exporter = jsex.JsonSchemaExporter(additional_properties=False, - #additional_options_for_text_props=additional_text_options, - #name_and_description_in_properties=True, + # additional_options_for_text_props=additional_text_options, + # name_and_description_in_properties=True, name_property_for_new_records=True, - #do_not_create=do_not_create, - #do_not_retrieve=do_not_retrieve, + do_not_create=["Organisation"], + # do_not_retrieve=do_not_retrieve, ) schema_top = exporter.recordtype_to_json_schema(model.get_deep("Training")) schema_pers = exporter.recordtype_to_json_schema(model.get_deep("Person")) diff --git a/unittests/table_json_conversion/model_schema.json b/unittests/table_json_conversion/model_schema.json index 4be94811e124226d88cefda9fb19428364f8506d..6b27c8b6604fbd3a7eb5ea1b6182fce60047d14b 100644 --- a/unittests/table_json_conversion/model_schema.json +++ b/unittests/table_json_conversion/model_schema.json @@ -53,19 +53,29 @@ "type": "string" }, "Organisation": { - "type": "object", - "required": [], - "additionalProperties": false, - "title": "Organisation", - "properties": { - "name": { - "type": "string", - "description": "The name of the Record to be created" + "oneOf": [ + { + "title": "Existing entries", + "enum": [ + "Federal Reserve" + ] }, - "Country": { - "type": "string" + { + "type": "object", + "required": [], + "additionalProperties": false, + "title": "Create new", + "properties": { + "name": { + "type": "string", + "description": "The name of the Record to be created" + }, + "Country": { + "type": "string" + } + } } - } + ] } } } @@ -87,19 +97,29 @@ "type": "string" }, "Organisation": { - "type": "object", - "required": [], - "additionalProperties": false, - "title": "Organisation", - "properties": { - "name": { - "type": "string", - "description": "The name of the Record to be created" + "oneOf": [ + { + "title": "Existing entries", + "enum": [ + "Federal Reserve" + ] }, - "Country": { - "type": "string" + { + "type": "object", + "required": [], + "additionalProperties": false, + "title": "Create new", + "properties": { + "name": { + "type": "string", + "description": "The name of the Record to be created" + }, + "Country": { + "type": "string" + } + } } - } + ] } } }, @@ -132,19 +152,29 @@ "type": "string" }, "Organisation": { - "type": "object", - "required": [], - "additionalProperties": false, - "title": "Organisation", - "properties": { - "name": { - "type": "string", - "description": "The name of the Record to be created" + "oneOf": [ + { + "title": "Existing entries", + "enum": [ + "Federal Reserve" + ] }, - "Country": { - "type": "string" + { + "type": "object", + "required": [], + "additionalProperties": false, + "title": "Create new", + "properties": { + "name": { + "type": "string", + "description": "The name of the Record to be created" + }, + "Country": { + "type": "string" + } + } } - } + ] } }, "$schema": "https://json-schema.org/draft/2020-12/schema"