File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,16 @@ def common_start(values):
228
228
start = start [:- 1 ]
229
229
230
230
231
+ def is_relative_to (path , base ):
232
+ """
233
+ Check if 'path' is relative to 'base'.
234
+ """
235
+ try :
236
+ path .relative_to (base )
237
+ return True
238
+ except ValueError :
239
+ return False
240
+
231
241
def make_path_relative (filename , base ):
232
242
"""
233
243
Returns the relative path of `filename` with respect to the `base` directory,
@@ -252,7 +262,7 @@ def make_path_relative(filename, base):
252
262
253
263
offset = ""
254
264
for i in range (3 ):
255
- if file_path . is_relative_to (base_path ):
265
+ if is_relative_to (file_path , base_path ):
256
266
return str (offset / file_path .relative_to (base_path ))
257
267
base_path = base_path .parent
258
268
offset /= PurePath (".." )
You can’t perform that action at this time.
0 commit comments