<s> '''<STR_LIT>''' <EOL> from __future__ import unicode_literals <EOL> from . session_base import SessionBase <EOL> from time import time <EOL> class Session ( SessionBase ) : <EOL> def __init__ ( self , <EOL> token_type , <EOL> expires_in , <EOL> scope_string , <EOL> access_token , <EOL> client_id , <EOL> auth_server_url , <EOL> redirect_uri , <EOL> refresh_token = None , <EOL> client_secret = None ) : <EOL> self . token_type = token_type <EOL> self . _expires_at = time ( ) + int ( expires_in ) <EOL> self . scope = scope_string . split ( "<STR_LIT:U+0020>" ) <EOL> self . access_token = access_token <EOL> self . client_id = client_id <EOL> self . auth_server_url = auth_server_url <EOL> self . redirect_uri = redirect_uri <EOL> self . refresh_token = refresh_token <EOL> self . client_secret = client_secret <EOL> def is_expired ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _expires_at < time ( ) - <NUM_LIT:10> <EOL> def refresh_session ( self , expires_in , scope_string , access_token , refresh_token ) : <EOL> self . _expires_at = time ( ) + int ( expires_in ) <EOL> self . scope = scope_string . split ( "<STR_LIT:U+0020>" ) <EOL> self . access_token = access_token <EOL> self . refresh_token = refresh_token <EOL> def save_session ( self , ** save_session_kwargs ) : <EOL> """<STR_LIT>""" <EOL> path = "<STR_LIT>" <EOL> if "<STR_LIT:path>" in save_session_kwargs : <EOL> path = save_session_kwargs [ "<STR_LIT:path>" ] <EOL> with open ( path , "<STR_LIT:wb>" ) as session_file : <EOL> import pickle <EOL> pickle . dump ( self , session_file , pickle . HIGHEST_PROTOCOL ) <EOL> @ staticmethod <EOL> def load_session ( ** load_session_kwargs ) : <EOL> """<STR_LIT>""" <EOL> path = "<STR_LIT>" <EOL> if "<STR_LIT:path>" in load_session_kwargs : <EOL> path = load_session_kwargs [ "<STR_LIT:path>" ] <EOL> with open ( path , "<STR_LIT:rb>" ) as session_file : <EOL> import pickle <EOL> return pickle . load ( session_file ) </s>
