def which(program):
 (filepath, filename) = os.path.split(program)
 os_path = os.environ['PATH'].split(os.pathsep)
 if (sys.platform == 'win32'):
  try:
   prog_files = os.environ['PROGRAMFILES']
  except KeyError:
   prog_files = 'C:\\Program Files'
  likely_dirs = (['', prog_files, os.path.join(prog_files, 'paml41'), os.path.join(prog_files, 'paml43'), os.path.join(prog_files, 'paml44'), os.path.join(prog_files, 'paml45')] + sys.path)
  os_path.extend(likely_dirs)
 for path in os.environ['PATH'].split(os.pathsep):
  exe_file = os.path.join(path, program)
  if is_exe(exe_file):
   return exe_file
 return None

def which ( program ) : ( filepath , filename ) = os . path . split ( program ) os_path = os . environ [ 'PATH' ] . split ( os . pathsep ) if ( sys . platform == 'win32' ) : try : prog_files = os . environ [ 'PROGRAMFILES' ] except KeyError : prog_files = 'C:\\Program Files' likely_dirs = ( [ '' , prog_files , os . path . join ( prog_files , 'paml41' ) , os . path . join ( prog_files , 'paml43' ) , os . path . join ( prog_files , 'paml44' ) , os . path . join ( prog_files , 'paml45' ) ] + sys . path ) os_path . extend ( likely_dirs ) for path in os . environ [ 'PATH' ] . split ( os . pathsep ) : exe_file = os . path . join ( path , program ) if is_exe ( exe_file ) : return exe_file return None
search path for executable files with the given name .