<s> from __future__ import absolute_import , unicode_literals , print_function , division <EOL> import re <EOL> import sublime <EOL> import sublime_plugin <EOL> from . import GitTextCommand <EOL> class GitBranchStatusListener ( sublime_plugin . EventListener ) : <EOL> def on_activated ( self , view ) : <EOL> view . run_command ( "<STR_LIT>" ) <EOL> def on_post_save ( self , view ) : <EOL> view . run_command ( "<STR_LIT>" ) <EOL> class GitBranchStatusCommand ( GitTextCommand ) : <EOL> def run ( self , view ) : <EOL> s = sublime . load_settings ( "<STR_LIT>" ) <EOL> if s . get ( "<STR_LIT>" ) : <EOL> self . run_command ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , self . branch_done , show_status = False , no_save = True , error_suppresses_output = True ) <EOL> else : <EOL> self . branch_done ( False ) <EOL> if ( s . get ( "<STR_LIT>" ) ) : <EOL> self . run_command ( [ '<STR_LIT>' , '<STR_LIT:status>' , '<STR_LIT>' ] , self . status_done , show_status = False , no_save = True , error_suppresses_output = True ) <EOL> else : <EOL> self . status_done ( False ) <EOL> def branch_done ( self , result ) : <EOL> if result is False : <EOL> self . view . set_status ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> else : <EOL> self . view . set_status ( "<STR_LIT>" , "<STR_LIT>" + result . strip ( ) ) <EOL> def status_done ( self , result ) : <EOL> if result is False : <EOL> self . view . set_status ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . view . set_status ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> else : <EOL> lines = [ line for line in result . splitlines ( ) if re . match ( r'<STR_LIT>' , line ) ] <EOL> index = [ line [ <NUM_LIT:0> ] for line in lines if not line [ <NUM_LIT:0> ] . isspace ( ) ] <EOL> working = [ line [ <NUM_LIT:1> ] for line in lines if not line [ <NUM_LIT:1> ] . isspace ( ) ] <EOL> self . view . set_status ( "<STR_LIT>" , "<STR_LIT>" + self . status_string ( index ) ) <EOL> self . view . set_status ( "<STR_LIT>" , "<STR_LIT>" + self . status_string ( working ) ) <EOL> def status_string ( self , statuses ) : <EOL> s = sublime . load_settings ( "<STR_LIT>" ) <EOL> symbols = s . get ( "<STR_LIT>" ) <EOL> if not statuses : <EOL> return symbols [ '<STR_LIT>' ] <EOL> status = [ ] <EOL> if statuses . count ( '<STR_LIT:M>' ) : <EOL> status . append ( "<STR_LIT>" % ( statuses . count ( '<STR_LIT:M>' ) , symbols [ '<STR_LIT>' ] ) ) <EOL> if statuses . count ( '<STR_LIT:A>' ) : <EOL> status . append ( "<STR_LIT>" % ( statuses . count ( '<STR_LIT:A>' ) , symbols [ '<STR_LIT>' ] ) ) <EOL> if statuses . count ( '<STR_LIT:D>' ) : <EOL> status . append ( "<STR_LIT>" % ( statuses . count ( '<STR_LIT:D>' ) , symbols [ '<STR_LIT>' ] ) ) <EOL> if statuses . count ( '<STR_LIT:?>' ) : <EOL> status . append ( "<STR_LIT>" % ( statuses . count ( '<STR_LIT:?>' ) , symbols [ '<STR_LIT>' ] ) ) <EOL> if statuses . count ( '<STR_LIT>' ) : <EOL> status . append ( "<STR_LIT>" % ( statuses . count ( '<STR_LIT>' ) , symbols [ '<STR_LIT>' ] ) ) <EOL> if statuses . count ( '<STR_LIT:R>' ) : <EOL> status . append ( "<STR_LIT>" % ( statuses . count ( '<STR_LIT:R>' ) , symbols [ '<STR_LIT>' ] ) ) <EOL> if statuses . count ( '<STR_LIT:C>' ) : <EOL> status . append ( "<STR_LIT>" % ( statuses . count ( '<STR_LIT:C>' ) , symbols [ '<STR_LIT>' ] ) ) <EOL> return symbols [ '<STR_LIT>' ] . join ( status ) </s>
