BlendPath: don't use os.path.join() for slash notations

The BlendPath should just use forward slashes, and not be depending on the
current platform.
This commit is contained in:
Sybren A. Stüvel
2019-01-02 15:14:50 +01:00
parent 0e392f27c9
commit d81fe590db
2 changed files with 7 additions and 2 deletions
+2 -2
View File
@@ -79,13 +79,13 @@ class BlendPath(bytes):
sub = BlendPath(subpath)
if sub.is_absolute():
raise ValueError("'a / b' only works when 'b' is a relative path")
return BlendPath(os.path.join(self, sub))
return BlendPath(self.rstrip(b'/') + b'/' + sub)
def __rtruediv__(self, parentpath: bytes):
"""Slash notation like pathlib.Path."""
if self.is_absolute():
raise ValueError("'a / b' only works when 'b' is a relative path")
return BlendPath(os.path.join(parentpath, self))
return BlendPath(parentpath.rstrip(b'/') + b'/' + self)
def to_path(self) -> pathlib.PurePath:
"""Convert this path to a pathlib.PurePath.