Skip to content

Commit 1f0f53f

Browse files
authored
#156: Fixed implementation of BucketPath.parent (#157)
* #156: Fixed implementation of BucketPath.parent * Prepare release 0.13.0
1 parent dc24516 commit 1f0f53f

File tree

6 files changed

+38
-31
lines changed

6 files changed

+38
-31
lines changed

doc/changes/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# 📝 Changes
22

33
* [unreleased](unreleased.md)
4+
* [0.13.0](changes_0.13.0.md)
45
* [0.12.0](changes_0.12.0.md)
56
* [0.11.0](changes_0.11.0.md)
67
* [0.10.0](changes_0.10.0.md)
@@ -19,6 +20,7 @@
1920
hidden:
2021
---
2122
unreleased
23+
changes_0.13.0
2224
changes_0.12.0
2325
changes_0.11.0
2426
changes_0.10.0

doc/changes/changes_0.13.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 0.13.0 - 2024-08-07
2+
3+
## Bugfixes
4+
5+
* #156: Fixed implementation of BucketPath.parent

doc/design/bucketpath.rst

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Problem Description
88
Users of the BucketFS file system need to use it in various diffrent contexts like, from the outside of the
99
DB interacting with bucketfs, from within the DB when accessing BucketFS paths from within UDFs.
1010
Also common actions/tasks like listing a directory are pretty tedious when just interacting with
11-
the BucketFS API due to the fact that it does not know the concept of directories. So in
12-
order to simplify and streamline frequently used path operations and also provide a uniform
11+
the BucketFS API due to the fact that it does not know the concept of directories. So in
12+
order to simplify and streamline frequently used path operations and also provide a uniform
1313
interface accross the actual system (local path, http, ...) behind the BucketFS path we need
1414
to have an abstraction for the user.
1515

@@ -38,7 +38,7 @@ Challenges with Current BucketFS Interactions
3838
Proposed Solution
3939
=================
4040

41-
To address the identified issues with BucketFS interactions, we propose adding an abstraction layer that simplifies and standardizes these interactions across different contexts and operations. This approach is based on the design of the `pathlib` module in the Python standard library, which abstracts filesystem access across operating systems.
41+
To address the identified issues with BucketFS interactions, we propose adding an abstraction layer that simplifies and standardizes these interactions across different contexts and operations. This approach is based on the design of the `pathlib` module in the Python standard library, which abstracts filesystem access across operating systems.
4242

4343
Our proposed path abstraction layer will:
4444

