MCPcopy Create free account
hub / github.com/catboost/catboost / relative_to

Function relative_to

library/python/pytest/module_utils.py:24–42  ·  view source on GitHub ↗

A polyfill for pathlib.Path.relative_to (string-based implementation). Does NOT involve filesystem operations.

(path, parent)

Source from the content-addressed store, hash-verified

22
23
24def relative_to(path, parent):
25 """
26 A polyfill for pathlib.Path.relative_to (string-based implementation).
27 Does NOT involve filesystem operations.
28 """
29 path = os.path.normpath(path)
30 parent = os.path.normpath(parent)
31
32 if path == parent:
33 return ''
34
35 if not parent.endswith(os.sep):
36 parent += os.sep
37
38 # Check if path starts with parent
39 if not path.startswith(parent):
40 raise ValueError('Path {} is not relative to {}', path, parent)
41
42 return path[len(parent) :]
43
44
45def get_module_file_path(module_name):

Callers 1

get_proper_module_pathFunction · 0.85

Calls 1

lenFunction · 0.85

Tested by

no test coverage detected