From 2c0bf905da9b2e70fedbea82b9397d7d5230d2ee Mon Sep 17 00:00:00 2001 From: Rene Luria Date: Wed, 27 Nov 2024 14:32:51 +0100 Subject: [PATCH] feat: add new category and days to schedule argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🛠️ myice.py -> Added new enum value 'u111' to AgeGroup, modified get_schedule function to accept num_days parameter, added num_days option to schedule function. --- myice/myice.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/myice/myice.py b/myice/myice.py index 30fda3b..e9639f5 100755 --- a/myice/myice.py +++ b/myice/myice.py @@ -31,6 +31,7 @@ class AgeGroup(str, Enum): u13p = "U13 (Prép)" u15t = "U15 (Top)" u15a = "U15 (A)" + u111 = "U11 (1)" class EventType(str, Enum): @@ -141,13 +142,13 @@ def wrapper_session(func): @wrapper_session -def get_schedule() -> str: +def get_schedule(num_days: int) -> str: global session global userid assert session and userid now = datetime.datetime.now() date_start = now - date_end = date_start + datetime.timedelta(days=7) + date_end = date_start + datetime.timedelta(days=num_days) r = session.post( "https://app.myice.hockey/inc/processclubplanning.php", data={ @@ -208,11 +209,12 @@ def schedule( "--outfile", "-o", help="file to write result to, or stdout if none" ), ] = None, + num_days: Annotated[int, typer.Option("--days")] = 7, ): """ Fetch schedule as json """ - schedule = get_schedule() + schedule = get_schedule(num_days) if outfile: with outfile.open("w") as f: f.write(schedule)