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

Function is_relative_to

library/python/pytest/module_utils.py:7–21  ·  view source on GitHub ↗

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

(path, parent)

Source from the content-addressed store, hash-verified

5
6
7def is_relative_to(path, parent):
8 """
9 A polyfill for pathlib.Path.is_relative_to (string-based implementation).
10 Does NOT involve filesystem operations.
11 """
12 path = os.path.normpath(path)
13 parent = os.path.normpath(parent)
14
15 if path == parent:
16 return True
17
18 if not parent.endswith(os.sep):
19 parent += os.sep
20
21 return path.startswith(parent)
22
23
24def relative_to(path, parent):

Callers 1

get_proper_module_pathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected