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

STY: Enhanced styling

parent b18c5df8
No related branches found
No related tags found
2 merge requests!100WIP: Filling XLSX: Seems to be working.,!93Filling XLSX: Everything except multiple choice.
Pipeline #49062 failed
...@@ -36,8 +36,8 @@ unittest: ...@@ -36,8 +36,8 @@ unittest:
pytest-3 unittests pytest-3 unittests
style: style:
pycodestyle --count src unittests --exclude=swagger_client pycodestyle --count --exclude=swagger_client src unittests
autopep8 -ar --diff --exit-code --exclude swagger_client . autopep8 -ar --diff --exit-code --exclude swagger_client src unittests
.PHONY: style .PHONY: style
lint: lint:
......
...@@ -314,7 +314,7 @@ out: union[dict, None] ...@@ -314,7 +314,7 @@ out: union[dict, None]
else: else:
value = content[0] value = content[0]
if isinstance(value, str): if isinstance(value, str):
value = ILLEGAL_CHARACTERS_RE.sub("", value) value = ILLEGAL_CHARACTERS_RE.sub("", value)
path_str = p2s(path) path_str = p2s(path)
assert path_str not in insertables assert path_str not in insertables
insertables[path_str] = value insertables[path_str] = value
......
...@@ -208,13 +208,14 @@ class TableTemplateGenerator(ABC): ...@@ -208,13 +208,14 @@ class TableTemplateGenerator(ABC):
foreigns = self._get_foreign_keys(foreign_keys, array_path) foreigns = self._get_foreign_keys(foreign_keys, array_path)
if isinstance(foreigns, str): if isinstance(foreigns, str):
raise ValueError("Foreign keys must be a list of strings, but a single " raise ValueError("Foreign keys must be a list of strings, but a single "
"string was given:\n" "string was given:\n"
f"{array_path} -> {foreigns}") f"{array_path} -> {foreigns}")
for foreign in foreigns: for foreign in foreigns:
internal_key = p2s(array_path + [foreign]) internal_key = p2s(array_path + [foreign])
if internal_key in sheets[sheetname]: if internal_key in sheets[sheetname]:
raise ValueError("The schema would lead to two columns with the same " raise ValueError("The schema would lead to two columns with the same "
f"name, which is forbidden:\n{foreign} -> {internal_key}") "name, which is forbidden:\n"
f"{foreign} -> {internal_key}")
ref_sheet = p2s(array_path) ref_sheet = p2s(array_path)
sheets[sheetname][internal_key] = ( sheets[sheetname][internal_key] = (
ColumnType.FOREIGN, f"see sheet '{ref_sheet}'", array_path + [foreign]) ColumnType.FOREIGN, f"see sheet '{ref_sheet}'", array_path + [foreign])
......
...@@ -216,21 +216,21 @@ def test_template_generator(): ...@@ -216,21 +216,21 @@ def test_template_generator():
with open(rp) as sfi: with open(rp) as sfi:
schema = json.load(sfi) schema = json.load(sfi)
fk_path = os.path.join(di, "foreign_keys"+fi[len('schema'):]) fk_path = os.path.join(di, "foreign_keys"+fi[len('schema'):])
path =os.path.join(di, "template"+fi[len('schema'):-4]+"xlsx") path = os.path.join(di, "template"+fi[len('schema'):-4]+"xlsx")
allreadydone = [ alreadydone = [
"Präventionsmaßnahmen" , "Präventionsmaßnahmen",
"Beratungsstellen" , "Beratungsstellen",
"Schutzeinrichtungen", "Schutzeinrichtungen",
"Einzelfallversorgung" , "Einzelfallversorgung",
"Strategiedokumente" , "Strategiedokumente",
"Kooperationsvereinbarungen" , "Kooperationsvereinbarungen",
"Gremien" , "Gremien",
"Verwaltungsvorschriften" , "Verwaltungsvorschriften",
"Gewaltschutzkonzepte und -maßnahmen", "Gewaltschutzkonzepte und -maßnahmen",
"Polizeilicher Opferschutz", "Polizeilicher Opferschutz",
"Feedback", "Feedback",
] ]
if any([path.startswith("template_"+k) for k in allreadydone]): if any([path.startswith("template_"+k) for k in alreadydone]):
continue continue
if not os.path.exists(fk_path): if not os.path.exists(fk_path):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment