<s> import json <EOL> import os <EOL> from . . import config <EOL> from . . import global_vars <EOL> from . . import json_encoders <EOL> from . . import utils <EOL> from . . problem import ProblemSession <EOL> def fatal ( error ) : <EOL> print ( error ) <EOL> exit ( <NUM_LIT:0> ) <EOL> def load_session ( ) : <EOL> try : <EOL> if os . path . exists ( config . get_session_file_path ( ) ) : <EOL> session_data_json = open ( config . get_session_file_path ( ) , '<STR_LIT:r>' ) . read ( ) <EOL> elif os . path . exists ( os . path . join ( '<STR_LIT:..>' , config . get_session_file_path ( ) ) ) : <EOL> config . internal_directory_path = os . path . join ( '<STR_LIT:..>' , config . internal_directory_path ) <EOL> session_data_json = open ( config . get_session_file_path ( ) , '<STR_LIT:r>' ) . read ( ) <EOL> else : <EOL> return False <EOL> session_data = json . loads ( session_data_json , object_hook = json_encoders . my_json_decoder ) <EOL> global_vars . problem = ProblemSession ( config . polygon_url , session_data [ "<STR_LIT>" ] ) <EOL> global_vars . problem . use_ready_session ( session_data ) <EOL> return True <EOL> except : <EOL> return False <EOL> def save_session ( ) : <EOL> session_data = global_vars . problem . dump_session ( ) <EOL> session_data_json = json . dumps ( session_data , sort_keys = True , indent = '<STR_LIT:U+0020>' , default = json_encoders . my_json_encoder ) <EOL> utils . safe_rewrite_file ( config . get_session_file_path ( ) , session_data_json ) </s>
