1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!./env/bin/python
import yaml, textwrap
from prettytable import PrettyTable
from datetime import datetime, timedelta
with open("infos.yaml", "r") as f:
i=yaml.safe_load(f)
def parse_date(d):
return datetime.strptime(d, "%d/%m/%Y")
def getmonday(d):
return d - timedelta(days=d.weekday())
def getnextmonday(d):
return getmonday(d)+timedelta(days=7)
def getnextdayn(d,n):
return (d+timedelta(days=n))
def formatday(d):
return d.strftime("%d.%m")
def getassign(d):
val=""
for a in i["assigments"]:
start=parse_date(i["assigments"][a]["start"])
end=parse_date(i["assigments"][a]["end"])
if d>=start and d<=end:
if len(val)>0:
val+="/"
val+=str(a)
return val
def getlecture(d):
for l in i["lectures"]:
date=parse_date(i["lectures"][l]["date"])
if d==date:
lecturer=""
if i["output"]["show_lecturers"]:
lecturer="\n ("+i["lectures"][l]["who"]+")"
return textwrap.fill(i["lectures"][l]["name"]+lecturer,15)
return ""
def getevents(d):
val=""
for e in i["events"]:
date=parse_date(i["events"][e]["date"])
if d==date:
if len(val)>0:
val+=","
val+=str(i["events"][e]["name"])
return textwrap.fill(val,15)
sstart=parse_date(i["semester"]["start"])
send=parse_date(i["semester"]["end"])
d=sstart
w=i["semester"]["week"]
while d <= send:
t = PrettyTable()
t.field_names = ["Week "+str(w), "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
if i["output"]["show_dates"]:
t.add_row(["Date",
formatday(getnextdayn(d, 0)),
formatday(getnextdayn(d, 1)),
formatday(getnextdayn(d, 2)),
formatday(getnextdayn(d, 3)),
formatday(getnextdayn(d, 4))],divider=True)
t.add_row(["Assigment",
getassign(getnextdayn(d, 0)),
getassign(getnextdayn(d, 1)),
getassign(getnextdayn(d, 2)),
getassign(getnextdayn(d, 3)),
getassign(getnextdayn(d, 4))],divider=True)
t.add_row(["Lecture",
getlecture(getnextdayn(d, 0)),
getlecture(getnextdayn(d, 1)),
getlecture(getnextdayn(d, 2)),
getlecture(getnextdayn(d, 3)),
getlecture(getnextdayn(d, 4))],divider=True)
if i["output"]["show_events"]:
t.add_row(["Other",
getevents(getnextdayn(d, 0)),
getevents(getnextdayn(d, 1)),
getevents(getnextdayn(d, 2)),
getevents(getnextdayn(d, 3)),
getevents(getnextdayn(d, 4))],divider=True)
print(t)
print()
d=getnextmonday(d)
w+=1
|