-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflashdeck.py
More file actions
98 lines (88 loc) · 2.44 KB
/
flashdeck.py
File metadata and controls
98 lines (88 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import argparse
import logging
import json
import pathlib
letters = [
("α", "alpha (lowercase)"),
("β", "beta (lowercase)"),
("γ", "gamma (lowercase)"),
("δ", "delta (lowercase)"),
("ε", "epsilon (lowercase)"),
("ζ", "zeta (lowercase)"),
("η", "eta (lowercase)"),
("θ", "theta (lowercase)"),
("ι", "iota (lowercase)"),
("κ", "kappa (lowercase)"),
("λ", "lambda (lowercase)"),
("μ", "mu (lowercase)"),
("ν", "nu (lowercase)"),
("ξ", "xi (lowercase)"),
("ο", "omicron (lowercase)"),
("π", "pi (lowercase)"),
("ρ", "rho (lowercase)"),
("σ", "sigma (lowercase)"),
("τ", "tau (lowercase)"),
("υ", "upsilon (lowercase)"),
("φ", "phi (lowercase)"),
("χ", "chi (lowercase)"),
("ψ", "psi (lowercase)"),
("ω", "omega (lowercase)"),
("Α", "alpha (uppercase)"),
("Β", "beta (uppercase)"),
("Γ", "gamma (uppercase)"),
("Δ", "delta (uppercase)"),
("Ε", "epsilon (uppercase)"),
("Ζ", "zeta (uppercase)"),
("Η", "eta (uppercase)"),
("Θ", "theta (uppercase)"),
("Ι", "iota (uppercase)"),
("Κ", "kappa (uppercase)"),
("Λ", "lambda (uppercase)"),
("Μ", "mu (uppercase)"),
("Ν", "nu (uppercase)"),
("Ξ", "xi (uppercase)"),
("Ο", "omicron (uppercase)"),
("Π", "pi (uppercase)"),
("Ρ", "rho (uppercase)"),
("Σ", "sigma (uppercase)"),
("Τ", "tau (uppercase)"),
("Υ", "upsilon (uppercase)"),
("Φ", "phi (uppercase)"),
("Χ", "chi (uppercase)"),
("Ψ", "psi (uppercase)"),
("Ω", "omega (uppercase)"),
]
def main():
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("infile")
arg_parser.add_argument("outfile")
args = arg_parser.parse_args()
del arg_parser
input_path = pathlib.Path(args.infile)
output_path = pathlib.Path(args.outfile)
del args
logging.info("Reading %s", input_path)
with input_path.open("rb") as f:
data = json.load(f)
if len(data) != 1:
raise Exception(f"len(data) should be 1, but got {len(data)}")
cardlist = []
nextId = 0
for (letter, letter_name) in letters:
nextId += 1
cardlist.append({
"id": nextId,
"deckId": 1,
"ordinal": nextId,
"question": letter,
"questionImage": "",
"questionVoice": "",
"answer": letter_name,
"answerImage": "",
})
data[0]["cardList"] = cardlist
logging.info("Writing %s", output_path)
with output_path.open("wt", encoding="utf8") as f:
json.dump(data, f, indent=2)
if __name__ == "__main__":
main()