summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoïc Guégan <manzerbredes@mailbox.org>2025-07-24 16:11:58 +0200
committerLoïc Guégan <manzerbredes@mailbox.org>2025-07-24 16:11:58 +0200
commit13b5acb1c4e8de4a375eab846814fbde337c1fc9 (patch)
tree4598e632e3f330e2efb12a6660688c9ccdc203d3
parentc0cfc0346936446e1c5f1c2212ba881046ad8f2a (diff)
Init project
-rw-r--r--.gitignore1
-rw-r--r--infos.yaml40
-rwxr-xr-xmain.py86
-rw-r--r--requirements.txt4
4 files changed, 131 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8fa5b33
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+env \ No newline at end of file
diff --git a/infos.yaml b/infos.yaml
new file mode 100644
index 0000000..4367ec9
--- /dev/null
+++ b/infos.yaml
@@ -0,0 +1,40 @@
+course: "Parallel Programming"
+
+semester:
+ start: "11/08/2025"
+ end: "15/12/2025"
+ week: 33
+
+output:
+ show_events: yes
+ show_lecturers: yes
+ show_dates: yes
+
+events:
+ 1:
+ name: "Deadline student list"
+ date: "19/11/2025"
+ 2:
+ name: "Exam"
+ date: "03/12/2025"
+
+assigments:
+ 1:
+ start: "01/09/2025"
+ end: "17/09/2025"
+ 2:
+ start: "15/09/2025"
+ end: "08/10/2025"
+ 3:
+ start: "06/10/2025"
+ end: "29/10/2025"
+
+lectures:
+ 1:
+ name: "Introduction"
+ date: "13/08/2025"
+ who: "Loïc"
+ 2:
+ name: "Parallel software and hardware"
+ date: "22/08/2025"
+ who: "Loïc"
diff --git a/main.py b/main.py
new file mode 100755
index 0000000..2667513
--- /dev/null
+++ b/main.py
@@ -0,0 +1,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
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..0976d7c
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,4 @@
+prettytable==3.16.0
+pyaml==25.7.0
+PyYAML==6.0.2
+wcwidth==0.2.13