Skip to content
Snippets Groups Projects
Verified Commit 78da958b authored by Daniel Hornung's avatar Daniel Hornung
Browse files

WIP: Validating to_dict result.

parent 8ce04d88
No related branches found
No related tags found
No related merge requests found
...@@ -707,10 +707,8 @@ def _set_in_nested(mydict: dict, path: list, value: Any, prefix: list = [], skip ...@@ -707,10 +707,8 @@ def _set_in_nested(mydict: dict, path: list, value: Any, prefix: list = [], skip
return mydict return mydict
# ToDo: Fix https://gitlab.indiscale.com/caosdb/src/caosdb-advanced-user-tools/-/issues/138
# and remove pylint disable
def to_dict(xlsx: Union[str, BinaryIO], schema: Union[dict, str, TextIO], def to_dict(xlsx: Union[str, BinaryIO], schema: Union[dict, str, TextIO],
validate: bool = None, strict: bool = False) -> dict: # pylint: disable=unused-argument validate: bool = False, strict: bool = False) -> dict:
"""Convert the xlsx contents to a dict, it must follow a schema. """Convert the xlsx contents to a dict, it must follow a schema.
Parameters Parameters
...@@ -722,10 +720,10 @@ def to_dict(xlsx: Union[str, BinaryIO], schema: Union[dict, str, TextIO], ...@@ -722,10 +720,10 @@ def to_dict(xlsx: Union[str, BinaryIO], schema: Union[dict, str, TextIO],
Schema for validation of XLSX content. Schema for validation of XLSX content.
validate: bool, optional validate: bool, optional
If True, validate the result against the schema. If True, validate the result against the schema. Default is False.
strict: bool, optional strict: bool, optional
If True, fail faster. If True, fail faster. Default is False.
Returns Returns
...@@ -734,4 +732,4 @@ def to_dict(xlsx: Union[str, BinaryIO], schema: Union[dict, str, TextIO], ...@@ -734,4 +732,4 @@ def to_dict(xlsx: Union[str, BinaryIO], schema: Union[dict, str, TextIO],
A dict representing the JSON with the extracted data. A dict representing the JSON with the extracted data.
""" """
converter = XLSXConverter(xlsx, schema, strict=strict) converter = XLSXConverter(xlsx, schema, strict=strict)
return converter.to_dict() return converter.to_dict(validate=validate)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment