From c0e72a5ca01a3a60d8b5acca8f04fbfa1029e5af Mon Sep 17 00:00:00 2001 From: dymik739 Date: Sat, 6 Apr 2024 17:38:28 +0300 Subject: [PATCH] auto-schedule-pro-v2: add support for reading comments from schedule-v2 file format --- modules/auto-schedule-pro-v2/main.py | 12 ++++++++++++ .../templates/legacy-vibrant/comment.msg | 1 + .../templates/legacy/comment.msg | 1 + .../templates/modern/comment.msg | 1 + 4 files changed, 15 insertions(+) create mode 100644 modules/auto-schedule-pro-v2/templates/legacy-vibrant/comment.msg create mode 100644 modules/auto-schedule-pro-v2/templates/legacy/comment.msg create mode 100644 modules/auto-schedule-pro-v2/templates/modern/comment.msg diff --git a/modules/auto-schedule-pro-v2/main.py b/modules/auto-schedule-pro-v2/main.py index 50298e5..672b5e5 100644 --- a/modules/auto-schedule-pro-v2/main.py +++ b/modules/auto-schedule-pro-v2/main.py @@ -184,6 +184,10 @@ def generate_lesson_description(lesson, start_datetime, end_datetime, current_da total_result = total_result.replace("%TYPE%", get_name_of_lesson_type(lesson['type'])) total_result = total_result.replace("%NAME_PREFIX%", custom_name_prefix) + if 'comment' in lesson: + total_result += load_template(template, "comment") + total_result = total_result.replace("%COMMENT%", lesson["comment"]) + return total_result + "\n" else: @@ -200,6 +204,10 @@ def generate_lesson_description(lesson, start_datetime, end_datetime, current_da active_template = active_template.replace("%TYPE%", get_name_of_lesson_type(lesson['type'])) active_template = active_template.replace("%NAME_PREFIX%", custom_name_prefix) + if 'comment' in lesson: + active_template += load_template(template, "comment") + active_template = active_template.replace("%COMMENT%", lesson["comment"]) + return active_template elif lesson.__class__ == list: @@ -218,6 +226,10 @@ def generate_lesson_description(lesson, start_datetime, end_datetime, current_da active_template = active_template.replace("%TYPE%", get_name_of_lesson_type(l['type'])) active_template = active_template.replace("%NAME_PREFIX%", custom_name_prefix) + if 'comment' in lesson: + total_result += load_template(template, "comment") + total_result = total_result.replace("%COMMENT%", lesson["comment"]) + total_result += active_template + "\n" return total_result diff --git a/modules/auto-schedule-pro-v2/templates/legacy-vibrant/comment.msg b/modules/auto-schedule-pro-v2/templates/legacy-vibrant/comment.msg new file mode 100644 index 0000000..3dc1f78 --- /dev/null +++ b/modules/auto-schedule-pro-v2/templates/legacy-vibrant/comment.msg @@ -0,0 +1 @@ +Коментар: %COMMENT% diff --git a/modules/auto-schedule-pro-v2/templates/legacy/comment.msg b/modules/auto-schedule-pro-v2/templates/legacy/comment.msg new file mode 100644 index 0000000..3e40f85 --- /dev/null +++ b/modules/auto-schedule-pro-v2/templates/legacy/comment.msg @@ -0,0 +1 @@ +Коментар: %COMMENT% diff --git a/modules/auto-schedule-pro-v2/templates/modern/comment.msg b/modules/auto-schedule-pro-v2/templates/modern/comment.msg new file mode 100644 index 0000000..29b280b --- /dev/null +++ b/modules/auto-schedule-pro-v2/templates/modern/comment.msg @@ -0,0 +1 @@ +Коментар: %COMMENT%