refactor: format file with ruff
This commit is contained in:
+11
-13
@@ -8,7 +8,7 @@ from renderer.fifty_ohm_html_renderer import FiftyOhmHtmlRenderer
|
|||||||
|
|
||||||
|
|
||||||
def parse_katalog():
|
def parse_katalog():
|
||||||
with open('data/fragenkatalog3b.json') as fragenkatalog_file:
|
with open("data/fragenkatalog3b.json") as fragenkatalog_file:
|
||||||
fragenkatalog = json.load(fragenkatalog_file)
|
fragenkatalog = json.load(fragenkatalog_file)
|
||||||
|
|
||||||
questions = {}
|
questions = {}
|
||||||
@@ -25,13 +25,15 @@ def parse_katalog():
|
|||||||
|
|
||||||
return questions
|
return questions
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/html'))
|
|
||||||
question_template = env.get_template('question.html')
|
env = Environment(loader=FileSystemLoader("templates/html"))
|
||||||
|
question_template = env.get_template("question.html")
|
||||||
questions = parse_katalog()
|
questions = parse_katalog()
|
||||||
|
|
||||||
|
|
||||||
def question_stub(input):
|
def question_stub(input):
|
||||||
"""Combines the original question dataset from BNetzA with our internal metadata"""
|
"""Combines the original question dataset from BNetzA with our internal metadata"""
|
||||||
with open('data/metadata.json') as metadata_file :
|
with open("data/metadata.json") as metadata_file:
|
||||||
metadata = json.load(metadata_file)
|
metadata = json.load(metadata_file)
|
||||||
number = metadata[f"{input}"]["number"] # Fragennummer z.B. AB123
|
number = metadata[f"{input}"]["number"] # Fragennummer z.B. AB123
|
||||||
|
|
||||||
@@ -39,12 +41,7 @@ def question_stub(input):
|
|||||||
metadata = metadata[f"{input}"]
|
metadata = metadata[f"{input}"]
|
||||||
|
|
||||||
if "answer_a" in question:
|
if "answer_a" in question:
|
||||||
answers = [
|
answers = [question["answer_a"], question["answer_b"], question["answer_c"], question["answer_d"]]
|
||||||
question["answer_a"],
|
|
||||||
question["answer_b"],
|
|
||||||
question["answer_c"],
|
|
||||||
question["answer_d"]
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
answers = []
|
answers = []
|
||||||
|
|
||||||
@@ -53,7 +50,7 @@ def question_stub(input):
|
|||||||
metadata["picture_a"],
|
metadata["picture_a"],
|
||||||
metadata["picture_b"],
|
metadata["picture_b"],
|
||||||
metadata["picture_c"],
|
metadata["picture_c"],
|
||||||
metadata["picture_d"]
|
metadata["picture_d"],
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
answer_pictures = []
|
answer_pictures = []
|
||||||
@@ -69,9 +66,10 @@ def question_stub(input):
|
|||||||
layout=metadata["layout"],
|
layout=metadata["layout"],
|
||||||
picture_question=picture_question,
|
picture_question=picture_question,
|
||||||
answers=answers,
|
answers=answers,
|
||||||
answer_pictures=answer_pictures
|
answer_pictures=answer_pictures,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_html(capsys):
|
def test_html(capsys):
|
||||||
with capsys.disabled():
|
with capsys.disabled():
|
||||||
with open("test/acceptanceTest.md") as file:
|
with open("test/acceptanceTest.md") as file:
|
||||||
@@ -79,5 +77,5 @@ def test_html(capsys):
|
|||||||
with FiftyOhmHtmlRenderer(question_stub) as renderer:
|
with FiftyOhmHtmlRenderer(question_stub) as renderer:
|
||||||
output = renderer.render(Document(content))
|
output = renderer.render(Document(content))
|
||||||
with open("test/acceptanceTest.html", "w") as output_file:
|
with open("test/acceptanceTest.html", "w") as output_file:
|
||||||
pretty = BeautifulSoup(output, 'html.parser').prettify()
|
pretty = BeautifulSoup(output, "html.parser").prettify()
|
||||||
output_file.write(pretty)
|
output_file.write(pretty)
|
||||||
|
|||||||
Reference in New Issue
Block a user