Skip to content
Snippets Groups Projects

Draft: Automatic XLSX export

Open I. Nüske requested to merge f-enh-143-automatic-xlsx-exporting into dev
12 unresolved threads
1 file
+ 1
1
Compare changes
  • Side-by-side
  • Inline
@@ -24,15 +24,16 @@ from __future__ import annotations
import datetime
import pathlib
import warnings
from types import SimpleNamespace
from typing import Any, Optional, TextIO, Union
from warnings import warn
from jsonschema import FormatChecker, validate
from jsonschema.exceptions import ValidationError
from openpyxl import load_workbook, Workbook
from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE
from .validation_utils import _validate_jsonschema
from .xlsx_utils import (
array_schema_from_model_schema,
get_foreign_key_columns,
@@ -354,15 +355,17 @@ validation_schema: dict, optional
# Validation
if validation_schema is not None:
validation_schema = array_schema_from_model_schema(read_or_dict(validation_schema))
# convert to array_schema if given schema is a model_schema
if 'properties' in validation_schema and validation_schema['properties'].values():
if list(validation_schema['properties'].values())[0]["type"] != "array":
validation_schema = array_schema_from_model_schema(read_or_dict(validation_schema))
try:
# FIXME redefine checker for datetime
validate(data, validation_schema, format_checker=FormatChecker())
_validate_jsonschema(data, validation_schema)
Please register or sign in to reply
except ValidationError as verr:
print(verr.message)
raise verr
else:
print("No validation schema given, continue at your own risk.")
warnings.warn("No validation schema given, continue at your own risk.")
    • Comment on lines -365 to +368
      Author Maintainer

      Changed to warnings.warn for filtering, and because the warnings in these files generally are done with warnings.warn. Should these also be replaced with logs?

Please register or sign in to reply
# Filling the data
result_wb = load_workbook(template)
Loading