datalad_next.patches.distribution_dataset

DatasetParameter support for resolve_path()

This is the standard result of EnsureDataset, which unlike the datalad-core version actually carries a Dataset instance.

This patch ensure the traditional handling of "dataset instance from a string-type parameter in this context.

datalad_next.patches.distribution_dataset.resolve_path(path, ds=None, ds_resolved=None)[source]

Resolve a path specification (against a Dataset location)

Any path is returned as an absolute path. If, and only if, a dataset object instance is given as ds, relative paths are interpreted as relative to the given dataset. In all other cases, relative paths are treated as relative to the current working directory.

Note however, that this function is not able to resolve arbitrarily obfuscated path specifications. All operations are purely lexical, and no actual path resolution against the filesystem content is performed. Consequently, common relative path arguments like '../something' (relative to PWD) can be handled properly, but things like 'down/../under' cannot, as resolving this path properly depends on the actual target of any (potential) symlink leading up to '..'.

Parameters:
  • path (str or PathLike or list) -- Platform-specific path specific path specification. Multiple path specifications can be given as a list

  • ds (Dataset or PathLike or None) -- Dataset instance to resolve relative paths against.

  • ds_resolved (Dataset or None) -- A dataset instance that was created from ds outside can be provided to avoid multiple instantiation on repeated calls.

Returns:

When a list was given as input a list is returned, a Path instance otherwise.

Return type:

pathlib.Path object or list(Path)