summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--infos.yaml14
-rwxr-xr-xmain.py47
2 files changed, 41 insertions, 20 deletions
diff --git a/infos.yaml b/infos.yaml
index e4c2962..264a2f9 100644
--- a/infos.yaml
+++ b/infos.yaml
@@ -123,3 +123,17 @@ events:
name: "Guest Lecture"
date: "07/11/2025"
who: "Loïc"
+
+config:
+ name_wrap: 15 # Line break will follow if names exceed this value
+ calendar:
+ show_room: yes
+ show_time: yes
+ show_who: yes
+ show_project: yes
+ show_date: yes
+ min_col_width: 10 # if <=0 not acccounted
+ defrag: no # If yes empty lines from the calendar are not shown
+ labels:
+ week: "Week {}"
+ project: "Projects"
diff --git a/main.py b/main.py
index 2533a69..f745260 100755
--- a/main.py
+++ b/main.py
@@ -6,6 +6,8 @@ from datetime import datetime, timedelta
with open("infos.yaml", "r") as f:
_i=yaml.safe_load(f)
+ _c=_i["config"]
+ _ccal=_c["calendar"]
#### Parsing
def parse_date(s):
@@ -47,12 +49,12 @@ def formatevents(d):
if (not _e["hidden"]) and (_e["date"].date() == d.date() or matchrepeat(d, e)):
if len(output)!=0:
output+="\n"
- if _e["start"] is not None:
+ if _ccal["show_time"] and _e["start"] is not None:
output+=gettime(_e["start"])+"-"+gettime(_e["end"])+"\n"
- if _e["room"] is not None:
+ if _ccal["show_room"] and _e["room"] is not None:
output+="Room: "+_e["room"]+"\n"
output+=_e["name"]
- if _e["who"] is not None:
+ if _ccal["show_who"] and _e["who"] is not None:
output+="\n("+_e["who"]+")"
return output
def formatday(d):
@@ -71,7 +73,7 @@ def add_row(t,row,div):
total=0
for e in row[1:]:
total+=len(e)
- if total > 0:
+ if total > 0 or not _ccal["defrag"]:
t.add_row(row,divider=div)
#### Load semester
@@ -102,14 +104,14 @@ if _i["semester"]["projects"] is not None:
sem["projects"][p]={}
sem["projects"][p]["start"]=parse_date(_p["start"])
sem["projects"][p]["end"]=parse_date(_p["end"])
- sem["projects"][p]["name"]=_p["name"]
+ sem["projects"][p]["name"]=textwrap.fill(_p["name"])
#### Load events
events={}
for e in _i["events"]:
_e=_i["events"][e]
events[e]={
"type": _e["type"],
- "name": _e["name"],
+ "name": textwrap.fill(_e["name"],_c["name_wrap"]),
"date": parse_date(_e["date"]),
"repeat": {
"every": 0,
@@ -137,27 +139,32 @@ for e in _i["events"]:
d=getmonday(sem["start"])
w=getweek(d)
while d<=sem["end"]:
- t = PrettyTable()
- t.field_names = ["Week "+str(w), "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
+ 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"
- 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)
+ 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)
- add_row(t,["Projects",
- formatprojects(getnextdayn(d, 0)),
- formatprojects(getnextdayn(d, 1)),
- formatprojects(getnextdayn(d, 2)),
- formatprojects(getnextdayn(d, 3)),
- formatprojects(getnextdayn(d, 4))],False)
+ 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)
d=getnextmonday(d)
w+=1