Skip to content

Commit

Permalink
✅ Add temporary directory creation function
Browse files Browse the repository at this point in the history
  • Loading branch information
fbriol committed Jan 16, 2024
1 parent 087e603 commit f2b293f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion zcollection/tests/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""
from typing import Any, Iterator
import pathlib
import tempfile

import fsspec
import fsspec.implementations.memory
Expand All @@ -23,14 +24,19 @@
S3_IMPORT_EXCEPTION = str(err)


def tempdir(tmpdir) -> pathlib.Path:
"""Create a temporary directory."""
return pathlib.Path(tempfile.mkdtemp(dir=str(tmpdir)))


class Local:
"""Local files system."""

def __init__(self, tmpdir, protocol) -> None:
#: The filesystem.
self.fs: fsspec.AbstractFileSystem = fsspec.filesystem(protocol)
#: The root directory.
self.root = pathlib.Path(tmpdir)
self.root = tempdir(pathlib.Path(tmpdir))
#: The collection directory.
self.collection: pathlib.Path = self.root.joinpath('collection')
#: The view directory.
Expand Down

0 comments on commit f2b293f

Please sign in to comment.