<s> import sublime <EOL> import sublime_plugin <EOL> import os <EOL> import threading <EOL> try : <EOL> from . import libsass <EOL> except ValueError : <EOL> import libsass <EOL> compile = libsass . compile <EOL> deps = libsass . deps <EOL> pathutils = libsass . pathutils <EOL> project = libsass . project <EOL> clears = { } <EOL> def autoload_frameworks ( config ) : <EOL> root = config [ '<STR_LIT:root>' ] <EOL> loadpath = config [ '<STR_LIT>' ] [ '<STR_LIT>' ] or [ ] <EOL> if type ( loadpath ) is str : <EOL> loadpath = [ loadpath ] <EOL> frameworks = pathutils . find_type_dirs ( root , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> print ( "<STR_LIT>" , frameworks ) <EOL> frameworks = [ p for p in frameworks if p not in pathutils . subpaths ( config [ '<STR_LIT:file>' ] ) ] <EOL> print ( "<STR_LIT>" , frameworks ) <EOL> return config <EOL> def compile_deps ( path , config ) : <EOL> files , root = deps . get ( path ) <EOL> config [ '<STR_LIT:root>' ] = root <EOL> config [ '<STR_LIT:file>' ] = path <EOL> autoload_frameworks ( config ) <EOL> struct = config [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> if not struct or struct == "<STR_LIT>" : <EOL> return compile . nested ( files , config ) <EOL> elif type ( struct ) is list and len ( struct ) is <NUM_LIT:2> and struct [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> return compile . nested ( files , config , struct [ <NUM_LIT:1> ] ) <EOL> elif struct == "<STR_LIT>" : <EOL> return compile . flat ( files , config ) <EOL> else : <EOL> sublime . error_message ( u"<STR_LIT>" . format ( struct ) ) <EOL> return <EOL> class CompileSassCommand ( sublime_plugin . WindowCommand ) : <EOL> '''<STR_LIT>''' <EOL> def run ( self , ** build ) : <EOL> file_path = build [ '<STR_LIT>' ] <EOL> thread = CompileThread ( file_path , self . callback ( file_path ) ) <EOL> thread . start ( ) <EOL> return <EOL> def callback ( self , file_path ) : <EOL> def cb1 ( compiled ) : <EOL> def cb2 ( ) : <EOL> if compiled : <EOL> self . _set_status ( u"<STR_LIT>" . format ( "<STR_LIT:U+002C>" . join ( compiled ) ) ) <EOL> else : <EOL> self . _set_status ( u"<STR_LIT>" . format ( os . path . basename ( file_path ) ) ) <EOL> return cb2 <EOL> return cb1 <EOL> def _set_status ( self , message ) : <EOL> view = self . window . active_view ( ) <EOL> view . set_status ( '<STR_LIT>' , message ) <EOL> global clears <EOL> id = view . id ( ) <EOL> clears [ id ] = clears . get ( id , <NUM_LIT:0> ) + <NUM_LIT:1> <EOL> sublime . set_timeout ( self . _clear_status ( view ) , <NUM_LIT> ) <EOL> return <EOL> def _clear_status ( self , view ) : <EOL> def clear ( ) : <EOL> id = view . id ( ) <EOL> global clears <EOL> clears [ id ] -= <NUM_LIT:1> <EOL> if clears [ id ] == <NUM_LIT:0> : <EOL> view . set_status ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> return <EOL> return clear <EOL> class CompileThread ( threading . Thread ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , file , callback ) : <EOL> threading . Thread . __init__ ( self ) <EOL> self . file = file <EOL> self . callback = callback <EOL> self . config = project . config_for ( file ) <EOL> return <EOL> def run ( self ) : <EOL> compiled = compile_deps ( self . file , self . config ) <EOL> sublime . set_timeout ( self . callback ( compiled ) , <NUM_LIT:1> ) <EOL> return </s>
