Formats JSON output from yorku-class-scraper to a LaTeX timetable PDF.
- What is this?
- Requirements
- Installation
- Running the Program
- Arguments
- Files in this Repository
- Donate
This program inputs a JSON file generated by
yorku-class-scraper,
and the building and room you are looking for. This will output a LaTeX tex
file that has the entire week's schedule of that class.
It's a separate program because if anyone wants to make something out of just yorku-class-scraper, they can (without all of this LaTeX conversion in this program).
To install this program, you have to clone this git repository and download the required libraries as well. Instructions below.
:note: This assumes you already have python3 installed.
git clone https://github.com/hussein-esmail7/yorku-scheduler
cd yorku-scheduler/
pip install configparser
Since this program outputs a .tex
file, it's recommended that you do use some
compiler for LaTeX to PDF. You can paste your file into https://overleaf.com/
to compile it online easily, but for an offline mode of compilation, I use
pdflatex
.
To use this program, you have to make sure you are in the correct directory
(using the cd
command).
python3 yorku-scheduler.py <args>
Here are possible arguments you can call in Terminal:
-h, --help --> Help message and exit program.
-j, --json --> Input the JSON path as a string.
-o, --output --> Input the output file name as a string.
-r, --room --> Input the room as a string.
-s, --sem, --semester --> Input the semester you want as a string.
-q, --quiet --> Quiet mode. Only display text when required.
Example:
python3 yorku-scheduler.py -j "../yorku-class-scraper/json/su_2022_all.json" -r "db 0011" -o "test2.tex" -q -s "SU"
This program outputs a .tex
LaTeX file. There are multiple ways of comverting this to PDF:
- Use an online compiler like Overleaf after the program runs.
- Make a script that can run right after this program if you pass the file path of it to the
PATH_POST_SCRIPT
variable in your config file.
yorku_scheduler.py
: Main Python program that is run.timetable.tex
: Template file thatyorku_scheduler.py
uses to make its final output file.
This section is the arguments you can put into your configuration file at
~/.config/yorku-scheduler/config
[Default]
ITEM_TITLE={c} {n} {a}
ITEM_SUBTITLE={t} {s}
COLOR_BG_LECT=pink
COLOR_BG_ELSE=lightgray
COLOR_FG_LECT=black
COLOR_FG_ELSE=black
PATH_POST_SCRIPT=
PATH_TEMPLATE=./timetable.tex
ITEM_TITLE={c} {n} {a}
ITEM_SUBTITLE={t} {s}
Values above are the default values
Options:
{c}
: Course department ("EECS", "ADMS", etc.){n}
: Course number ("1001" from "EECS 1001"){a}
: Course section ("A", "B", "Z", etc.){t}
: Meeting Type ("LECT", "TUTR", "BLEN", "SEMR", etc.){s}
: Semester (if not the chosen one. Ex. If you chose "W", only shows "Y"){p}
: Professor full name{f}
: Professor first name{l}
: Professor last name{t}
: Professor last name\\
: New line
⚠️ If at any point the specified field isn't available in your JSON input file, the program will not add it instead of raising an error.
The colour codes in this program comes from the xcolor
package in LaTeX.
COLOR_BG_LECT=pink # Background colour for lectures
COLOR_BG_ELSE=lightgray # Background colour for everything else (TUTR, BLEN, etc.)
COLOR_FG_LECT=black # Foreground colour for lectures
COLOR_FG_ELSE=black # Foreground colour for everything else (TUTR, BLEN, etc.)
Values above are the default values
Available colours (only 1 per argument):
red
green
blue
cyan
magenta
yellow
black
gray
white
darkgray
lightgray
brown
lime
olive
orange
pink
purple
teal
violet
For more info about modifying your own template file to add more colour options, please go to this link at https://latex-tutorial.com.
This part of the configuration file lets you run another script after the
output .tex
file has been created. Personally, I have this set to my
c.sh
program that can
be found at my hussein-esmail7/sh/
repository. By default, this field is left empty.
PATH_POST_SCRIPT= # Post Script file location here (including arguments)
The Python program runs whatever is in the PATH_POST_SCRIPT
argument, then
lastly the file name of the .tex
file the program just outputted. Please do
not put quotation marks in this argument even if there are spaces in your
command.
Example:
PATH_POST_SCRIPT=python3 compile.py --latex
What is actually run (where output.tex
was made by this program):
python3 compile.py --latex output.tex
You can decide what template file this program uses. By default, it's the
timetable.tex
file in this repository, but you can set a different file location. The rest of
this section explains what this program looks for in that file so that it works
properly (you can skip it if you're not planning on changing the template
file).
PATH_TEMPLATE=./timetable.tex
The
timetable.tex
uses the schedule
LaTeX package that generates calendar items.
With the schedule
package, you can create different appointment types. This program uses LECT
and ELSE
(which are where the colour codes are also used). The format the program types these commands are as follows:
\LECT{Line 1}{Line 2}{Day}{Start Time-End Time}
\ELSE{Line 1}{Line 2}{Day}{Start Time-End Time}
When the program adds lines, it adds them between the lines that say "[CLASSES START]
" and "[CLASSES END]
"
Wherever the program sees "[COLOR_BG_LECT]
", "[COLOR_BG_ELSE]
",
"[COLOR_FG_LECT]
", or "[COLOR_FG_ELSE]
", it replaces those strings
(including the square brackets) with the respective colour found in the config
file.