<s> import sublime <EOL> import sublime_plugin <EOL> import os <EOL> class RunPigCommand ( sublime_plugin . WindowCommand ) : <EOL> settings = None <EOL> def get_setting ( self , name ) : <EOL> setting = self . settings . get ( name ) <EOL> if setting is not None and len ( setting ) == <NUM_LIT:0> : <EOL> setting = None <EOL> return setting <EOL> def run ( self , file_regex = '<STR_LIT>' , path = '<STR_LIT>' ) : <EOL> env = { } <EOL> self . settings = sublime . load_settings ( '<STR_LIT>' ) <EOL> java_home = self . get_setting ( '<STR_LIT>' ) <EOL> pig_home = self . get_setting ( '<STR_LIT>' ) <EOL> execution_mode = self . get_setting ( '<STR_LIT>' ) <EOL> pig_classpath = self . get_setting ( '<STR_LIT>' ) <EOL> log4j_properties = self . get_setting ( '<STR_LIT>' ) <EOL> pig_binary = None <EOL> if java_home is not None : <EOL> env [ '<STR_LIT>' ] = java_home <EOL> if pig_home is not None : <EOL> env [ '<STR_LIT>' ] = pig_home <EOL> pig_binary = os . path . join ( pig_home , '<STR_LIT>' , '<STR_LIT>' ) <EOL> else : <EOL> pig_binary = '<STR_LIT>' <EOL> cmd = [ pig_binary ] <EOL> if pig_classpath is not None : <EOL> env [ '<STR_LIT>' ] = pig_classpath <EOL> if log4j_properties is not None : <EOL> cmd . extend ( [ '<STR_LIT>' , log4j_properties ] ) <EOL> if execution_mode is not None : <EOL> cmd . extend ( [ '<STR_LIT>' , execution_mode ] ) <EOL> cmd . append ( self . window . active_view ( ) . file_name ( ) ) <EOL> self . window . run_command ( '<STR_LIT>' , <EOL> { '<STR_LIT>' : cmd , '<STR_LIT>' : env , '<STR_LIT>' : file_regex , '<STR_LIT:path>' : path } ) </s>
