Path Expansion#
Conversion between pathnames with and without expanded %ENVIRONMENT_VARIABLES%.
- mhi.common.path.expand_path(path: str | PurePath, abspath: bool = False, folder: str | PurePath | None = None) str#
Expand
path, by replacing a ~ or ~user prefix, as well as expanding any $var, ${var} and %var% patterns in the path.
- mhi.common.path.expand_paths(paths: Sequence[str | PurePath], abspath: bool = False, folder: str | PurePath | None = None) List[str]#
Expand
paths, by replacing a ~ or ~user prefix, as well as expanding any $var, ${var} and %var% patterns in the paths.- Parameters:
- Returns:
A list of expanded
paths, optionally forced to absolute paths.- Return type:
List[str]
- mhi.common.path.contract_path(path)#
Look for and replace any substring of the path that matches a value found in an environment variable with that environment variable: ${key} or %key%. Additionally, replace a path starting with the user’s home path with ~.
- mhi.common.path.contract_paths(paths)#
Look for and replace any substring of the paths that matches a value found in an environment variable with that environment variable: ${key} or %key%. Additionally, replace paths starting with the user’s home path with ~.