<s> import json <EOL> import sublime <EOL> from . . modules import session <EOL> def _objectify ( s ) : <EOL> if isinstance ( s , str ) : <EOL> return json . loads ( s ) <EOL> return s <EOL> class SessionDecoder ( json . JSONDecoder ) : <EOL> def decode ( self , s ) : <EOL> o = _objectify ( s ) <EOL> try : <EOL> name = o [ "<STR_LIT:name>" ] <EOL> windows = [ <EOL> WindowDecoder . decode ( self , w ) for w in o [ "<STR_LIT>" ] <EOL> ] <EOL> except NameError : <EOL> pass <EOL> else : <EOL> return session . Session ( name , windows ) <EOL> return json . JSONDecoder . decode ( self , o ) <EOL> class WindowDecoder ( json . JSONDecoder ) : <EOL> def decode ( self , s ) : <EOL> o = _objectify ( s ) <EOL> try : <EOL> project = o [ "<STR_LIT>" ] <EOL> project_path = o [ "<STR_LIT>" ] <EOL> views = [ <EOL> ViewDecoder . decode ( self , view ) for view in o [ "<STR_LIT>" ] <EOL> ] <EOL> except NameError : <EOL> pass <EOL> else : <EOL> return session . Window ( project , project_path , views ) <EOL> return json . JSONDecoder . decode ( self , o ) <EOL> class ViewDecoder ( json . JSONDecoder ) : <EOL> def decode ( self , s ) : <EOL> o = _objectify ( s ) <EOL> try : <EOL> file_path = o [ "<STR_LIT>" ] <EOL> active = o [ "<STR_LIT>" ] <EOL> sel_regions = [ <EOL> RegionDecoder . decode ( self , region ) for region in o [ "<STR_LIT>" ] <EOL> ] <EOL> visible_region = RegionDecoder . decode ( self , o [ "<STR_LIT>" ] ) <EOL> except NameError : <EOL> pass <EOL> else : <EOL> return session . View ( file_path , active , sel_regions , visible_region ) <EOL> return json . JSONDecoder . decode ( self , o ) <EOL> class RegionDecoder ( json . JSONDecoder ) : <EOL> def decode ( self , s ) : <EOL> o = _objectify ( s ) <EOL> try : <EOL> a = o [ <NUM_LIT:0> ] <EOL> b = o [ <NUM_LIT:1> ] <EOL> except IndexError : <EOL> pass <EOL> else : <EOL> return sublime . Region ( a , b ) <EOL> return json . JSONDecoder . decode ( self , o ) </s>
