-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script the translation of safety check questions from Excel
- Loading branch information
1 parent
94f189e
commit 051bb38
Showing
15 changed files
with
230 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import csv | ||
|
||
# Manually copy from Excel, naming the columns "Metric Mode ID Description | ||
# Critical Red Amber Green" (with tabs). This is a one-off script; the source | ||
# of truth becomes the Svelte files, which need to be manually edited to | ||
# improve formatting. | ||
with open("safety_check.tsv") as tsv: | ||
idx = 0 | ||
for row in csv.DictReader(tsv, delimiter=" "): | ||
with open(row["ID"].lower() + "/+page.svelte", "w") as f: | ||
f.write("""<script lang="ts">\n""") | ||
f.write("""import Question from "../Question.svelte";\n""") | ||
f.write("""</script>\n""") | ||
f.write("""\n""") | ||
|
||
f.write("""<Question\n""") | ||
f.write(" idx={" + str(idx) + "}\n") | ||
f.write(""" label="{}"\n""".format(row["Metric"])) | ||
|
||
f.write(""" cases={[\n""") | ||
f.write(""" ["C", "{}"],\n""".format(row["Critical"])) | ||
f.write(""" ["0", "{}"],\n""".format(row["Red"])) | ||
f.write(""" ["1", "{}"],\n""".format(row["Amber"])) | ||
f.write(""" ["2", "{}"],\n""".format(row["Green"])) | ||
f.write(""" ]}\n""") | ||
f.write(""">\n""") | ||
|
||
f.write(""" <p>{}</p>\n""".format(row["Description"])) | ||
f.write("""</Question>\n""") | ||
idx += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.