gaps.utilities.resolve_path#

resolve_path(path, base_dir)[source]#

Resolve a file path represented by the input string.

This function resolves the input string if it resembles a path. Specifically, the string will be resolved if it starts with “./” or “..”, or it if it contains either “./” or “..” somewhere in the string body. Otherwise, the string is returned unchanged, so this function is safe to call on any string, even ones that do not resemble a path. This method delegates the “resolving” logic to pathlib.Path.resolve(). This means the path is made absolute, symlinks are resolved, and “..” components are eliminated. If the path input starts with “./” or “..”, it is assumed to be w.r.t the config directory, not the run directory.

Parameters:
  • path (str) – Input file path.

  • base_dir (path-like) – Base path to directory from which to resolve path string (typically current directory).

Returns:

str – The resolved path.