diff options
| -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, |
