File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -254,30 +254,38 @@ def session_context(self):
254
254
255
255
return self ._session_context
256
256
257
- def save (self , path = None ):
257
+ def save (self , path = None , to_json = False ):
258
258
"""
259
259
:type path: str
260
+ :type to_json: bool
260
261
261
262
:rtype: None
262
263
"""
263
264
264
265
if path is None :
265
266
path = self ._PATH_API_CONTEXT_DEFAULT
266
267
268
+ if to_json :
269
+ return converter .class_to_json (self )
270
+
267
271
with open (path , self ._FILE_MODE_WRITE ) as file :
268
272
file .write (converter .class_to_json (self ))
269
273
270
274
@classmethod
271
- def restore (cls , path = None ):
275
+ def restore (cls , path = None , json_data = None ):
272
276
"""
273
277
:type path: str
278
+ :type json_data: str
274
279
275
280
:rtype: ApiContext
276
281
"""
277
282
278
283
if path is None :
279
284
path = cls ._PATH_API_CONTEXT_DEFAULT
280
285
286
+ if json_data is not None :
287
+ return converter .json_to_class (ApiContext , json_data )
288
+
281
289
with open (path , cls ._FILE_MODE_READ ) as file :
282
290
return converter .json_to_class (ApiContext , file .read ())
283
291
You can’t perform that action at this time.
0 commit comments