aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlessons.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/lessons.py b/lessons.py
index b29918d..10476c3 100755
--- a/lessons.py
+++ b/lessons.py
@@ -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,