MCPcopy Create free account
hub / github.com/bugy/script-server / relative_path

Function relative_path

src/utils/file_utils.py:145–161  ·  view source on GitHub ↗
(path, parent_path)

Source from the content-addressed store, hash-verified

143
144
145def relative_path(path, parent_path):
146 path = normalize_path(path)
147 parent_path = normalize_path(parent_path)
148
149 if os_utils.is_win():
150 path = path.capitalize()
151 parent_path = parent_path.capitalize()
152
153 if not path.startswith(parent_path):
154 raise ValueError(path + ' is not subpath of ' + parent_path)
155
156 relative_path = path[len(parent_path):]
157
158 if relative_path.startswith(os.path.sep):
159 return relative_path[1:]
160
161 return relative_path
162
163
164def split_all(path):

Callers

nothing calls this directly

Calls 1

normalize_pathFunction · 0.85

Tested by

no test coverage detected