common.tools: Add a function for relative pathes

rel_path(a, b) is the absolute path of b, taken relative to a.
If b is already an absolute path, rel_path(a, b) is b.
This commit is contained in:
Nicolas Braud-Santoni 2016-09-11 23:05:36 +02:00
parent 81778136bc
commit 734afd892b
No known key found for this signature in database
GPG key ID: 9D4F88010CFE19E3

View file

@ -133,3 +133,8 @@ def copy_tree(from_path, to_path):
for path in files:
copy(os.path.join(abs_prefix, path),
os.path.join(to_path, prefix, path))
def rel_path(base, path):
import os.path
return os.path.join(os.path.dirname(base), path)