flatfs 0.5.0__tar.gz → 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flatfs-0.5.0 → flatfs-0.7.0}/PKG-INFO +2 -1
- flatfs-0.7.0/flatfs/__init__.py +1 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/aio/backends.py +3 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/aio/helpers.py +2 -2
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/aio/interface.py +13 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/backends.py +21 -9
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/helpers.py +3 -1
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/interface.py +13 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/pyproject.toml +4 -1
- flatfs-0.5.0/flatfs/__init__.py +0 -1
- {flatfs-0.5.0 → flatfs-0.7.0}/LICENSE.txt +0 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/README.md +0 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/_compat.py +0 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/_export.py +0 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/_utils.py +0 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/aio/__init__.py +0 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/aio/api.py +0 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/api.py +0 -0
- {flatfs-0.5.0 → flatfs-0.7.0}/flatfs/exc.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flatfs
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: Minimal filesystem abstraction with pluggable backends, treating paths as keys and file contents as values.
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE.txt
|
|
@@ -12,6 +12,7 @@ Classifier: Development Status :: 4 - Beta
|
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: Operating System :: OS Independent
|
|
14
14
|
Classifier: Topic :: Software Development :: Libraries
|
|
15
|
+
Requires-Dist: atomicwrites (>=1.4.1,<2.0.0)
|
|
15
16
|
Project-URL: Bug Tracker, https://github.com/mwiatrzyk/flatfs/issues
|
|
16
17
|
Project-URL: Repository, https://github.com/mwiatrzyk/flatfs
|
|
17
18
|
Description-Content-Type: text/markdown
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.7.0"
|
|
@@ -38,9 +38,9 @@ async def async_read_text(
|
|
|
38
38
|
@export
|
|
39
39
|
async def async_write_text(
|
|
40
40
|
fs: SupportsAsyncWriteChunks, path: str, data: str, encoding: str = "utf-8", chunk_size: int = 65535
|
|
41
|
-
):
|
|
41
|
+
) -> int:
|
|
42
42
|
"""Async variant of the :func:`write_text` helper."""
|
|
43
|
-
await async_write_bytes(fs, path, data.encode(encoding), chunk_size)
|
|
43
|
+
return await async_write_bytes(fs, path, data.encode(encoding), chunk_size)
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
@export
|
|
@@ -48,6 +48,19 @@ class SupportsAsyncWriteChunks(Protocol):
|
|
|
48
48
|
class AsyncFlatFsReader(SupportsAsyncReadChunks, Protocol):
|
|
49
49
|
"""Async variant of the :class:`FlatFsReader` protocol."""
|
|
50
50
|
|
|
51
|
+
def uri(self, path: str) -> str:
|
|
52
|
+
"""Get a unique URI string for the given path.
|
|
53
|
+
|
|
54
|
+
This method is meant to be used to get a fullpath-like representation
|
|
55
|
+
of the given path in a form of a URI string.
|
|
56
|
+
|
|
57
|
+
.. important::
|
|
58
|
+
The returned URI-like string is meant to be used for presentation
|
|
59
|
+
purposes only, where a sort of fullpath is needed (e.g. to display
|
|
60
|
+
error pointing to a missing file).
|
|
61
|
+
"""
|
|
62
|
+
...
|
|
63
|
+
|
|
51
64
|
def scan(self) -> AsyncIterator[str]:
|
|
52
65
|
"""Return iterator that yields normalized paths to existing files.
|
|
53
66
|
|
|
@@ -5,6 +5,8 @@ import os
|
|
|
5
5
|
import pathlib
|
|
6
6
|
from typing import Generator, Iterator, Optional
|
|
7
7
|
|
|
8
|
+
from atomicwrites import atomic_write # type: ignore
|
|
9
|
+
|
|
8
10
|
from flatfs.exc import PathAccessError, PathNotFoundError
|
|
9
11
|
from flatfs.interface import Stat
|
|
10
12
|
|
|
@@ -15,9 +17,9 @@ __all__ = export = _export.Export() # type: ignore
|
|
|
15
17
|
|
|
16
18
|
@export
|
|
17
19
|
class LocalFlatFs:
|
|
18
|
-
"""FlatFS implementation using local filesystem to store files.
|
|
20
|
+
"""FlatFS implementation using a local filesystem to store files.
|
|
19
21
|
|
|
20
|
-
You can use this to access files
|
|
22
|
+
You can use this to access files within an existing directory (the paths are
|
|
21
23
|
then relative to *root_dir*), or to create a completely new filesystem
|
|
22
24
|
inside an empty directory.
|
|
23
25
|
|
|
@@ -27,19 +29,19 @@ class LocalFlatFs:
|
|
|
27
29
|
:param exclude:
|
|
28
30
|
The glob patterns of paths to exclude.
|
|
29
31
|
|
|
30
|
-
For example, you may want to exclude ``.git`` directory when you use
|
|
31
|
-
FlatFS to access content of
|
|
32
|
+
For example, you may want to exclude the ``.git`` directory when you use
|
|
33
|
+
FlatFS to access the content of a Git repository.
|
|
32
34
|
|
|
33
|
-
For more details on pattern syntax
|
|
35
|
+
For more details on the pattern syntax, check :mod:`fnmatch` which is
|
|
34
36
|
used underneath.
|
|
35
37
|
|
|
36
38
|
:param include:
|
|
37
39
|
The glob patterns of paths to include.
|
|
38
40
|
|
|
39
|
-
These can only be paths from
|
|
40
|
-
may wish to allow
|
|
41
|
+
These can only be paths from within the root directory. For example, you
|
|
42
|
+
may wish to allow only the ``src`` and ``test`` directories, not all files.
|
|
41
43
|
|
|
42
|
-
For more details on pattern syntax
|
|
44
|
+
For more details on the pattern syntax, check :mod:`fnmatch` which is
|
|
43
45
|
used underneath.
|
|
44
46
|
"""
|
|
45
47
|
|
|
@@ -77,6 +79,9 @@ class LocalFlatFs:
|
|
|
77
79
|
elif not self.__is_excluded(fullrelpath) and self.__is_included(fullrelpath):
|
|
78
80
|
yield fullrelpath
|
|
79
81
|
|
|
82
|
+
def uri(self, path: str) -> str:
|
|
83
|
+
return f"file://{self.__make_abspath(path)}"
|
|
84
|
+
|
|
80
85
|
def scan(self) -> Iterator[str]:
|
|
81
86
|
return self.__walk(self.__root_dir, "")
|
|
82
87
|
|
|
@@ -108,7 +113,7 @@ class LocalFlatFs:
|
|
|
108
113
|
def write_chunks(self, path: str, chunk_gen: Generator[bytes, None, None]) -> Generator[int, None, None]:
|
|
109
114
|
abspath = self.__make_abspath(path)
|
|
110
115
|
abspath.parent.mkdir(parents=True, exist_ok=True)
|
|
111
|
-
with abspath
|
|
116
|
+
with atomic_write(abspath, mode="wb", overwrite=True) as fd:
|
|
112
117
|
for chunk in chunk_gen:
|
|
113
118
|
yield fd.write(chunk)
|
|
114
119
|
|
|
@@ -117,6 +122,10 @@ class LocalFlatFs:
|
|
|
117
122
|
if not abspath.is_file():
|
|
118
123
|
raise PathNotFoundError(path)
|
|
119
124
|
abspath.unlink()
|
|
125
|
+
current = abspath.parent
|
|
126
|
+
while len(os.listdir(current)) == 0:
|
|
127
|
+
current.rmdir()
|
|
128
|
+
current = current.parent
|
|
120
129
|
|
|
121
130
|
|
|
122
131
|
@export
|
|
@@ -139,6 +148,9 @@ class InMemoryFlatFs:
|
|
|
139
148
|
normalized_key = _utils.normalize_path(path)
|
|
140
149
|
return normalized_key
|
|
141
150
|
|
|
151
|
+
def uri(self, path: str) -> str:
|
|
152
|
+
return f"mem://{self.__make_key(path)}"
|
|
153
|
+
|
|
142
154
|
def scan(self) -> Iterator[str]:
|
|
143
155
|
return iter(self.__storage.keys())
|
|
144
156
|
|
|
@@ -87,12 +87,14 @@ def read_text(fs: SupportsReadChunks, path: str, encoding: str = "utf-8", chunk_
|
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
@export
|
|
90
|
-
def write_text(fs: SupportsWriteChunks, path: str, data: str, encoding: str = "utf-8", chunk_size: int = 65535):
|
|
90
|
+
def write_text(fs: SupportsWriteChunks, path: str, data: str, encoding: str = "utf-8", chunk_size: int = 65535) -> int:
|
|
91
91
|
"""Create new text file or replace existing with given text data.
|
|
92
92
|
|
|
93
93
|
Uses :func:`write_bytes` underneath and just encodes given *data* with
|
|
94
94
|
provided *encoding*, which is ``utf-8`` by default.
|
|
95
95
|
|
|
96
|
+
Returns the number of bytes written.
|
|
97
|
+
|
|
96
98
|
:param fs:
|
|
97
99
|
FlatFS object to write to.
|
|
98
100
|
|
|
@@ -71,6 +71,19 @@ class SupportsWriteChunks(Protocol):
|
|
|
71
71
|
class FlatFsReader(SupportsReadChunks, Protocol):
|
|
72
72
|
"""Read-only interface to access files in the flat filesystem."""
|
|
73
73
|
|
|
74
|
+
def uri(self, path: str) -> str:
|
|
75
|
+
"""Get a unique URI string for the given path.
|
|
76
|
+
|
|
77
|
+
This method is meant to be used to get a fullpath-like representation
|
|
78
|
+
of the given path in a form of a URI string.
|
|
79
|
+
|
|
80
|
+
.. important::
|
|
81
|
+
The returned URI-like string is meant to be used for presentation
|
|
82
|
+
purposes only, where a sort of fullpath is needed (e.g. to display
|
|
83
|
+
error pointing to a missing file).
|
|
84
|
+
"""
|
|
85
|
+
...
|
|
86
|
+
|
|
74
87
|
def scan(self) -> Iterator[str]:
|
|
75
88
|
"""Return iterator that yields normalized paths to existing files."""
|
|
76
89
|
...
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "flatfs"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.7.0"
|
|
4
4
|
description = "Minimal filesystem abstraction with pluggable backends, treating paths as keys and file contents as values."
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Maciej Wiatrzyk", email = "maciej.wiatrzyk@gmail.com"}
|
|
@@ -17,6 +17,7 @@ classifiers = [
|
|
|
17
17
|
]
|
|
18
18
|
requires-python = ">=3.9,<4"
|
|
19
19
|
dependencies = [
|
|
20
|
+
"atomicwrites (>=1.4.1,<2.0.0)"
|
|
20
21
|
]
|
|
21
22
|
|
|
22
23
|
[project.urls]
|
|
@@ -36,3 +37,5 @@ pytest-cov = "^7.1.0"
|
|
|
36
37
|
ruff = "^0.15.12"
|
|
37
38
|
mypy = "^1.19.1"
|
|
38
39
|
bumpify = "^0.5.1"
|
|
40
|
+
sphinx = "7.4.7"
|
|
41
|
+
sphinx-rtd-theme = "^3.1.0"
|
flatfs-0.5.0/flatfs/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.5.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|