Skip to content

Commit

Permalink
#139 Removed archive extension in as_udf_path
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsimb committed May 23, 2024
1 parent 7be848b commit 3c9520e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 135 deletions.
11 changes: 10 additions & 1 deletion exasol/bucketfs/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from exasol.bucketfs._service import Service
from exasol.bucketfs._error import BucketFsError

ARCHIVE_SUFFIXES = [".tar", ".gz", ".tgz", ".zip", ".tar"]


class StorageBackend(Enum):
onprem = auto()
Expand Down Expand Up @@ -170,6 +172,12 @@ def __truediv__(self, other):
"""


def _remove_archive_suffix(path: PurePath) -> PurePath:
while path.suffix in ARCHIVE_SUFFIXES:
path = path.with_suffix('')
return path


class _BucketFile:
"""
A node in a perceived file structure of a bucket.
Expand Down Expand Up @@ -288,7 +296,8 @@ def as_uri(self) -> str:
return self._path.as_uri()

def as_udf_path(self) -> str:
return str(PurePath(self._bucket_api.udf_path) / self._path)
return str(PurePath(self._bucket_api.udf_path) /
_remove_archive_suffix(self._path))

def exists(self) -> bool:
return self._navigate() is not None
Expand Down
Loading

0 comments on commit 3c9520e

Please sign in to comment.