Skip to content

Commit

Permalink
run black and isort
Browse files Browse the repository at this point in the history
  • Loading branch information
florianziemen committed Nov 14, 2024
1 parent 0a737a9 commit ea43642
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions slkspec/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(
self.write_through = False
self.delay = delay
self._file_queue = _file_queue
# print(self._file)
# print(self._file)
with _lock:
if not Path(self._file).exists() or override:
self._file_queue.put((self._url, str(Path(self._file).parent)))
Expand Down Expand Up @@ -193,23 +193,26 @@ def seek(self, target: int) -> int: # type: ignore
self._cache_files()
return self._file_obj.seek(target) # type: ignore

def _mkdirs(self, path : Union[str, Path]) -> None:
def _mkdirs(self, path: Union[str, Path]) -> None:
rp = os.path.realpath(path)
if os.access(rp, os.F_OK):
if not os.access(rp, os.W_OK):
raise PermissionError(f"Cannot write to directory, {rp}, needed for downloading data. Probably, you lack access privileges.")
raise PermissionError(
f"Cannot write to directory, {rp}, needed for downloading data. Probably, you lack access privileges."
)
return
components = Path(rp).parts[1:]
for i in range (len(components)):
subpath = Path("/", *components[:i+1])
for i in range(len(components)):
subpath = Path("/", *components[: i + 1])
if not os.access(subpath, os.F_OK):
try:
os.mkdir(subpath)
except PermissionError as e:
raise PermissionError(f"Cannot create or access directory, {e.filename}, needed for downloading data. Probably, you lack access privileges.")
raise PermissionError(
f"Cannot create or access directory, {e.filename}, needed for downloading data."
)
os.chmod(subpath, self.dir_permissions)


@staticmethod
def readable() -> Literal[True]:
"""Compatibility method."""
Expand Down

0 comments on commit ea43642

Please sign in to comment.