Skip to content

Commit a79b8b1

Browse files
committed
fix: expect latest item but cached ones got
1 parent 917e333 commit a79b8b1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

zjuintl_assistant/assistant.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ def get_cookie_jar(self, key: str = None, base: str = None) -> requests.cookies.
6161
return self.__cookie_jars[key]
6262

6363

64+
def remove_cookie_jar(self, key: str = None):
65+
"""
66+
Remove cookie jar
67+
"""
68+
69+
if key is None:
70+
key = inspect.currentframe().f_back.f_code.co_name
71+
if key in self.__cookie_jars:
72+
logger.debug(f"Removing {key} cookie jar")
73+
self.__cookie_jars.pop(key)
74+
else:
75+
logger.debug(f"{key} cookie jar not found")
76+
77+
6478
def logout(self):
6579
"""
6680
Logout by clearing cookies and set related flags to False
@@ -292,6 +306,9 @@ def get_bb_grades(self, count) -> list[data_classes.BB_Grade]:
292306

293307
logger.debug("Get BB grades success")
294308

309+
# remove cookie jar
310+
self.remove_cookie_jar()
311+
295312
return result
296313

297314

@@ -364,6 +381,9 @@ def get_bb_announcements(self, count: int, full: bool = False) -> list[data_clas
364381

365382
logger.debug("Get BB announcements success")
366383

384+
# remove cookie jar
385+
self.remove_cookie_jar()
386+
367387
return result
368388

369389

0 commit comments

Comments
 (0)