From 68783a2d6118c367734d42700cfb423246943c75 Mon Sep 17 00:00:00 2001 From: Loïc Guégan Date: Sun, 27 Jul 2025 16:11:35 +0200 Subject: Minor changes --- infos.yaml | 5 ++- main.py | 139 +++++++++++++++++++++++++++++++------------------------------ 2 files changed, 75 insertions(+), 69 deletions(-) diff --git a/infos.yaml b/infos.yaml index 23ef1f1..66e377b 100644 --- a/infos.yaml +++ b/infos.yaml @@ -128,6 +128,7 @@ config: name_wrap: 15 # Line break will follow if names exceed this value format: "text" # Or html/json/csv/latex/mediawiki calendar: + hidden: no # Generate calendar or not? show_room: yes show_time: yes show_who: yes @@ -139,8 +140,10 @@ config: week: "Week {}" project: "Projects" slots: + hidden: no # Generate slots tables or not? show_room: yes - projects: + projects: # Generate projects deadline table or not? + hidden: no show_week: yes labels: start: "Project {} handout" diff --git a/main.py b/main.py index e089405..a04c279 100755 --- a/main.py +++ b/main.py @@ -138,76 +138,79 @@ for e in _i["events"]: events[e]["room"] = sem["slots"][_e["type"]][dayname]["room"] #### Gen semester calendar -d=getmonday(sem["start"]) -w=getweek(d) -while d<=sem["end"]: - if _ccal["min_col_width"]>0: - t = PrettyTable(min_width=_ccal["min_col_width"]) - else: - t = PrettyTable() - t.field_names = [_ccal["labels"]["week"].format(w), "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] - t.align[t.field_names[0]]="l" - if _ccal["show_date"]: - t.add_row(["", - formatday(getnextdayn(d, 0)), - formatday(getnextdayn(d, 1)), - formatday(getnextdayn(d, 2)), - formatday(getnextdayn(d, 3)), - formatday(getnextdayn(d, 4))],divider=True) - add_row(t,["", - formatevents(getnextdayn(d, 0)), - formatevents(getnextdayn(d, 1)), - formatevents(getnextdayn(d, 2)), - formatevents(getnextdayn(d, 3)), - formatevents(getnextdayn(d, 4))],True) - if _ccal["show_project"]: - add_row(t,[_ccal["labels"]["project"], - formatprojects(getnextdayn(d, 0)), - formatprojects(getnextdayn(d, 1)), - formatprojects(getnextdayn(d, 2)), - formatprojects(getnextdayn(d, 3)), - formatprojects(getnextdayn(d, 4))],False) - print(t.get_formatted_string(_c["format"])) - d=getnextmonday(d) - w+=1 - if d0: + t = PrettyTable(min_width=_ccal["min_col_width"]) + else: + t = PrettyTable() + t.field_names = [_ccal["labels"]["week"].format(w), "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] + t.align[t.field_names[0]]="l" + if _ccal["show_date"]: + t.add_row(["", + formatday(getnextdayn(d, 0)), + formatday(getnextdayn(d, 1)), + formatday(getnextdayn(d, 2)), + formatday(getnextdayn(d, 3)), + formatday(getnextdayn(d, 4))],divider=True) + add_row(t,["", + formatevents(getnextdayn(d, 0)), + formatevents(getnextdayn(d, 1)), + formatevents(getnextdayn(d, 2)), + formatevents(getnextdayn(d, 3)), + formatevents(getnextdayn(d, 4))],True) + if _ccal["show_project"]: + add_row(t,[_ccal["labels"]["project"], + formatprojects(getnextdayn(d, 0)), + formatprojects(getnextdayn(d, 1)), + formatprojects(getnextdayn(d, 2)), + formatprojects(getnextdayn(d, 3)), + formatprojects(getnextdayn(d, 4))],False) + print(t.get_formatted_string(_c["format"])) + d=getnextmonday(d) + w+=1 + if d 0: - t = PrettyTable() - t.field_names = ["Week", "Day", "Project info"] - t.align[t.field_names[-1]]="l" - d=getmonday(sem["start"]) - w=getweek(d) - while d<=sem["end"]: # This is not optimal but works fine - for p in sem["projects"].keys(): - start=sem["projects"][p]["start"] - end=sem["projects"][p]["end"] - name=sem["projects"][p]["name"] - if d.date() == start.date(): - t.add_row([w,formatday(start),_cproj["labels"]["start"].format(name)]) - if d.date() == end.date(): - t.add_row([w,formatday(end),_cproj["labels"]["end"].format(name)]) - d=getnextdayn(d, 1) +if not _cproj["hidden"]: + if len(sem["projects"].keys()) > 0: + t = PrettyTable() + t.field_names = ["Week", "Day", "Project info"] + t.align[t.field_names[-1]]="l" + d=getmonday(sem["start"]) w=getweek(d) - if not _cproj["show_week"]: - t.del_column(t.field_names[0]) - print("Projects deadlines:") - print(t.get_formatted_string(_c["format"])) + while d<=sem["end"]: # This is not optimal but works fine + for p in sem["projects"].keys(): + start=sem["projects"][p]["start"] + end=sem["projects"][p]["end"] + name=sem["projects"][p]["name"] + if d.date() == start.date(): + t.add_row([w,formatday(start),_cproj["labels"]["start"].format(name)]) + if d.date() == end.date(): + t.add_row([w,formatday(end),_cproj["labels"]["end"].format(name)]) + d=getnextdayn(d, 1) + w=getweek(d) + if not _cproj["show_week"]: + t.del_column(t.field_names[0]) + print("Projects deadlines:") + print(t.get_formatted_string(_c["format"])) -- cgit v1.2.3