find_dir

(function from pyomo.common.fileutils)

pyomo.common.fileutils.find_dir(dirname, cwd=True, mode=4, pathlist=[], allow_pathlist_deep_references=True)[source]

Locate a directory, given a set of search parameters

Parameters:
  • dirname (str) – The directory 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.

  • cwd (bool) – Start by looking in the current working directory [default: True]

  • mode (mask) – If not None, only return directories 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]

  • 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 dirname appears to be a relative path, allow deep reference matches relative to directories in the pathlist (e.g., if dirname is foo/bar and /usr/bin is in the pathlist, then find_dir() could return /usr/bin/foo/bar). If allow_pathlist_deep_references is False and the dirname appears to be a relative path, then only matches relative to the current directory are allowed (assuming cwd==True). [default: True]

Notes

find_dir uses glob, so the path and/or directory name may contain wildcards. The first matching directory is returned.