<s> from __future__ import unicode_literals <EOL> import sublime <EOL> import os <EOL> import traceback <EOL> import functools <EOL> import sys <EOL> from functools import partial as bind <EOL> from . import sexp <EOL> from . sexp import key , sym <EOL> from . paths import * <EOL> from . sbt import * <EOL> def locations ( window ) : <EOL> """<STR_LIT>""" <EOL> return [ ( f + os . sep + "<STR_LIT>" ) for f in window . folders ( ) if os . path . exists ( f + os . sep + "<STR_LIT>" ) ] <EOL> def exists ( window ) : <EOL> """<STR_LIT>""" <EOL> return len ( locations ( window ) ) != <NUM_LIT:0> <EOL> def load ( window ) : <EOL> """<STR_LIT>""" <EOL> for f in locations ( window ) : <EOL> root = encode_path ( os . path . dirname ( f ) ) <EOL> with open ( f ) as open_file : <EOL> src = open_file . read ( ) <EOL> try : <EOL> conf = sexp . read_relaxed ( src ) <EOL> m = sexp . sexp_to_key_map ( conf ) <EOL> if m . get ( "<STR_LIT>" ) : <EOL> root = m [ "<STR_LIT>" ] <EOL> else : <EOL> conf = conf + [ key ( "<STR_LIT>" ) , root ] <EOL> return ( root , conf , None ) <EOL> except : <EOL> return ( None , None , bind ( error_bad_config , window , f , sys . exc_info ( ) ) ) <EOL> return ( None , None , bind ( error_no_config , window ) ) <EOL> def error_no_config ( window ) : <EOL> message = "<STR_LIT>" <EOL> message += "<STR_LIT>" <EOL> message += "<STR_LIT>" <EOL> sublime . error_message ( message ) <EOL> def error_bad_config ( window , f , ex ) : <EOL> exc_type , exc_value , exc_tb = ex <EOL> detailed_info = "<STR_LIT>" . join ( traceback . format_exception ( exc_type , exc_value , exc_tb ) ) <EOL> print ( detailed_info ) <EOL> message = "<STR_LIT>" + str ( <EOL> f ) + "<STR_LIT>" <EOL> message += "<STR_LIT>" <EOL> message += ( str ( exc_type ) + "<STR_LIT>" + str ( exc_value ) ) <EOL> message += ( "<STR_LIT:\n>" + "<STR_LIT>" ) <EOL> message += "<STR_LIT>" <EOL> message += "<STR_LIT>" <EOL> if sublime . ok_cancel_dialog ( message ) : <EOL> edit ( window ) <EOL> def edit ( window ) : <EOL> window . open_file ( locations ( window ) [ <NUM_LIT:0> ] ) </s>
