MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / relpath

Function relpath

tests/test_general.py:1351–1361  ·  view source on GitHub ↗

A 'safe' alternative to os.path.relpath(). Avoids an exception on Windows if the drive needs to change - in this case we use os.path.abspath().

(path, start=None)

Source from the content-addressed store, hash-verified

1349
1350
1351def relpath(path, start=None):
1352 '''
1353 A 'safe' alternative to os.path.relpath(). Avoids an exception on Windows
1354 if the drive needs to change - in this case we use os.path.abspath().
1355 '''
1356 try:
1357 return os.path.relpath(path, start)
1358 except ValueError:
1359 # os.path.relpath() fails if trying to change drives.
1360 assert platform.system() == 'Windows'
1361 return os.path.abspath(path)
1362
1363
1364def test_open():

Callers 2

test_openFunction · 0.70
test_open2Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…