diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-04-05 16:39:10 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-04-05 16:39:10 +0200 |
| commit | bba0994ffbce3016d4038504370a953812aefd15 (patch) | |
| tree | 1483c55729fd03f02eafc40a9fc8ac413299031f /lessons.py | |
| parent | 6c9cbaf8aa1915dcb3158d8ae856dab0d15b19e6 (diff) | |
| download | avail-lessons-bba0994ffbce3016d4038504370a953812aefd15.tar.gz avail-lessons-bba0994ffbce3016d4038504370a953812aefd15.zip | |
add line formatting for events
I want to color a table row in a certain color if a early end of class
causes my lesson to be canceled.
To do so I use the new configuration table:
```toml
[event_line_formats]
Unterrichtsschluss = '\\rowcolor{{red!30}} {line}'```
Diffstat (limited to 'lessons.py')
| -rwxr-xr-x | lessons.py | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -93,15 +93,21 @@ def format_period(period: webuntis.objects.PeriodObject, # strip the leading ' ' and trailing ' |' period_events = period_events[1:-2] - output = config.get( + fmt = config.get( 'fmt') or '{week} {date.strftime(\'%d.%m\')} {period_events}' # Using eval here instead of string.format() is potentially dangerous. # However, I do not consider this an actual thread because this is an # obscure script run with only trusted inputs (cli arguments, manual written # config), therefore potential code execution is not a real concern. - output = eval(F'f"{output}"') # pylint: disable=eval-used + line = eval('f' + f'"{fmt}"') # pylint: disable=eval-used - return output + # Apply event_line_formats + event_line_formats = config.get('event_line_formats', []) + for ev in period_evs: + if ev.summary in event_line_formats: + line = eval('f' + f'"{event_line_formats[ev.summary]}"') + + return line def filter_periods(timetable: webuntis.objects.PeriodList, |
