Skip to content

Commit

Permalink
✨ Add choice to include empty days
Browse files Browse the repository at this point in the history
  • Loading branch information
RustySnek committed Apr 1, 2024
1 parent 42c35bb commit 1cca26f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/schedule_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

"""
get_schedule returns all days and their events from the month and year provided.
get_schedule(token, month, year) -> dict[str, list[Event]]
get_schedule(token, month, year, include_all = True) -> dict[str, list[Event]]
Structure of Event class:
class Event:
Expand All @@ -22,7 +22,7 @@ class Event:

month = "2"
year = "2023"
schedule = get_schedule(token, month, year)
schedule = get_schedule(token, month, year, True) # True to include empty days

# Printing out all events in the month
for day in schedule:
Expand Down
4 changes: 3 additions & 1 deletion librus_apix/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def schedule_detail(token: Token, prefix: str, detail_url: str) -> Dict[str, str
return schedule


def get_schedule(token: Token, month: str, year: str) -> Dict[int, List[Event]]:
def get_schedule(token: Token, month: str, year: str, include_empty: bool = False) -> Dict[int, List[Event]]:
schedule = defaultdict(list)
soup = no_access_check(
BeautifulSoup(
Expand All @@ -47,6 +47,8 @@ def get_schedule(token: Token, month: str, year: str) -> Dict[int, List[Event]]:
raise ParseError("Error in parsing days of the schedule.")
for day in days:
d = day.find("div", attrs={"class": "kalendarz-numer-dnia"}).text
if include_empty == True:
schedule[int(d)] = []
tr = day.find_all("tr")
if tr:
for event in tr:
Expand Down

0 comments on commit 1cca26f

Please sign in to comment.