summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py139
1 files changed, 71 insertions, 68 deletions
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 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"]))