Skip to content
Snippets Groups Projects

ENH: xlsx template generator

Merged Henrik tom Wörden requested to merge f-xlsx-json into f-more-jsonschema-export
2 unresolved threads
1 file
+ 4
4
Compare changes
  • Side-by-side
  • Inline
@@ -28,7 +28,7 @@ import sys
from abc import ABC, abstractmethod
from argparse import RawTextHelpFormatter
from enum import Enum
from typing import Union
from typing import Dict, List, Tuple, Union
from openpyxl import Workbook
from openpyxl.workbook.child import INVALID_TITLE_REGEX
@@ -74,7 +74,7 @@ class TableTemplateGenerator(ABC):
pass
def _generate_sheets_from_schema(self, schema: dict, foreign_keys: dict = None
) -> dict[str, dict[str, list]]:
) -> Dict[str, Dict[str, list]]:
""" generates a sheet definition from a given JSON schema
Parameters
@@ -104,7 +104,7 @@ class TableTemplateGenerator(ABC):
foreign_keys = {}
# here, we treat the top level
# sheets[sheetname][colname]= (COL_TYPE, description, [path])
sheets: dict[str, dict[str, tuple[str, list]]] = {}
sheets: Dict[str, dict[str, Tuple[str, list]]] = {}
if "properties" not in schema:
raise ValueError("Inappropriate JSON schema: The following part should contain "
f"the 'properties' key:\n{schema}\n")
@@ -141,7 +141,7 @@ class TableTemplateGenerator(ABC):
def _treat_schema_element(self, schema: dict, sheets: dict = None, path: list = None,
foreign_keys: dict = None, level_in_sheet_name: int = 1,
array_paths: list = None
) -> dict[str, tuple[str, str, list]]:
) -> Dict[str, Tuple[str, str, list]]:
""" recursively transforms elements from the schema into column definitions
sheets is modified in place.
Loading