forked from PrairieLearn/PrairieLearn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_tex_images.py
executable file
·33 lines (28 loc) · 1.02 KB
/
make_tex_images.py
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
#!/usr/bin/env python
import os.path, sys, re, subprocess
if not os.path.exists("backend/config.json"):
print("ERROR: no config.json file found")
sys.exit(1)
dir_list = []
print("Reading backend/config.json")
with open("backend/config.json") as config_file:
for line in config_file:
for pattern in [
'"questionsDir" *: *\"([^"]*)\"',
'"clientCodeDir" *: *\"([^"]*)\"',
]:
match = re.search(pattern, line)
if match:
dir_name = match.group(1)
if not os.path.isabs(dir_name):
dir_name = os.path.join("backend", dir_name)
dir_list.append(dir_name)
if len(dir_list) <= 0:
print("ERROR: Unable to determine any directories from config.json")
sys.exit(1)
print("Directories to process for tex images:")
for dir_name in dir_list:
print(dir_name)
args = ["python", "tool/generate_text.py", "frontend/text"] + dir_list
print("Running command: %s" % " ".join(args))
subprocess.call(args)