def find_executable(name, names=None, required=True):
path_from_env = os.environ.get(name.upper())<EOL>if path_from_env is not None:<EOL><INDENT>return path_from_env<EOL><DEDENT>names = [name] + (names or [])<EOL>for _name in names:<EOL><INDENT>if osp.isabs(_name):<EOL><INDENT>return _name<EOL><DEDENT>paths = os.environ.get('<STR_LIT>', '<STR_LIT>').split(os.pathsep)<EOL>eax = find_in_paths(_name, paths)<EOL>if eax:<EOL><INDENT>return eax<EOL><DEDENT><DEDENT>if required:<EOL><INDENT>raise NameError('<STR_LIT>' % name)<EOL><DEDENT>else:<EOL><INDENT>return name<EOL><DEDENT>
Utility function to find an executable in PATH
    name: program to find. Use given value if absolute path

    names: list of additional names. For instance

       >>> find_executable('sed', names=['gsed'])

    required: If True, then the function raises an Exception
    if the program is not found else the function returns name if
    the program is not found.