@@ -72,11 +72,16 @@ def save_session(self, **save_session_kwargs):
7272 Remember, the access_token should be treated the same as a password.
7373
7474 Args:
75- save_session_kwargs (dicr): Arguments to be passed
76- to Session.save_session(). Not used in this implementation,
77- but can be used by subclasses.
75+ save_session_kwargs (dicr): To be used by implementation
76+ of save_session, however save_session wants to use them. The
77+ default implementation (this one) takes a relative or absolute
78+ file path for pickle save location, under the name "path"
7879 """
79- with open ("session.pickle" , "wb" ) as session_file :
80+ path = "session.pickle"
81+ if "path" in save_session_kwargs :
82+ path = save_session_kwargs ["path" ]
83+
84+ with open (path , "wb" ) as session_file :
8085 import pickle
8186 # pickle.HIGHEST_PROTOCOL is binary format. Good perf.
8287 pickle .dump (self , session_file , pickle .HIGHEST_PROTOCOL )
@@ -91,13 +96,18 @@ def load_session(**load_session_kwargs):
9196 Remember, the access_token should be treated the same as a password.
9297
9398 Args:
94- load_session_kwargs (dict): Arguments to be passed to
95- Session.load_session(). Not used in this implementation,
96- but can be used in subclasses.
99+ load_session_kwargs (dict): To be used by implementation
100+ of load_session, however load_session wants to use them. The
101+ default implementation (this one) takes a relative or absolute
102+ file path for pickle save location, under the name "path"
97103
98104 Returns:
99105 :class:`Session`: The loaded session
100106 """
101- with open ("session.pickle" , "rb" ) as session_file :
107+ path = "session.pickle"
108+ if "path" in load_session_kwargs :
109+ path = load_session_kwargs ["path" ]
110+
111+ with open (path , "rb" ) as session_file :
102112 import pickle
103113 return pickle .load (session_file )
0 commit comments