Add parameter simple to remove .\ from relative path.
This commit is contained in:
parent
d9d10a843e
commit
85572ba406
1 changed files with 3 additions and 2 deletions
|
@ -126,7 +126,7 @@ class Path:
|
||||||
def relative_path(self):
|
def relative_path(self):
|
||||||
return self.relative_to(os.getcwd())
|
return self.relative_to(os.getcwd())
|
||||||
|
|
||||||
def relative_to(self, other):
|
def relative_to(self, other, simple=False):
|
||||||
other = Path(other)
|
other = Path(other)
|
||||||
|
|
||||||
if self == other:
|
if self == other:
|
||||||
|
@ -139,6 +139,7 @@ class Path:
|
||||||
relative = self.absolute_path
|
relative = self.absolute_path
|
||||||
relative = relative.replace(other.absolute_path, '', 1)
|
relative = relative.replace(other.absolute_path, '', 1)
|
||||||
relative = relative.lstrip(os.sep)
|
relative = relative.lstrip(os.sep)
|
||||||
|
if not simple:
|
||||||
relative = '.' + os.sep + relative
|
relative = '.' + os.sep + relative
|
||||||
return relative
|
return relative
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue