diff options
| author | Loïc Guégan <manzerbredes@mailbox.org> | 2025-07-27 16:11:35 +0200 |
|---|---|---|
| committer | Loïc Guégan <manzerbredes@mailbox.org> | 2025-07-27 16:11:35 +0200 |
| commit | 68783a2d6118c367734d42700cfb423246943c75 (patch) | |
| tree | 3a8bee89425b8183374ddae6de9141652fdaf20a | |
| parent | 34c5be47ca807ef09a42569604341cd97e07d188 (diff) | |
Minor changes
| -rw-r--r-- | infos.yaml | 5 | ||||
| -rwxr-xr-x | main.py | 139 |
2 files changed, 75 insertions, 69 deletions
@@ -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" @@ -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 d<sem["end"]: - print("") +if not _ccal["hidden"]: + 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 d<sem["end"]: + print("") #### Gen slots tables -for s in sem["slots"]: - t = PrettyTable() - t.field_names = ["Day", "Time", "Room"] - t.align["Day"]="l" - for dayname in ["monday","tuesday","wednesday","thursday", "friday"]: - p=sem["slots"][s][dayname] - timeStr=gettime(p["start"])+"-"+gettime(p["end"]) if p["start"] is not None else "" - room=p["room"] if p["room"] is not None else "" - if timeStr != "" or room != "": - t.add_row([dayname.capitalize(),timeStr,room]) - if not _cslot["show_room"]: - t.del_column(t.field_names[-1]) - print(s+":") - print(t.get_formatted_string(_c["format"])) +if not _cslot["hidden"]: + for s in sem["slots"]: + t = PrettyTable() + t.field_names = ["Day", "Time", "Room"] + t.align["Day"]="l" + for dayname in ["monday","tuesday","wednesday","thursday", "friday"]: + p=sem["slots"][s][dayname] + timeStr=gettime(p["start"])+"-"+gettime(p["end"]) if p["start"] is not None else "" + room=p["room"] if p["room"] is not None else "" + if timeStr != "" or room != "": + t.add_row([dayname.capitalize(),timeStr,room]) + if not _cslot["show_room"]: + t.del_column(t.field_names[-1]) + print(s+":") + print(t.get_formatted_string(_c["format"])) #### Gen projects deadline tables -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) - 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"])) |
