Skip to content
Snippets Groups Projects
Verified Commit 72260704 authored by TheJoeCoder's avatar TheJoeCoder
Browse files

Improve documentation and prevent broken parts of code from working

parent fb63894b
Branches main
No related tags found
No related merge requests found
......@@ -421,5 +421,6 @@ $RECYCLE.BIN/
config.json
patches.json
patches.json.old
patches.*.json
input.json
output.ics
\ No newline at end of file
{
"python.languageServer": "Pylance",
"python.languageServer": "Jedi",
"python.analysis.diagnosticSeverityOverrides": {
"reportMissingModuleSource": "none",
"reportShadowedImports": "none"
......
......@@ -52,3 +52,27 @@ Arguments:
- `<` less than
- `>=` greater then/equal to
- `<=` less than/equal to
---
## Operations
**edit** - merges the arguments with the lesson's json object
- `edit` - the json to merge
---
**edit_times** - edits the start and end time of a lesson
- `edit` object containing at least one of the following:
- `start` - the start time
- `end` - the end time
*WARNING*: Be very careful of timezones! While the times of lessons from input are interpreted in the system's timezone, start and end times in this operation are interpreted as UTC! Specify a timezone by appending to the end of the time (e.g. Z for UTC, +01:00 for BST, etc.).
---
**add**: adds a lesson on specific days
- `days` - a list of days to add the lesson (named e.g. ["Monday", "Tuesday"])
- `start_time` - the start time
- `length` - the length of the lesson, as an integer, in minutes
- `data` - the lesson data as if lesson was from Bromcom
\ No newline at end of file
......@@ -146,9 +146,20 @@ def apply_patch(input_lessons: list, patch: dict, week_lookup_table: list) -> li
if "end" in patch["edit"]:
end_time = datetime.time.fromisoformat(patch["edit"]["end"])
end_date = end_date.replace(hour=end_time.hour, minute=end_time.minute, second=end_time.second)
start_date_formatted = start_date.strftime("%Y-%m-%dT%H:%M:%S")
end_date_formatted = end_date.strftime("%Y-%m-%dT%H:%M:%S")
if end_date < start_date:
logger.warn(
f"For lesson {lesson.get("period", "no-period")} on {start_date.strftime("%Y-%m-%d")}: " +
f"end date is before start date ({start_date_formatted} vs {end_date_formatted}). Skipped"
)
continue
# Set new dates
lesson["startDate"] = start_date.strftime("%Y-%m-%dT%H:%M:%S")
lesson["endDate"] = end_date.strftime("%Y-%m-%dT%H:%M:%S")
lesson["startDate"] = start_date_formatted
lesson["endDate"] = end_date_formatted
elif patch["type"] == "add":
# Add a lesson
# Build day map
......@@ -235,29 +246,29 @@ if __name__ == "__main__":
#)
#school_attendee.user_type = "GROUP"
class_attendee = Attendee(
email=f"{lesson['class']}"
)
class_attendee.user_type = "GROUP"
class_attendee.role = "REQ-PARTICIPANT"
class_attendee.rsvp = "False"
#class_attendee = Attendee(
# email=f"{lesson['class']}"
#)
#class_attendee.user_type = "GROUP"
#class_attendee.role = "REQ-PARTICIPANT"
#class_attendee.rsvp = "False"
# ^ Might be a temporary bug with ics,
# setting to a string works so not gonna change it
class_attendee.status = "ACCEPTED"
#class_attendee.status = "ACCEPTED"
teacher_attendee = Attendee(
email=f"{lesson['teacherName']}"
)
teacher_attendee.user_type = "INDIVIDUAL"
teacher_attendee.role = "REQ-PARTICIPANT"
teacher_attendee.rsvp = "False"
teacher_attendee.status = "ACCEPTED"
#teacher_attendee = Attendee(
# email=f"{lesson['teacherName']}"
#)
#teacher_attendee.user_type = "INDIVIDUAL"
#teacher_attendee.role = "REQ-PARTICIPANT"
#teacher_attendee.rsvp = "False"
#teacher_attendee.status = "ACCEPTED"
e_attendees = [
# school_attendee,
class_attendee,
teacher_attendee
]
#e_attendees = [
# # school_attendee,
# class_attendee,
# teacher_attendee
#]
# Create event
event = Event(
......@@ -265,11 +276,11 @@ if __name__ == "__main__":
begin=e_begin,
end=e_end,
location=e_location,
attendees=e_attendees,
#attendees=e_attendees,
created=datetime.datetime.now()
)
event.extra.append(ContentLine(name="COLOR", value=f"#{lesson['subjectColour']}"))
#event.extra.append(ContentLine(name="COLOR", value=f"#{lesson['subjectColour']}"))
# Add event to calendar
cal.events.append(event)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment