summaryrefslogtreecommitdiff
path: root/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpers.py')
-rw-r--r--helpers.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/helpers.py b/helpers.py
new file mode 100644
index 0000000..faf14e7
--- /dev/null
+++ b/helpers.py
@@ -0,0 +1,9 @@
+from os import path
+from pathlib import Path
+
+
+def relative_path(*, to, ref):
+ # pathlib.Path(x).relative_to(y) cannot handle y not being under x,
+ # os.path.dirname('x') yields '' rather than '.'.
+ # 😮‍💨
+ return path.relpath(to, Path(ref).parent)