diff --git a/README.md b/README.md index 4a90db2..eb4201d 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,10 @@ A lecture file contains a line ``` which is the lecture number, date an title of the lecture. Date format is configurable in `config.py`. +#### `init-all-courses.py` + +This is the first file you should run, after creating the directory and the `info.yaml` file for each course. It creates all `master.tex` files. + #### `config.py` This is where you configure what calendar to use for the countdown script, the root folder of the file structure, and similar stuff. You can also configure the date format used in some places (lecture selection dialog and LaTeX files). diff --git a/scripts/init-all-courses.py b/scripts/init-all-courses.py new file mode 100644 index 0000000..f7397fb --- /dev/null +++ b/scripts/init-all-courses.py @@ -0,0 +1,20 @@ +#!/bin/python3 +from courses import Courses + +for course in Courses(): + lectures = course.lectures + course_title = lectures.course.info["title"] + lines = [r'\documentclass[a4paper]{article}', + r'\input{../preamble.tex}', + fr'\title{{{course_title}}}', + r'\begin{document}', + r' \maketitle', + r' \tableofcontents', + fr' % start lectures', + fr' % end lectures', + r'\end{document}' + ] + lectures.master_file.touch() + lectures.master_file.write_text('\n'.join(lines)) + (lectures.root / 'master.tex.latexmain').touch() + (lectures.root / 'figures').mkdir(exist_ok=True)