@@ -152,50 +152,50 @@ Pathlike
152152
class Pathlike(Protocol):
153153
154154
@property
155-
def name:
155+
def name(self) -> str:
156156
"""
157157
A string representing the final path component, excluding the drive and root, if any.
158158
"""
159159
160160
@property
161-
def suffix:
161+
def suffix(self) -> str:
162162
"""
163163
The file extension of the final component, if any.
164164
"""
165165
166166
@property
167-
def root:
167+
def root(self) -> str:
168168
"""
169169
A string representing the root, if any.
170170
"""
171171
172172
@property
173-
def parent:
173+
def parent(self) -> PathLike:
174174
"""
175175
The logical parent of this path.
176176
"""
177177
178-
def as_uri():
178+
def as_uri(self) -> str:
179179
"""
180180
Represent the path as a file URI. Can be used to reconstruct the location/path.
181181
"""
182182
183-
def exists():
183+
def exists(self) -> bool:
184184
"""
185185
Return True if the path points to an existing file or directory.
186186
"""
187187
188-
def is_dir():
188+
def is_dir(self) -> bool:
189189
"""
190190
Return True if the path points to a directory, False if it points to another kind of file.
191191
"""
192192
193-
def is_file():
193+
def is_file(self) -> bool:
194194
"""
195195
Return True if the path points to a regular file, False if it points to another kind of file.
196196
"""
197197
198-
def read(chunk_size: int = 8192) -> Iterable[ByteString]:
198+
def read(self, chunk_size: int = 8192) -> Iterable[ByteString]:
199199
"""
200200
Read the content of a the file behind this path.
201201
@@ -212,9 +212,9 @@ Pathlike
212212
FileNotFoundError: If the file does not exist.
213213
"""
214214
215-
def write(data: ByteString | BinaryIO | Iterable[ByteString]):
215+
def write(self, data: ByteString | BinaryIO | Iterable[ByteString]):
216216
"""
217-
Writes data to a this path.
217+
Writes data to a this path.
218218
219219
After successfully writing to this path `exists` will yield true for this path.
220220
If the file already existed it will be overwritten.
@@ -226,7 +226,7 @@ Pathlike
226226
NotAFileError: if the pathlike object is not a file path.
227227
"""
228228
229-
def rm():
229+
def rm(self):
230230
"""
231231
Remove this file.
232232
@@ -238,7 +238,7 @@ Pathlike
238238
FileNotFoundError: If the file does not exist.
239239
"""
240240
241-
def rmdir(recursive: bool = False):
241+
def rmdir(self, recursive: bool = False):
242242
"""
243243
Removes this directory.
244244
@@ -254,15 +254,15 @@ Pathlike
254254
PermissionError: If recursive is false and the directory is not empty.
255255
"""
256256
257-
def joinpath(*pathsegements) -> Pathlike:
257+
def joinpath(self, *pathsegements) -> Pathlike:
258258
"""
259259
Calling this method is equivalent to combining the path with each of the given pathsegments in turn.
260260
261261
Returns:
262262
A new pathlike object pointing the combined path.
263263
"""
264264
265-
def walk() -> Tuple[Pathlike, List[str], List[str]]:
265+
def walk(self) -> Tuple[Pathlike, List[str], List[str]]:
266266
"""
267267
Generate the file names in a directory tree by walking the tree either top-down or bottom-up.
268268
@@ -274,7 +274,7 @@ Pathlike
274274
A 3-tuple of (dirpath, dirnames, filenames).
275275
"""
276276
277-
def iterdir() -> Generator[Pathlike, None, None]:
277+
def iterdir(self) -> Generator[Pathlike, None, None]:
278278
"""
279279
When the path points to a directory, yield path objects of the directory contents.
280280
@@ -286,7 +286,7 @@ Pathlike
286286
"""
287287
288288
# Overload / for joining, see also joinpath or `pathlib.Path`.
289-
def __truediv__():
289+
def __truediv__(self, other):
290290
"""
291291
"""
292292
@@ -310,7 +310,7 @@ Each backend must implement the ``as_uri`` method in a way that the location is
310310
"""
311311
Provides access to a bucket path served via http or https.
312312
"""
313-
313+
314314
# uri protocol specifies associated with this class
315315
protocol = ['bfs', 'bfss']
316316
@@ -322,7 +322,7 @@ Each backend must implement the ``as_uri`` method in a way that the location is
322322
bucket: used for accssing and interacting with to the underlying bucket.
323323
path: of the file within the bucket.
324324
"""
325-
325+
326326
# Pathlike functionalities
327327
# ...
328328
@@ -365,7 +365,7 @@ Each modifier:
365365
"""
366366
Modifies a pathlike object so it will be locked into a specified root.
367367
"""
368-
368+
369369
def __init__(self, path: Pathlike, chroot='/'):
370370
"""
371371
Create a new Chroot.
@@ -400,7 +400,7 @@ Each modifier:
400400
Returns:
401401
A path like object whith write proection.
402402
"""
403-
403+
404404
# Pathlike functionalities
405405
# Note: Non readonly actions should throw an exception
406406
# ...
@@ -445,7 +445,7 @@ Factory & Builders
445445
A Pathlike object for the given uri.
446446
"""
447447
# type: LocalPath, BucketPath, Chroot ...
448-
#
448+
#
449449
# Note: based on the uri the factory should assemble the apropriate Pathlike object.
450450
# E.g.:
451451
type = _determine_type(path)
@@ -494,4 +494,4 @@ Utilities
494494
Returns:
495495
A LocalPath (UdfPath) object.
496496
"""
497-
497+

exasol/bucketfs/_path.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def root(self) -> str:
4242
"""
4343

4444
@property
45-
def parent(self) -> str:
45+
def parent(self) -> PathLike:
4646
"""
4747
The logical parent of this path.
4848
"""
@@ -289,8 +289,8 @@ def root(self) -> str:
289289
return self._path.root
290290

291291
@property
292-
def parent(self) -> str:
293-
return self._path.parent.name
292+
def parent(self) -> PathLike:
293+
return BucketPath(self._path.parent, self._bucket_api)
294294

295295
def as_uri(self) -> str:
296296
return self._path.as_uri()

exasol/bucketfs/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
# Do not edit this file manually!
66
# If you need to change the version, do so in the project.toml, e.g. by using `poetry version X.Y.Z`.
77
MAJOR = 0
8-
MINOR = 12
8+
MINOR = 13
99
PATCH = 0
1010
VERSION = f"{MAJOR}.{MINOR}.{PATCH}"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ packages = [
1010
{include = "exasol"},
1111
{include = "exasol_bucketfs_utils_python"}
1212
]
13-
version = "0.12.0"
13+
version = "0.13.0"
1414
description = "BucketFS utilities for the Python programming language"
1515

1616
license = "MIT"

0 commit comments

Comments
 (0)