Skip to content

Commit

Permalink
Generate quiz-output.html if there's exactly one version
Browse files Browse the repository at this point in the history
  • Loading branch information
kezsulap committed Oct 12, 2024
1 parent 8fb7353 commit 4769262
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,20 @@ def main():
content.append(escape(get_file(filename, content_branch)))
output = '[' + ','.join(content) + ']'

index = get_file('index.html', from_branch)
with open('output.html', 'w') as output_file:
index = index.replace('resources', 'resources_main').replace('hardcoded=undefined', 'hardcoded=' + output);
print(index, file=output_file)
to_process = [['index.html', 'output.html']]
if len(content) == 1:
to_process.append(['quiz.html', 'quiz-output.html'])
else:
try:
os.remove('quiz-output.html')
except FileNotFoundError:
pass

for input_name, output_name in to_process:
content = get_file(input_name, from_branch)
with open(output_name, 'w') as output_file:
content = content.replace('resources', 'resources_main').replace('hardcoded=undefined', 'hardcoded=' + output);
print(content, file=output_file)
subprocess.run(['rm', '-rf', 'resources_main'])
os.mkdir('resources_main')
for dirname in get_file('resources/all_directories_list', from_branch).split('\n'):
Expand Down

0 comments on commit 4769262

Please sign in to comment.