hpcflow.sdk.core.utils.get_relative_path#

hpcflow.sdk.core.utils.get_relative_path(path1, path2)#

Get relative path components between two paths.

Parameters:
Returns:

relative_path – The path components in path1 that are not in path2.

Return type:

tuple of (str or int or float)

Raises:

ValueError – If the two paths do not share a common ancestor of path components, or if path2 is longer than path1.

Notes

This function behaves like a simplified PurePath(*path1).relative_to(PurePath(*path2)) from the pathlib module, but where path components can include non-strings.

Examples

>>> get_relative_path(('A', 'B', 'C'), ('A',))
('B', 'C')
>>> get_relative_path(('A', 'B'), ('A', 'B'))
()