find_path
(function from pyomo.common.fileutils)
- pyomo.common.fileutils.find_path(name, validate, cwd=True, mode=4, ext=None, pathlist=[], allow_pathlist_deep_references=True)[source]
Locate a path, given a set of search parameters
- Parameters:
name (str) – The name to locate. The name may contain references to a user’s home directory (
~user), environment variables (${HOME}/bin), and shell wildcards (?and*); all of which will be expanded.validate (function) – A function to call to validate the path (used by find_file and find_dir to discriminate files and directories)
cwd (bool) – Start by looking in the current working directory [default: True]
mode (mask) – If not None, only return entries that can be accessed for reading/writing/executing. Valid values are the inclusive OR of {os.R_OK, os.W_OK, os.X_OK} [default:
os.R_OK]ext (str or iterable of str) – If not None, also look for name+ext [default: None]
pathlist (str or iterable of str) – A list of strings containing paths to search, each string contains a single path. If pathlist is a string, then it is first split using os.pathsep to generate the pathlist [default:
[]].allow_pathlist_deep_references (bool) – If allow_pathlist_deep_references is True and the name appears to be a relative path, allow deep reference matches relative to directories in the pathlist (e.g., if name is
foo/my.exeand/usr/binis in the pathlist, thenfind_file()could return/usr/bin/foo/my.exe). If allow_pathlist_deep_references is False and the name appears to be a relative path, then only matches relative to the current directory are allowed (assuming cwd==True). [default: True]
Notes
find_path uses glob, so the path and/or name may contain wildcards. The first matching entry is returned.