<s> from functools import partial <EOL> import sublime <EOL> from sublime_plugin import WindowCommand , TextCommand <EOL> from . util import noop , find_view_by_settings <EOL> from . cmd import GitCmd <EOL> from . helpers import GitShowHelper <EOL> GIT_SHOW_TITLE_PREFIX = '<STR_LIT>' <EOL> GIT_SHOW_SYNTAX = '<STR_LIT>' <EOL> class GitShowCommand ( WindowCommand , GitCmd ) : <EOL> """<STR_LIT>""" <EOL> def run ( self , repo = None , obj = None ) : <EOL> repo = repo or self . get_repo ( ) <EOL> if not repo : <EOL> return <EOL> if not obj : <EOL> self . window . show_input_panel ( '<STR_LIT>' , '<STR_LIT>' , partial ( self . show , repo ) , noop , noop ) <EOL> else : <EOL> self . show ( repo , obj ) <EOL> def show ( self , repo , obj = None ) : <EOL> if not obj : <EOL> exit , obj , _ = self . git ( [ '<STR_LIT>' , '<STR_LIT>' ] , cwd = repo ) <EOL> if exit != <NUM_LIT:0> : <EOL> return sublime . error_message ( "<STR_LIT>" ) <EOL> obj = obj . strip ( ) <EOL> title = GIT_SHOW_TITLE_PREFIX + obj [ : <NUM_LIT:7> ] if len ( obj ) == <NUM_LIT> else obj <EOL> view = find_view_by_settings ( self . window , git_view = '<STR_LIT>' , git_repo = repo , git_show_obj = obj ) <EOL> if not view : <EOL> view = self . window . new_file ( ) <EOL> view . set_name ( title ) <EOL> view . set_scratch ( True ) <EOL> view . set_read_only ( True ) <EOL> view . set_syntax_file ( GIT_SHOW_SYNTAX ) <EOL> view . settings ( ) . set ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> view . settings ( ) . set ( '<STR_LIT>' , repo ) <EOL> view . settings ( ) . set ( '<STR_LIT>' , obj ) <EOL> view . run_command ( '<STR_LIT>' , { '<STR_LIT>' : obj } ) <EOL> class GitShowRefreshCommand ( TextCommand , GitCmd , GitShowHelper ) : <EOL> def is_visible ( self ) : <EOL> return False <EOL> def run ( self , edit , obj = None ) : <EOL> obj = obj or self . view . settings ( ) . get ( '<STR_LIT>' ) <EOL> repo = self . view . settings ( ) . get ( '<STR_LIT>' ) <EOL> show = self . get_show ( repo , obj ) <EOL> if show : <EOL> self . view . set_read_only ( False ) <EOL> if self . view . size ( ) > <NUM_LIT:0> : <EOL> self . view . erase ( edit , sublime . Region ( <NUM_LIT:0> , self . view . size ( ) ) ) <EOL> self . view . insert ( edit , <NUM_LIT:0> , show ) <EOL> self . view . set_read_only ( True ) </s>
