Skip to content

Commit 7516128

Browse files
committed
Added custom "is_relative_to" function to support python versions below 3.9
1 parent bfb73f8 commit 7516128

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

saenopy/result_file.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ def common_start(values):
228228
start = start[:-1]
229229

230230

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+
231241
def make_path_relative(filename, base):
232242
"""
233243
Returns the relative path of `filename` with respect to the `base` directory,
@@ -252,7 +262,7 @@ def make_path_relative(filename, base):
252262

253263
offset = ""
254264
for i in range(3):
255-
if file_path.is_relative_to(base_path):
265+
if is_relative_to(file_path,base_path):
256266
return str(offset / file_path.relative_to(base_path))
257267
base_path = base_path.parent
258268
offset /= PurePath("..")

0 commit comments

Comments
 (0)