MCPcopy Create free account
hub / github.com/SOUI2/soui / find_program

Function find_program

third-part/jsoncpp/doxybuild.py:26–39  ·  view source on GitHub ↗

find a program in folders path_lst, and sets env[var] @param filenames: a list of possible names of the program to search for @return: the full path of the filename if found, or '' if filename could not be found

(*filenames)

Source from the content-addressed store, hash-verified

24 os.chdir(prevdir)
25
26def find_program(*filenames):
27 """find a program in folders path_lst, and sets env[var]
28 @param filenames: a list of possible names of the program to search for
29 @return: the full path of the filename if found, or '' if filename could not be found
30"""
31 paths = os.environ.get('PATH', '').split(os.pathsep)
32 suffixes = ('win32' in sys.platform) and '.exe .com .bat .cmd' or ''
33 for filename in filenames:
34 for name in [filename+ext for ext in suffixes.split(' ')]:
35 for directory in paths:
36 full_path = os.path.join(directory, name)
37 if os.path.isfile(full_path):
38 return full_path
39 return ''
40
41def do_subst_in_file(targetfile, sourcefile, dict):
42 """Replace all instances of the keys of dict with their values.

Callers 1

mainFunction · 0.85

Calls 2

getMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected