#NEWLINE# def run( self , edit , syntax = False ) : #NEWLINE# #INDENT# import subprocess , re #NEWLINE# platform = sublime . platform ( ) #NEWLINE# settings = sublime . load_settings ( 'CodeFormatter.sublime-settings' ) #NEWLINE# opts = settings . get ( 'codeformatter_php_options' ) #NEWLINE# php_path = 'php' #NEWLINE# if ( ( 'php_path' in opts ) and opts [ 'php_path' ] ) : #NEWLINE# #INDENT# php_path = opts [ 'php_path' ] #NEWLINE# #UNINDENT# cmd = [ ] #NEWLINE# cmd . append ( str ( php_path ) ) #NEWLINE# cmd . append ( ( sublime . packages_path ( ) + '/CodeFormatter/codeformatter/lib/phpbeautifier/fmt.phar' ) ) #NEWLINE# cmd . append ( '--list' ) #NEWLINE# stderr = '' #NEWLINE# stdout = '' #NEWLINE# try : #NEWLINE# #INDENT# if ( platform == 'windows' ) : #NEWLINE# #INDENT# startupinfo = subprocess . STARTUPINFO ( ) #NEWLINE# startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW #NEWLINE# startupinfo . wShowWindow = subprocess . SW_HIDE #NEWLINE# p = subprocess . Popen ( cmd , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . PIPE , startupinfo = startupinfo , shell = False , creationflags = subprocess . SW_HIDE ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# p = subprocess . Popen ( platform , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) #NEWLINE# #UNINDENT# ( stdout , stderr ) = p . communicate ( ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# stderr = str ( e ) #NEWLINE# #UNINDENT# if ( ( not stderr ) and ( not stdout ) ) : #NEWLINE# #INDENT# stderr = 'Error while gethering list of php transformations' #NEWLINE# #UNINDENT# if ( ( len ( stderr ) == 0 ) and ( len ( stdout ) > 0 ) ) : #NEWLINE# #INDENT# text = stdout . decode ( 'utf-8' ) #NEWLINE# text = re . sub ( 'Usage:.*?PASSNAME' , 'Available PHP Tranformations:' , text ) #NEWLINE# window = self . view . window ( ) #NEWLINE# pt = window . get_output_panel ( 'paneltranformations' ) #NEWLINE# pt . set_read_only ( False ) #NEWLINE# pt . insert ( edit , pt . size ( ) , text ) #NEWLINE# window . run_command ( 'show_panel' , { #NEWLINE# #INDENT# 'panel' : 'output.paneltranformations' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# show_error ( ( 'Formatter error:\n' + stderr ) )