MCPcopy
hub / github.com/mitmproxy/mitmproxy / relative_path

Function relative_path

mitmproxy/optmanager.py:628–637  ·  view source on GitHub ↗

Make relative paths found in config files relative to said config file, instead of relative to where the command is ran.

(script_path: Path | str, *, relative_to: Path | str)

Source from the content-addressed store, hash-verified

626
627
628def relative_path(script_path: Path | str, *, relative_to: Path | str) -> Path:
629 """
630 Make relative paths found in config files relative to said config file,
631 instead of relative to where the command is ran.
632 """
633 script_path = Path(script_path)
634 # Edge case when $HOME is not an absolute path
635 if script_path.expanduser() != script_path and not script_path.is_absolute():
636 script_path = script_path.expanduser().absolute()
637 return (relative_to / script_path.expanduser()).absolute()

Callers 1

loadFunction · 0.85

Calls 1

PathClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…