#NEWLINE# def __init__( self , name , fullpath = None , silent = False , search_dir = None ) : #NEWLINE# #INDENT# self . name = name #NEWLINE# self . fullpath = None #NEWLINE# if ( fullpath is not None ) : #NEWLINE# #INDENT# if ( not isinstance ( fullpath , list ) ) : #NEWLINE# #INDENT# self . fullpath = [ fullpath ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . fullpath = fullpath #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . fullpath = [ shutil . which ( name ) ] #NEWLINE# if ( ( self . fullpath [ 0 ] is None ) and ( search_dir is not None ) ) : #NEWLINE# #INDENT# trial = os . path . join ( search_dir , name ) #NEWLINE# suffix = os . path . splitext ( trial ) [ ( - 1 ) ] . lower ( ) [ 1 : ] #NEWLINE# if ( mesonlib . is_windows ( ) and ( ( suffix == 'exe' ) or ( suffix == 'com' ) or ( suffix == 'bat' ) ) ) : #NEWLINE# #INDENT# self . fullpath = [ trial ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not mesonlib . is_windows ( ) ) and os . access ( trial , os . X_OK ) ) : #NEWLINE# #INDENT# self . fullpath = [ trial ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# first_line = open ( trial ) . readline ( ) . strip ( ) #NEWLINE# if first_line . startswith ( '#!' ) : #NEWLINE# #INDENT# commands = first_line [ 2 : ] . split ( '#' ) [ 0 ] . strip ( ) . split ( ) #NEWLINE# if mesonlib . is_windows ( ) : #NEWLINE# #INDENT# commands [ 0 ] = commands [ 0 ] . split ( '/' ) [ ( - 1 ) ] #NEWLINE# if ( commands [ 0 ] == 'env' ) : #NEWLINE# #INDENT# commands = commands [ 1 : ] #NEWLINE# #UNINDENT# #UNINDENT# self . fullpath = ( commands + [ trial ] ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( not silent ) : #NEWLINE# #INDENT# if self . found ( ) : #NEWLINE# #INDENT# mlog . log ( 'Program' , mlog . bold ( name ) , 'found:' , mlog . green ( 'YES' ) , ( '(%s)' % ' ' . join ( self . fullpath ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mlog . log ( 'Program' , mlog . bold ( name ) , 'found:' , mlog . red ( 'NO' ) )