delete everything

This commit is contained in:
dogeystamp 2023-08-24 19:48:21 -04:00
parent 8c46d7519c
commit c1697308bc
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
4 changed files with 0 additions and 148 deletions

View File

@ -1,9 +0,0 @@
# calendar-tool
A tool to add a 6-day schedule to calendar apps.
Outputs in csv format.
An example config is available in docs/config.py.
**Note from future me:**
The code quality is garbage on this but the tool has faithfully served me for 2 years now 👍
Thank you past me

View File

@ -1 +0,0 @@
This is an example config. Move it to the same folder as main.py for it to work.

View File

@ -1,73 +0,0 @@
import datetime
class s_class:
def __init__(self, name, period,):
self.name = name
self.period = period
# If there are two periods that are identical, merge them
merge_periods = True
# Start times of each period
start_times = {
1: datetime.time(8,45,0),
2: datetime.time(9,30,0),
3: datetime.time(10,30,0),
4: datetime.time(11,15,0),
5: datetime.time(13,0,0),
6: datetime.time(13,45,0),
7: datetime.time(14,45,0),
}
# End times of each period
end_times = {
1: datetime.time(9,30,0),
2: datetime.time(10,15,0),
3: datetime.time(11,15,0),
4: datetime.time(12,0,0),
5: datetime.time(13,45,0),
6: datetime.time(14,30,0),
7: datetime.time(15,45,0),
}
# Classes that you can put in periods
classes = [s_class("Gym",1), #1,
s_class("Maths",1), #2
s_class("English",1),#3
s_class("ECR",1),#4
s_class("French",1),#5
s_class("Science",1),#6
s_class("Spanish",1),#7
s_class("History",1),#8
s_class("Geography",1), #9
s_class("Drama",1),#10
s_class("Music",1)] #11
# Which classes you put in each period for each day in the cycle
schedule_dict = {1:[5,5,7,1,2,8,3],
2:[6,6,2,2,3,3,4],
3:[9,9,2,2,6,6,5],
4:[2,2,5,5,7,7,3],
5:[5,5,1,1,10,10,6],
6:[5,5,8,8,11,11,9]}
# Start/end times of vacations (Only put the start time if it lasts one day)
vacation_days = [[datetime.datetime(2020,9,7,0,0,0,0)],
[datetime.datetime(2020,10,12,0,0,0,0)],
[datetime.datetime(2020,11,2,0,0,0,0),
datetime.datetime(2020,11,6,0,0,0,0)],
[datetime.datetime(2020,12,23,0,0,0,0),
datetime.datetime(2021,1,5,0,0,0,0)],
[datetime.datetime(2021,3,1,0,0,0,0),
datetime.datetime(2021,3,5,0,0,0,0)],
[datetime.datetime(2021,4,2,0,0,0,0),
datetime.datetime(2021,4,9,0,0,0,0)],
[datetime.datetime(2021,5,24,0,0,0,0)],
[datetime.datetime(2020,11,20,0,0,0,0)],
[datetime.datetime(2020,11,27,0,0,0,0)]]
# In the event you need to completely disrupt the cycle, add an exception
exceptions = [
[datetime.datetime(2021,4,22,0,0,0,0),3],
[datetime.datetime(2021,4,23,0,0,0,0),1]]
# Start of the schedule year
start_date = datetime.datetime(2020, 8, 28, 0, 0, 0, 0)
# End of the schedule year
end_date = datetime.datetime(2021, 6, 22, 0, 0, 0, 0)
# In case you're too lazy to modify the start date or vacation days
offset = 0

65
main.py
View File

@ -1,65 +0,0 @@
import csv
import datetime
from config import *
step = datetime.timedelta(days = 1)
day = 1
for i in range(offset):
start_date += step
with open('calendar.csv', mode='w') as calendar:
calendar_writer = csv.writer(calendar, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
calendar_writer.writerow(['Subject', 'Start Date', 'Start Time','End Date','End Time', 'All day event', 'Description' ,'Location'])
def period_to_time(start,period):
if start:
return start_times[period].strftime("%H:%M")
else:
return end_times[period].strftime("%H:%M")
def write_file(subject,date,long):
with open('calendar.csv', mode='a') as calendar:
calendar_writer = csv.writer(calendar, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
p2 = subject.period
if long:
p2 +=1
calendar_writer.writerow([subject.name, str(date.month) + "/"+ str(date.day) + "/" +str(date.year), period_to_time(True,subject.period),str(date.month) + "/"+ str(date.day) + "/" +str(date.year),period_to_time(False,p2),"FALSE", day])
current_date = start_date-step
while True:
current_date += step
school = True
for vacation in vacation_days:
if(len(vacation)>1):
if current_date >= vacation[0] and current_date <= vacation[1]:
school = False
break
else:
if current_date == vacation[0]:
school = False
break
for exception in exceptions:
if exception[0] == current_date:
day = exception[1]
if not school:
continue
if current_date > end_date:
break
if current_date.weekday() == 5 or current_date.weekday() == 6:
continue
schedule = schedule_dict[day]
for period_order, period_id in enumerate(schedule):
class_object = classes[period_id-1]
class_object.period = period_order + 1
long_period = False
if period_order < len(schedule_dict) and schedule[period_order+1] == period_id and merge_periods:
long_period = True
if period_order > 0 and schedule[period_order-1] == period_id and merge_periods:
continue
write_file(class_object, current_date, long_period)
day += 1
if day > len(schedule_dict):
day = 1