Skip to content

Commit

Permalink
upath: fix resolving issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-- committed Feb 23, 2024
1 parent 759fe91 commit 58f951e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions upath/_flavour.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from fsspec.spec import AbstractFileSystem

from upath._compat import str_remove_prefix
from upath._compat import str_remove_suffix
from upath._flavour_sources import FileSystemFlavourBase
from upath._flavour_sources import flavour_registry
from upath._protocol import get_upath_protocol
Expand Down Expand Up @@ -238,6 +239,10 @@ def stringify_path(pth: PathOrStr) -> str:
out = str(pth)
return normalize_empty_netloc(out)

def empty_part_join(self, path: str, *paths: str) -> str:
sep = self.sep
return sep.join([str_remove_suffix(path, sep), *paths])

def strip_protocol(self, pth: PathOrStr) -> str:
pth = self.stringify_path(pth)
return self._spec._strip_protocol(pth)
Expand Down Expand Up @@ -267,17 +272,21 @@ def isabs(self, path: PathOrStr) -> bool:
return self.strip_protocol(path).startswith(self.root_marker)

def join(self, path: PathOrStr, *paths: PathOrStr) -> str:
if self.supports_empty_parts:
_join = self.empty_part_join
else:
_join = posixpath.join
if self.netloc_is_anchor:
drv, p0 = self.splitdrive(path)
pN = map(self.stringify_path, paths)
pN = list(map(self.stringify_path, paths))
if not drv and not p0:
path, *pN = pN
drv, p0 = self.splitdrive(path)
return drv + posixpath.join(p0 or self.sep, *pN)
return drv + _join(p0 or self.sep, *pN)
else:
p0 = str(self.strip_protocol(path))
pN = map(self.stringify_path, paths)
return posixpath.join(p0, *pN)
return _join(p0, *pN)

def split(self, path: PathOrStr):
stripped_path = self.strip_protocol(path)
Expand Down

0 comments on commit 58f951e

Please sign in to comment.