18 lines
476 B
Python
18 lines
476 B
Python
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def load_func_body_from_file(filename: Path) -> str:
|
|
with open(filename, "r") as infile:
|
|
return infile.read().rstrip()
|
|
|
|
|
|
def convert_to_relative(path: Path, target: Path) -> Path:
|
|
major = sys.version_info.major
|
|
minor = sys.version_info.minor
|
|
|
|
if major >= 3 and minor >= 12:
|
|
return path.relative_to(target, walk_up=True)
|
|
else:
|
|
return Path(os.path.relpath(str(path), start=str(target))) |