From 8a4f18a7f08612bce83f5c69f7157645afd1943c Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Tue, 29 Apr 2025 18:49:45 +0200
Subject: [PATCH] REFACTOR: Documentation and small changes.

---
 CHANGELOG.md                                               | 7 +++++--
 src/caosadvancedtools/table_json_conversion/fill_xlsx.py   | 2 +-
 .../table_json_conversion/table_generator.py               | 2 +-
 unittests/table_json_conversion/utils.py                   | 5 -----
 4 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index dc465d78..2d6b41c8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,9 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Added ###
 
-- Added table_json_conversion.export_import_xlsx with a public function
-  export_container_to_xlsx, which exports the data of a given Entity
+- Added `table_json_conversion.export_import_xlsx` with a public function
+  `export_container_to_xlsx`, which exports the data of a given Entity
   Container to a XLSX file.
+- Added parameters to the JsonSchemaExporter to
+  - add `id` property to all RecordTypes
+  - guess when a reference property probably should be treated like an enum.
 
 ### Changed ###
 
diff --git a/src/caosadvancedtools/table_json_conversion/fill_xlsx.py b/src/caosadvancedtools/table_json_conversion/fill_xlsx.py
index b47dd56f..005742f0 100644
--- a/src/caosadvancedtools/table_json_conversion/fill_xlsx.py
+++ b/src/caosadvancedtools/table_json_conversion/fill_xlsx.py
@@ -376,7 +376,7 @@ validation_schema: dict, optional
     template_filler = TemplateFiller(result_wb, graceful=(validation_schema is None))
     template_filler.fill_data(data=data)
 
-    if isinstance(result, str):
+    if not isinstance(result, Path):
         result = Path(result)
     result.parent.mkdir(parents=True, exist_ok=True)
     result_wb.save(result)
diff --git a/src/caosadvancedtools/table_json_conversion/table_generator.py b/src/caosadvancedtools/table_json_conversion/table_generator.py
index 4a5fcd85..17ed5dac 100644
--- a/src/caosadvancedtools/table_json_conversion/table_generator.py
+++ b/src/caosadvancedtools/table_json_conversion/table_generator.py
@@ -331,7 +331,7 @@ class XLSXTemplateGenerator(TableTemplateGenerator):
         sheets = self._generate_sheets_from_schema(schema, foreign_keys,
                                                    use_ids_as_foreign=use_ids_as_foreign)
         wb = self._create_workbook_from_sheets_def(sheets)
-        if isinstance(filepath, str):
+        if not isinstance(filepath, Path):
             filepath = Path(filepath)
         parentpath = filepath.parent
         parentpath.mkdir(parents=True, exist_ok=True)
diff --git a/unittests/table_json_conversion/utils.py b/unittests/table_json_conversion/utils.py
index aa6b6842..0134c062 100644
--- a/unittests/table_json_conversion/utils.py
+++ b/unittests/table_json_conversion/utils.py
@@ -43,11 +43,6 @@ allow_name_dict: bool, default=False
     """
     if path is None:
         path = []
-
-    # if allow_name_dict:
-    #     if ((isinstance(json1, str) and isinstance(json2, dict)) or
-    #             (isinstance(json2, str) and isinstance(json1, dict))):
-    #         breakpoint()
     assert isinstance(json1, dict) == isinstance(json2, dict), f"Type mismatch, path: {path}"
     if isinstance(json1, dict):
         keys = set(json1.keys()).union(json2.keys())
-- 
GitLab