fastar 0.8.0__pp39-pypy39_pp73-musllinux_1_2_i686.whl

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.
fastar/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .fastar import *
2
+
3
+ __doc__ = fastar.__doc__
4
+ if hasattr(fastar, "__all__"):
5
+ __all__ = fastar.__all__
fastar/__init__.pyi ADDED
@@ -0,0 +1,167 @@
1
+ from os import PathLike
2
+ from pathlib import Path
3
+ from typing import Literal, Optional, Union, overload
4
+
5
+ from typing_extensions import Self
6
+
7
+ class FastarError(Exception):
8
+ """Base exception for all fastar errors."""
9
+
10
+ class ArchiveClosedError(FastarError):
11
+ """Exception raised when attempting to use a closed archive."""
12
+
13
+ class ArchiveUnpackingError(FastarError):
14
+ """Exception raised when unpacking an archive fails."""
15
+
16
+ class ArchiveAppendingError(FastarError):
17
+ """Exception raised when appending to an archive fails."""
18
+
19
+ class NameDerivationError(ArchiveAppendingError):
20
+ """Exception raised when a file name cannot be derived from a path."""
21
+
22
+ class ArchiveWriter:
23
+ """A tar archive writer that supports compressed and uncompressed formats."""
24
+
25
+ @classmethod
26
+ def open(
27
+ cls,
28
+ path: Union[str, Path, PathLike[str]],
29
+ mode: Literal["w", "w:gz", "w:zst"],
30
+ ) -> Self:
31
+ """
32
+ Open a tar archive for writing.
33
+
34
+ Args:
35
+ path: Path to the archive file to create
36
+ mode: Write mode - 'w' for uncompressed, 'w:gz' for gzip compressed, 'w:zst' for zstd compressed
37
+
38
+ Returns:
39
+ An ArchiveWriter instance
40
+
41
+ Raises:
42
+ ValueError: If an unsupported mode is provided
43
+ OSError: If the file cannot be opened
44
+ """
45
+
46
+ def append(
47
+ self,
48
+ path: Union[str, Path, PathLike[str]],
49
+ arcname: Optional[Union[str, Path, PathLike[str]]] = None,
50
+ recursive: bool = True,
51
+ dereference: bool = False,
52
+ ) -> None:
53
+ """
54
+ Append a file or directory to the archive.
55
+
56
+ Args:
57
+ path: Path to the file or directory to append
58
+ arcname: Name to use in the archive (defaults to the filename)
59
+ recursive: If True and path is a directory, append all contents recursively
60
+ dereference: If True, append the target of symlinks instead of the symlink itself
61
+
62
+ Raises:
63
+ ArchiveClosedError: If the archive is already closed
64
+ ArchiveAppendingError: If the target cannot be appended to the archive
65
+ OSError: If there's an error reading the target file or directory
66
+ """
67
+
68
+ def close(self) -> None:
69
+ """
70
+ Close the archive and flush all pending writes.
71
+
72
+ Raises:
73
+ OSError: If there's an error flushing the archive
74
+ """
75
+
76
+ def __enter__(self) -> Self:
77
+ """Enter the context manager."""
78
+
79
+ def __exit__(self, exc_type, exc_value, traceback) -> bool:
80
+ """Exit the context manager, closing the archive."""
81
+
82
+ class ArchiveReader:
83
+ """A tar archive reader that supports compressed and uncompressed formats."""
84
+
85
+ @classmethod
86
+ def open(
87
+ cls,
88
+ path: Union[str, Path, PathLike[str]],
89
+ mode: Literal["r", "r:", "r:gz", "r:zst"],
90
+ ) -> Self:
91
+ """
92
+ Open a tar archive for reading.
93
+
94
+ Args:
95
+ path: Path to the archive file to read
96
+ mode: Read mode - 'r' for transparent compression, 'r:gz' for gzip compressed, 'r:zst' for zstd compressed
97
+
98
+ Returns:
99
+ An ArchiveReader instance
100
+
101
+ Raises:
102
+ ValueError: If an unsupported mode is provided
103
+ OSError: If the file cannot be opened
104
+ """
105
+
106
+ def unpack(
107
+ self, to: Union[str, Path, PathLike[str]], preserve_mtime: bool = True
108
+ ) -> None:
109
+ """
110
+ Unpack all contents of the archive and put them into the specified directory.
111
+
112
+ Args:
113
+ to: Destination directory path
114
+ preserve_mtime: whether to preserve file modification times
115
+
116
+ Raises:
117
+ ArchiveClosedError: If the archive is already closed
118
+ ArchiveUnpackingError: If the archive cannot be unpacked
119
+ OSError: If unpacking fails due to I/O errors
120
+ """
121
+
122
+ def close(self) -> None:
123
+ """Close the archive."""
124
+
125
+ def __enter__(self) -> Self:
126
+ """Enter the context manager."""
127
+
128
+ def __exit__(self, exc_type, exc_value, traceback) -> bool:
129
+ """Exit the context manager, closing the archive."""
130
+
131
+ @overload
132
+ def open(
133
+ path: Union[str, Path, PathLike[str]], mode: Literal["w", "w:gz", "w:zst"]
134
+ ) -> ArchiveWriter:
135
+ """
136
+ Open a tar archive for writing.
137
+
138
+ Args:
139
+ path: Path to the archive file to create
140
+ mode: Write mode - 'w' for uncompressed, 'w:gz' for gzip compressed, 'w:zst' for zstd compressed
141
+
142
+ Returns:
143
+ An ArchiveWriter instance
144
+
145
+ Raises:
146
+ ValueError: If an unsupported mode is provided
147
+ OSError: If the file cannot be opened
148
+ """
149
+
150
+ @overload
151
+ def open(
152
+ path: Union[str, Path, PathLike[str]], mode: Literal["r", "r:", "r:gz", "r:zst"]
153
+ ) -> ArchiveReader:
154
+ """
155
+ Open a tar archive for reading.
156
+
157
+ Args:
158
+ path: Path to the archive file to read
159
+ mode: Read mode - 'r' for transparent compression, 'r:gz' for gzip compressed, 'r:zst' for zstd compressed
160
+
161
+ Returns:
162
+ An ArchiveReader instance
163
+
164
+ Raises:
165
+ ValueError: If an unsupported mode is provided
166
+ OSError: If the file cannot be opened
167
+ """
fastar/py.typed ADDED
File without changes
@@ -0,0 +1,103 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastar
3
+ Version: 0.8.0
4
+ Classifier: Intended Audience :: Developers
5
+ Classifier: License :: OSI Approved :: MIT License
6
+ Classifier: Operating System :: OS Independent
7
+ Classifier: Programming Language :: Rust
8
+ Classifier: Programming Language :: Python
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: Implementation :: CPython
18
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ License-File: LICENSE
22
+ Summary: High-level bindings for the Rust tar crate
23
+ Author-email: Jonathan Ehwald <github@ehwald.info>
24
+ License-Expression: MIT
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
27
+ Project-URL: homepage, https://github.com/DoctorJohn/fastar
28
+ Project-URL: repository, https://github.com/DoctorJohn/fastar
29
+ Project-URL: documentation, https://github.com/DoctorJohn/fastar
30
+
31
+ # Fastar
32
+
33
+ [![Versions][versions-image]][versions-url]
34
+ [![PyPI][pypi-image]][pypi-url]
35
+ [![Downloads][downloads-image]][downloads-url]
36
+ [![License][license-image]][license-url]
37
+ [![CodSpeed][codspeed-image]][codspeed-url]
38
+
39
+ [versions-image]: https://img.shields.io/pypi/pyversions/fastar
40
+ [versions-url]: https://github.com/DoctorJohn/fastar/blob/main/pyproject.toml
41
+ [pypi-image]: https://img.shields.io/pypi/v/fastar
42
+ [pypi-url]: https://pypi.org/project/fastar/
43
+ [downloads-image]: https://img.shields.io/pypi/dm/fastar
44
+ [downloads-url]: https://pypistats.org/packages/fastar
45
+ [license-image]: https://img.shields.io/pypi/l/fastar
46
+ [license-url]: https://github.com/DoctorJohn/fastar/blob/main/LICENSE
47
+ [codspeed-image]: https://img.shields.io/endpoint?url=https://codspeed.io/badge.json
48
+ [codspeed-url]: https://codspeed.io/DoctorJohn/fastar
49
+
50
+ The `fastar` library wraps the Rust [tar](https://crates.io/crates/tar), [flate2](https://crates.io/crates/flate2), and [zstd](https://crates.io/crates/zstd) crates, providing a high-performance way to work with compressed and uncompressed tar archives in Python.
51
+
52
+ ## Installation
53
+
54
+ ```sh
55
+ pip install fastar
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ This section shows basic examples of how to create and extract tar archives using Fastar. For more usage examples, please refer directly to the test cases in the [tests](https://github.com/DoctorJohn/fastar/tree/main/tests) directory.
61
+
62
+ ```python
63
+ import fastar
64
+ from pathlib import Path
65
+
66
+
67
+ input_file = Path("file.txt")
68
+ input_file.write_text("Hello, Fastar!")
69
+
70
+
71
+ with fastar.open("archive.tar", "w") as archive:
72
+ archive.append(input_file)
73
+
74
+
75
+ with fastar.open("archive.tar", "r") as archive:
76
+ archive.unpack("output/")
77
+
78
+
79
+ unpacked_file = Path("output/file.txt")
80
+ print(unpacked_file.read_text()) # Hello, Fastar!
81
+ ```
82
+
83
+ ### Opening Modes
84
+
85
+ The `fastar.open` method supports the following modes:
86
+
87
+ | Mode | Action | Compression |
88
+ | ------------- | ------------- | ------------------------- |
89
+ | `"w"` | Write | None |
90
+ | `"w:gz"` | Write | Gzip |
91
+ | `"w:zst"` | Write | Zstandard |
92
+ | `"r"` | Read | Automatically detected |
93
+ | `"r:"` | Read | None |
94
+ | `"r:gz"` | Read | Gzip |
95
+ | `"r:zst"` | Read | Zstandard |
96
+
97
+ ## Development
98
+
99
+ 1. Install dependencies into a virtual env: `uv sync`
100
+ 2. Make changes to the code and tests
101
+ 3. Build the package: `uv run maturin develop`
102
+ 4. Run the tests: `uv run pytest`
103
+
@@ -0,0 +1,9 @@
1
+ fastar-0.8.0.dist-info/METADATA,sha256=eLjz-KB7ZMYKcaMJwmEwD3PxT0MZwqa3lbFmMS2OMlU,3973
2
+ fastar-0.8.0.dist-info/WHEEL,sha256=XWhoXkqSfc0_mHxgggzRVBSKXfuCCZbwjNINDvuGibk,111
3
+ fastar-0.8.0.dist-info/licenses/LICENSE,sha256=rYGQpMiiUoV5IPve_SRv0E-Ci8BMj0TaNs5jSu3d6xo,1054
4
+ fastar.libs/libgcc_s-27e5a392.so.1,sha256=x5sO63liVwXxrjGGP371wB0RyQe1KEnIynYm82T0G0M,449745
5
+ fastar/__init__.py,sha256=mU2iZJ--coorw9PWKBK1JbU9C_N5EqCZQ-b7YvPFBWw,107
6
+ fastar/__init__.pyi,sha256=XgiFg1FAWP7nLEZoXbyjjNBJMWPs8b37zXphxdbmt3w,5134
7
+ fastar/fastar.pypy39-pp73-x86-linux-gnu.so,sha256=BpBtQ_jfIyozEtLLrGC9q-rxQWuZa3QqkHuimT6kUs4,1952641
8
+ fastar/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ fastar-0.8.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.10.2)
3
+ Root-Is-Purelib: false
4
+ Tag: pp39-pypy39_pp73-musllinux_1_2_i686
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Jonathan Ehwald
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file