Skip to content
Snippets Groups Projects
Commit 6b3289d9 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

wip

parent f62037c1
No related branches found
No related tags found
4 merge requests!100WIP: Filling XLSX: Seems to be working.,!94ENH: add framework for converting json schema into table templates,!93Filling XLSX: Everything except multiple choice.,!92ENH: xlsx template generator
...@@ -31,7 +31,8 @@ def _fill_leaves(json_doc: dict, workbook): ...@@ -31,7 +31,8 @@ def _fill_leaves(json_doc: dict, workbook):
for el in value: for el in value:
if isinstance(el, dict): if isinstance(el, dict):
_fill_leaves(el, workbook) _fill_leaves(el, workbook)
wb.cell(1,2, el) wb.cell(1, 2, el)
def _get_row_type_column(worksheet): def _get_row_type_column(worksheet):
for col in worksheet.columns: for col in worksheet.columns:
...@@ -40,6 +41,7 @@ def _get_row_type_column(worksheet): ...@@ -40,6 +41,7 @@ def _get_row_type_column(worksheet):
return cell.column return cell.column
raise ValueError("The column which defines row types (COL_TYPE, PATH, ...) is missing") raise ValueError("The column which defines row types (COL_TYPE, PATH, ...) is missing")
def _get_path_rows(worksheet): def _get_path_rows(worksheet):
rows = [] rows = []
rt_col = _get_row_type_column(worksheet) rt_col = _get_row_type_column(worksheet)
...@@ -50,7 +52,6 @@ def _get_path_rows(worksheet): ...@@ -50,7 +52,6 @@ def _get_path_rows(worksheet):
return rows return rows
def _generate_path_col_mapping(workbook): def _generate_path_col_mapping(workbook):
rt_col = _get_row_type_column(workbook) rt_col = _get_row_type_column(workbook)
...@@ -58,7 +59,7 @@ def _generate_path_col_mapping(workbook): ...@@ -58,7 +59,7 @@ def _generate_path_col_mapping(workbook):
pass 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 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``. ``template_path`` and store the result under ``result_path``.
......
...@@ -30,15 +30,16 @@ import tomli ...@@ -30,15 +30,16 @@ import tomli
# TODO why do I need a running LA instance? # TODO why do I need a running LA instance?
def prepare_datamodel(): def prepare_datamodel():
model = parser.parse_model_from_yaml("./model.yml") model = parser.parse_model_from_yaml("./model.yml")
exporter = jsex.JsonSchemaExporter(additional_properties=False, exporter = jsex.JsonSchemaExporter(additional_properties=False,
#additional_options_for_text_props=additional_text_options, # additional_options_for_text_props=additional_text_options,
#name_and_description_in_properties=True, # name_and_description_in_properties=True,
name_property_for_new_records=True, name_property_for_new_records=True,
#do_not_create=do_not_create, do_not_create=["Organisation"],
#do_not_retrieve=do_not_retrieve, # do_not_retrieve=do_not_retrieve,
) )
schema_top = exporter.recordtype_to_json_schema(model.get_deep("Training")) schema_top = exporter.recordtype_to_json_schema(model.get_deep("Training"))
schema_pers = exporter.recordtype_to_json_schema(model.get_deep("Person")) schema_pers = exporter.recordtype_to_json_schema(model.get_deep("Person"))
......
...@@ -53,19 +53,29 @@ ...@@ -53,19 +53,29 @@
"type": "string" "type": "string"
}, },
"Organisation": { "Organisation": {
"type": "object", "oneOf": [
"required": [], {
"additionalProperties": false, "title": "Existing entries",
"title": "Organisation", "enum": [
"properties": { "Federal Reserve"
"name": { ]
"type": "string",
"description": "The name of the Record to be created"
}, },
"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 @@ ...@@ -87,19 +97,29 @@
"type": "string" "type": "string"
}, },
"Organisation": { "Organisation": {
"type": "object", "oneOf": [
"required": [], {
"additionalProperties": false, "title": "Existing entries",
"title": "Organisation", "enum": [
"properties": { "Federal Reserve"
"name": { ]
"type": "string",
"description": "The name of the Record to be created"
}, },
"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 @@ ...@@ -132,19 +152,29 @@
"type": "string" "type": "string"
}, },
"Organisation": { "Organisation": {
"type": "object", "oneOf": [
"required": [], {
"additionalProperties": false, "title": "Existing entries",
"title": "Organisation", "enum": [
"properties": { "Federal Reserve"
"name": { ]
"type": "string",
"description": "The name of the Record to be created"
}, },
"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" "$schema": "https://json-schema.org/draft/2020-12/schema"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment