tzst 0.1.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.
- tzst-0.1.0/.gitignore +160 -0
- tzst-0.1.0/LICENSE +28 -0
- tzst-0.1.0/PKG-INFO +225 -0
- tzst-0.1.0/README.md +192 -0
- tzst-0.1.0/pyproject.toml +81 -0
- tzst-0.1.0/src/tzst/__init__.py +19 -0
- tzst-0.1.0/src/tzst/__main__.py +6 -0
- tzst-0.1.0/src/tzst/cli.py +319 -0
- tzst-0.1.0/src/tzst/core.py +441 -0
- tzst-0.1.0/src/tzst/exceptions.py +31 -0
- tzst-0.1.0/tests/__init__.py +1 -0
- tzst-0.1.0/tests/conftest.py +51 -0
- tzst-0.1.0/tests/test_cli.py +214 -0
- tzst-0.1.0/tests/test_core.py +231 -0
tzst-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
+
#.idea/
|
tzst-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Xi Xu
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
tzst-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tzst
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python library for creating and manipulating .tzst/.tar.zst archives
|
|
5
|
+
Project-URL: Homepage, https://github.com/xixu-me/tzst
|
|
6
|
+
Project-URL: Documentation, https://github.com/xixu-me/tzst#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/xixu-me/tzst.git
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/xixu-me/tzst/issues
|
|
9
|
+
Author: tzst contributors
|
|
10
|
+
License-Expression: BSD-3-Clause
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: archive,compression,tar,zstandard
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: System :: Archiving :: Compression
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Requires-Dist: zstandard<1.0.0,>=0.19.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# tzst
|
|
35
|
+
|
|
36
|
+
[](https://github.com/xixu-me/tzst/actions)
|
|
37
|
+
[](https://badge.fury.io/py/tzst)
|
|
38
|
+
[](https://pypi.org/project/tzst/)
|
|
39
|
+
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
40
|
+
|
|
41
|
+
A Python library for creating and manipulating `.tzst`/`.tar.zst` archives (tar archives compressed using Zstandard).
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- **Create** `.tzst`/`.tar.zst` archives from files and directories
|
|
46
|
+
- **Extract** contents with full paths or flat structure
|
|
47
|
+
- **List** archive contents with detailed information
|
|
48
|
+
- **Test** archive integrity
|
|
49
|
+
- **Command-line interface** with 7z-like commands
|
|
50
|
+
- **Cross-platform** support (Windows, macOS, Linux)
|
|
51
|
+
- **High performance** using Zstandard compression
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
Install from PyPI:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install tzst
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or install from source:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
git clone https://github.com/xixu-me/tzst.git
|
|
65
|
+
cd tzst
|
|
66
|
+
pip install .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Quick Start
|
|
70
|
+
|
|
71
|
+
### Python API
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import tzst
|
|
75
|
+
|
|
76
|
+
# Create an archive
|
|
77
|
+
tzst.create_archive("archive.tzst", ["file1.txt", "file2.txt", "directory/"])
|
|
78
|
+
|
|
79
|
+
# Extract an archive
|
|
80
|
+
tzst.extract_archive("archive.tzst", "output_directory/")
|
|
81
|
+
|
|
82
|
+
# List archive contents
|
|
83
|
+
contents = tzst.list_archive("archive.tzst", verbose=True)
|
|
84
|
+
for item in contents:
|
|
85
|
+
print(f"{item['name']} - {item['size']} bytes")
|
|
86
|
+
|
|
87
|
+
# Test archive integrity
|
|
88
|
+
is_valid = tzst.test_archive("archive.tzst")
|
|
89
|
+
print(f"Archive is valid: {is_valid}")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Advanced API Usage
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from tzst import TzstArchive
|
|
96
|
+
|
|
97
|
+
# Create archive with custom compression level
|
|
98
|
+
with TzstArchive("archive.tzst", "w") as archive:
|
|
99
|
+
archive.add("file1.txt")
|
|
100
|
+
archive.add("directory/", recursive=True)
|
|
101
|
+
|
|
102
|
+
# Extract specific files
|
|
103
|
+
with TzstArchive("archive.tzst", "r") as archive:
|
|
104
|
+
archive.extract("specific_file.txt", "output/")
|
|
105
|
+
|
|
106
|
+
# Or extract all with full paths
|
|
107
|
+
archive.extract(path="output/")
|
|
108
|
+
|
|
109
|
+
# List and examine contents
|
|
110
|
+
with TzstArchive("archive.tzst", "r") as archive:
|
|
111
|
+
members = archive.getmembers()
|
|
112
|
+
for member in members:
|
|
113
|
+
print(f"{member.name}: {member.size} bytes, {member.mtime}")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Command Line Interface
|
|
117
|
+
|
|
118
|
+
The CLI provides 7z-like commands for archive operations:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Create an archive
|
|
122
|
+
tzst a archive.tzst file1.txt file2.txt directory/
|
|
123
|
+
|
|
124
|
+
# Create with custom compression level (1-22)
|
|
125
|
+
tzst a archive.tzst -l 10 file1.txt file2.txt
|
|
126
|
+
|
|
127
|
+
# Extract with full paths
|
|
128
|
+
tzst x archive.tzst
|
|
129
|
+
|
|
130
|
+
# Extract to specific directory
|
|
131
|
+
tzst x archive.tzst -o output/
|
|
132
|
+
|
|
133
|
+
# Extract without paths (flat structure)
|
|
134
|
+
tzst e archive.tzst -o flat_output/
|
|
135
|
+
|
|
136
|
+
# List archive contents
|
|
137
|
+
tzst l archive.tzst
|
|
138
|
+
|
|
139
|
+
# List with detailed information
|
|
140
|
+
tzst l archive.tzst -v
|
|
141
|
+
|
|
142
|
+
# Test archive integrity
|
|
143
|
+
tzst t archive.tzst
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Command Reference
|
|
147
|
+
|
|
148
|
+
| Command | Aliases | Description |
|
|
149
|
+
|---------|---------|-------------|
|
|
150
|
+
| `a` | `add`, `create` | Create archive or add files |
|
|
151
|
+
| `x` | `extract` | Extract with full paths |
|
|
152
|
+
| `e` | `extract-flat` | Extract without paths |
|
|
153
|
+
| `l` | `list` | List archive contents |
|
|
154
|
+
| `t` | `test` | Test archive integrity |
|
|
155
|
+
|
|
156
|
+
## Performance
|
|
157
|
+
|
|
158
|
+
tzst uses Python's built-in `tarfile` module combined with the high-performance `zstandard` library. This provides:
|
|
159
|
+
|
|
160
|
+
- **Fast compression/decompression** with Zstandard
|
|
161
|
+
- **Memory efficient** streaming operations
|
|
162
|
+
- **Small archive sizes** with excellent compression ratios
|
|
163
|
+
- **Cross-platform compatibility**
|
|
164
|
+
|
|
165
|
+
## File Extensions
|
|
166
|
+
|
|
167
|
+
tzst supports both `.tzst` and `.tar.zst` extensions:
|
|
168
|
+
|
|
169
|
+
- `.tzst` - Short form (preferred)
|
|
170
|
+
- `.tar.zst` - Explicit form showing tar + zstandard
|
|
171
|
+
- Auto-detection and conversion when needed
|
|
172
|
+
|
|
173
|
+
## Requirements
|
|
174
|
+
|
|
175
|
+
- Python 3.8+
|
|
176
|
+
- zstandard >= 0.19.0
|
|
177
|
+
|
|
178
|
+
## Development
|
|
179
|
+
|
|
180
|
+
### Setup Development Environment
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
git clone https://github.com/xixu-me/tzst.git
|
|
184
|
+
cd tzst
|
|
185
|
+
pip install -e .[dev]
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Run Tests
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
pytest
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Run Linting
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
ruff check src tests
|
|
198
|
+
black src tests
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Build Package
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
python -m build
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Contributing
|
|
208
|
+
|
|
209
|
+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
|
|
210
|
+
|
|
211
|
+
1. Fork the repository
|
|
212
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
213
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
214
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
215
|
+
5. Open a Pull Request
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.
|
|
220
|
+
|
|
221
|
+
## Acknowledgments
|
|
222
|
+
|
|
223
|
+
- [Zstandard](https://github.com/facebook/zstd) for the excellent compression algorithm
|
|
224
|
+
- [python-zstandard](https://github.com/indygreg/python-zstandard) for Python bindings
|
|
225
|
+
- Python's `tarfile` module for tar archive handling
|
tzst-0.1.0/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# tzst
|
|
2
|
+
|
|
3
|
+
[](https://github.com/xixu-me/tzst/actions)
|
|
4
|
+
[](https://badge.fury.io/py/tzst)
|
|
5
|
+
[](https://pypi.org/project/tzst/)
|
|
6
|
+
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
7
|
+
|
|
8
|
+
A Python library for creating and manipulating `.tzst`/`.tar.zst` archives (tar archives compressed using Zstandard).
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Create** `.tzst`/`.tar.zst` archives from files and directories
|
|
13
|
+
- **Extract** contents with full paths or flat structure
|
|
14
|
+
- **List** archive contents with detailed information
|
|
15
|
+
- **Test** archive integrity
|
|
16
|
+
- **Command-line interface** with 7z-like commands
|
|
17
|
+
- **Cross-platform** support (Windows, macOS, Linux)
|
|
18
|
+
- **High performance** using Zstandard compression
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Install from PyPI:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install tzst
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or install from source:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/xixu-me/tzst.git
|
|
32
|
+
cd tzst
|
|
33
|
+
pip install .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
### Python API
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import tzst
|
|
42
|
+
|
|
43
|
+
# Create an archive
|
|
44
|
+
tzst.create_archive("archive.tzst", ["file1.txt", "file2.txt", "directory/"])
|
|
45
|
+
|
|
46
|
+
# Extract an archive
|
|
47
|
+
tzst.extract_archive("archive.tzst", "output_directory/")
|
|
48
|
+
|
|
49
|
+
# List archive contents
|
|
50
|
+
contents = tzst.list_archive("archive.tzst", verbose=True)
|
|
51
|
+
for item in contents:
|
|
52
|
+
print(f"{item['name']} - {item['size']} bytes")
|
|
53
|
+
|
|
54
|
+
# Test archive integrity
|
|
55
|
+
is_valid = tzst.test_archive("archive.tzst")
|
|
56
|
+
print(f"Archive is valid: {is_valid}")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Advanced API Usage
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from tzst import TzstArchive
|
|
63
|
+
|
|
64
|
+
# Create archive with custom compression level
|
|
65
|
+
with TzstArchive("archive.tzst", "w") as archive:
|
|
66
|
+
archive.add("file1.txt")
|
|
67
|
+
archive.add("directory/", recursive=True)
|
|
68
|
+
|
|
69
|
+
# Extract specific files
|
|
70
|
+
with TzstArchive("archive.tzst", "r") as archive:
|
|
71
|
+
archive.extract("specific_file.txt", "output/")
|
|
72
|
+
|
|
73
|
+
# Or extract all with full paths
|
|
74
|
+
archive.extract(path="output/")
|
|
75
|
+
|
|
76
|
+
# List and examine contents
|
|
77
|
+
with TzstArchive("archive.tzst", "r") as archive:
|
|
78
|
+
members = archive.getmembers()
|
|
79
|
+
for member in members:
|
|
80
|
+
print(f"{member.name}: {member.size} bytes, {member.mtime}")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Command Line Interface
|
|
84
|
+
|
|
85
|
+
The CLI provides 7z-like commands for archive operations:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Create an archive
|
|
89
|
+
tzst a archive.tzst file1.txt file2.txt directory/
|
|
90
|
+
|
|
91
|
+
# Create with custom compression level (1-22)
|
|
92
|
+
tzst a archive.tzst -l 10 file1.txt file2.txt
|
|
93
|
+
|
|
94
|
+
# Extract with full paths
|
|
95
|
+
tzst x archive.tzst
|
|
96
|
+
|
|
97
|
+
# Extract to specific directory
|
|
98
|
+
tzst x archive.tzst -o output/
|
|
99
|
+
|
|
100
|
+
# Extract without paths (flat structure)
|
|
101
|
+
tzst e archive.tzst -o flat_output/
|
|
102
|
+
|
|
103
|
+
# List archive contents
|
|
104
|
+
tzst l archive.tzst
|
|
105
|
+
|
|
106
|
+
# List with detailed information
|
|
107
|
+
tzst l archive.tzst -v
|
|
108
|
+
|
|
109
|
+
# Test archive integrity
|
|
110
|
+
tzst t archive.tzst
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Command Reference
|
|
114
|
+
|
|
115
|
+
| Command | Aliases | Description |
|
|
116
|
+
|---------|---------|-------------|
|
|
117
|
+
| `a` | `add`, `create` | Create archive or add files |
|
|
118
|
+
| `x` | `extract` | Extract with full paths |
|
|
119
|
+
| `e` | `extract-flat` | Extract without paths |
|
|
120
|
+
| `l` | `list` | List archive contents |
|
|
121
|
+
| `t` | `test` | Test archive integrity |
|
|
122
|
+
|
|
123
|
+
## Performance
|
|
124
|
+
|
|
125
|
+
tzst uses Python's built-in `tarfile` module combined with the high-performance `zstandard` library. This provides:
|
|
126
|
+
|
|
127
|
+
- **Fast compression/decompression** with Zstandard
|
|
128
|
+
- **Memory efficient** streaming operations
|
|
129
|
+
- **Small archive sizes** with excellent compression ratios
|
|
130
|
+
- **Cross-platform compatibility**
|
|
131
|
+
|
|
132
|
+
## File Extensions
|
|
133
|
+
|
|
134
|
+
tzst supports both `.tzst` and `.tar.zst` extensions:
|
|
135
|
+
|
|
136
|
+
- `.tzst` - Short form (preferred)
|
|
137
|
+
- `.tar.zst` - Explicit form showing tar + zstandard
|
|
138
|
+
- Auto-detection and conversion when needed
|
|
139
|
+
|
|
140
|
+
## Requirements
|
|
141
|
+
|
|
142
|
+
- Python 3.8+
|
|
143
|
+
- zstandard >= 0.19.0
|
|
144
|
+
|
|
145
|
+
## Development
|
|
146
|
+
|
|
147
|
+
### Setup Development Environment
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
git clone https://github.com/xixu-me/tzst.git
|
|
151
|
+
cd tzst
|
|
152
|
+
pip install -e .[dev]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Run Tests
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pytest
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Run Linting
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
ruff check src tests
|
|
165
|
+
black src tests
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Build Package
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
python -m build
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Contributing
|
|
175
|
+
|
|
176
|
+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
|
|
177
|
+
|
|
178
|
+
1. Fork the repository
|
|
179
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
180
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
181
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
182
|
+
5. Open a Pull Request
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.
|
|
187
|
+
|
|
188
|
+
## Acknowledgments
|
|
189
|
+
|
|
190
|
+
- [Zstandard](https://github.com/facebook/zstd) for the excellent compression algorithm
|
|
191
|
+
- [python-zstandard](https://github.com/indygreg/python-zstandard) for Python bindings
|
|
192
|
+
- Python's `tarfile` module for tar archive handling
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tzst"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "A Python library for creating and manipulating .tzst/.tar.zst archives"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "BSD-3-Clause"
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
authors = [{ name = "tzst contributors" }]
|
|
13
|
+
keywords = ["tar", "zstandard", "compression", "archive"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: BSD License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.8",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: System :: Archiving :: Compression",
|
|
26
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
27
|
+
]
|
|
28
|
+
dependencies = ["zstandard>=0.19.0,<1.0.0"]
|
|
29
|
+
|
|
30
|
+
[project.optional-dependencies]
|
|
31
|
+
dev = ["pytest>=7.0.0", "pytest-cov>=4.0.0", "ruff>=0.1.0", "black>=23.0.0"]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/xixu-me/tzst"
|
|
35
|
+
Documentation = "https://github.com/xixu-me/tzst#readme"
|
|
36
|
+
Repository = "https://github.com/xixu-me/tzst.git"
|
|
37
|
+
"Bug Tracker" = "https://github.com/xixu-me/tzst/issues"
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
tzst = "tzst.cli:main"
|
|
41
|
+
|
|
42
|
+
[tool.hatch.version]
|
|
43
|
+
path = "src/tzst/__init__.py"
|
|
44
|
+
|
|
45
|
+
[tool.hatch.build.targets.wheel]
|
|
46
|
+
packages = ["src/tzst"]
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.sdist]
|
|
49
|
+
include = ["/src", "/tests", "/README.md", "/LICENSE"]
|
|
50
|
+
|
|
51
|
+
[tool.pytest.ini_options]
|
|
52
|
+
testpaths = ["tests"]
|
|
53
|
+
python_files = ["test_*.py"]
|
|
54
|
+
python_classes = ["Test*"]
|
|
55
|
+
python_functions = ["test_*"]
|
|
56
|
+
addopts = "--cov=tzst --cov-report=term-missing --cov-report=html"
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
target-version = "py38"
|
|
60
|
+
line-length = 88
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
select = [
|
|
64
|
+
"E", # pycodestyle errors
|
|
65
|
+
"W", # pycodestyle warnings
|
|
66
|
+
"F", # pyflakes
|
|
67
|
+
"I", # isort
|
|
68
|
+
"B", # flake8-bugbear
|
|
69
|
+
"C4", # flake8-comprehensions
|
|
70
|
+
"UP", # pyupgrade
|
|
71
|
+
]
|
|
72
|
+
ignore = [
|
|
73
|
+
"E501", # line too long, handled by black
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[tool.ruff.lint.per-file-ignores]
|
|
77
|
+
"tests/**/*" = ["E501"]
|
|
78
|
+
|
|
79
|
+
[tool.black]
|
|
80
|
+
target-version = ["py38", "py39", "py310", "py311", "py312"]
|
|
81
|
+
line-length = 88
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""tzst - A Python library for creating and manipulating .tzst/.tar.zst archives."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.0"
|
|
4
|
+
|
|
5
|
+
from .core import (
|
|
6
|
+
TzstArchive,
|
|
7
|
+
create_archive,
|
|
8
|
+
extract_archive,
|
|
9
|
+
list_archive,
|
|
10
|
+
test_archive,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"TzstArchive",
|
|
15
|
+
"create_archive",
|
|
16
|
+
"extract_archive",
|
|
17
|
+
"list_archive",
|
|
18
|
+
"test_archive",
|
|
19
|
+
]
|