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

REFACTOR: Linting, PEPping, styling, docs.

parent 9307d8fe
No related branches found
No related tags found
2 merge requests!138Release 0.14.0,!132Automatic XLSX export
Pipeline #62643 passed
...@@ -124,8 +124,8 @@ class JsonSchemaExporter: ...@@ -124,8 +124,8 @@ class JsonSchemaExporter:
that the exporter may fail if this option is activated and the data model is not that the exporter may fail if this option is activated and the data model is not
self-sufficient. self-sufficient.
use_rt_pool : models.data_model.DataModel, optional use_rt_pool : models.data_model.DataModel, optional
If given, do not attempt to retrieve RecordType information remotely but from this parameter If given, do not attempt to retrieve RecordType information remotely but from this
instead. parameter instead.
multiple_choice : list[str], optional multiple_choice : list[str], optional
A list of reference Property names which shall be denoted as multiple choice properties. A list of reference Property names which shall be denoted as multiple choice properties.
This means that each option in this property may be selected at most once. This is not This means that each option in this property may be selected at most once. This is not
...@@ -341,7 +341,8 @@ ui_schema : dict ...@@ -341,7 +341,8 @@ ui_schema : dict
rt = db.Entity() rt = db.Entity()
if isinstance(rt, str): if isinstance(rt, str):
raise NotImplementedError("Behavior is not implemented when _no_remote == True and datatype is given as a string.") raise NotImplementedError("Behavior is not implemented when _no_remote == "
"True and datatype is given as a string.")
subschema, ui_schema = self._make_segment_from_recordtype(rt) subschema, ui_schema = self._make_segment_from_recordtype(rt)
if prop.is_reference(): if prop.is_reference():
......
...@@ -25,7 +25,7 @@ import json ...@@ -25,7 +25,7 @@ import json
import tempfile import tempfile
import warnings import warnings
import logging import logging
from typing import Union from typing import Optional, Union
from pathlib import Path from pathlib import Path
import linkahead import linkahead
...@@ -44,7 +44,7 @@ logging.disable(logging.NOTSET) ...@@ -44,7 +44,7 @@ logging.disable(logging.NOTSET)
def _generate_jsonschema_from_recordtypes(recordtypes: list, def _generate_jsonschema_from_recordtypes(recordtypes: list,
out_path: Union[str, Path] = None) -> dict: out_path: Optional[Union[str, Path]] = None) -> dict:
""" """
Generate a combined jsonschema for all given recordtypes. Generate a combined jsonschema for all given recordtypes.
...@@ -52,7 +52,7 @@ def _generate_jsonschema_from_recordtypes(recordtypes: list, ...@@ -52,7 +52,7 @@ def _generate_jsonschema_from_recordtypes(recordtypes: list,
---------- ----------
recordtypes : Iterable recordtypes : Iterable
List of RecordType entities for which a schema should be generated. List of RecordType entities for which a schema should be generated.
out_path : str, Path out_path : str or Path, optional
If given, the resulting jsonschema will also be written to the file If given, the resulting jsonschema will also be written to the file
given by out_path. given by out_path.
Optional, default None Optional, default None
...@@ -78,7 +78,7 @@ def _generate_jsonschema_from_recordtypes(recordtypes: list, ...@@ -78,7 +78,7 @@ def _generate_jsonschema_from_recordtypes(recordtypes: list,
def _generate_jsondata_from_records(records: Container, def _generate_jsondata_from_records(records: Container,
out_path: Union[str, Path] = None) -> dict: out_path: Optional[Union[str, Path]] = None) -> dict:
""" """
Extract relevant information (id, name, properties, etc.) from the given Extract relevant information (id, name, properties, etc.) from the given
records and converts this information to json. records and converts this information to json.
...@@ -87,7 +87,7 @@ def _generate_jsondata_from_records(records: Container, ...@@ -87,7 +87,7 @@ def _generate_jsondata_from_records(records: Container,
---------- ----------
records : Iterable records : Iterable
List of Record entities from which the data will be converted to json. List of Record entities from which the data will be converted to json.
out_path : str, Path out_path : str or Path, optional
If given, the resulting jsondata will also be written to the file given If given, the resulting jsondata will also be written to the file given
by out_path. by out_path.
Optional, default None Optional, default None
......
...@@ -331,7 +331,7 @@ to_insert: Optional[dict[str, str]] ...@@ -331,7 +331,7 @@ to_insert: Optional[dict[str, str]]
def fill_template(data: Union[dict, str, TextIO], template: str, result: str, def fill_template(data: Union[dict, str, TextIO], template: str, result: str,
validation_schema: Union[dict, str, TextIO] = None) -> None: validation_schema: Optional[Union[dict, str, TextIO]] = None) -> None:
"""Insert json data into an xlsx file, according to a template. """Insert json data into an xlsx file, according to a template.
This function fills the json data into the template stored at ``template`` and stores the result as This function fills the json data into the template stored at ``template`` and stores the result as
...@@ -355,6 +355,9 @@ validation_schema: dict, optional ...@@ -355,6 +355,9 @@ validation_schema: dict, optional
# Validation # Validation
if validation_schema is not None: if validation_schema is not None:
validation_schema = read_or_dict(validation_schema)
assert isinstance(validation_schema, dict)
# convert to array_schema if given schema is a model_schema # convert to array_schema if given schema is a model_schema
if 'properties' in validation_schema and validation_schema['properties'].values(): if 'properties' in validation_schema and validation_schema['properties'].values():
if list(validation_schema['properties'].values())[0]["type"] != "array": if list(validation_schema['properties'].values())[0]["type"] != "array":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment