https://github.com/uuunyaa/x7zipfile
x7zipfile is a thin 7-zip command wrapper for Python.
https://github.com/uuunyaa/x7zipfile
7zip p7zip python zipfile
Last synced: 9 months ago
JSON representation
x7zipfile is a thin 7-zip command wrapper for Python.
- Host: GitHub
- URL: https://github.com/uuunyaa/x7zipfile
- Owner: UuuNyaa
- License: bsd-3-clause
- Created: 2021-03-23T17:43:35.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-26T12:35:20.000Z (about 5 years ago)
- Last Synced: 2024-12-31T10:30:05.531Z (over 1 year ago)
- Topics: 7zip, p7zip, python, zipfile
- Language: Python
- Homepage:
- Size: 1.4 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# x7zipfile
x7zipfile is a thin [7-zip](https://www.7-zip.org/) extract command wrapper for Python.
## Features
- The interface follows the style of [zipfile](https://docs.python.org/3/library/zipfile.html).
- Archive operations are handled by executing external tool: 7z.
- Works with single file.
- Supports extract and list operations.
- **Not** supports compress operations.
- Supports archive formats that can be processed by the 7z command.
- Supports Unicode filenames.
- Supports password-protected archives.
## Installation
### Requirements
- Python **3.7** or later
- 7-zip **16** or later
### Download
- Download `x7zipfile.py` from [the github code page](https://github.com/UuuNyaa/x7zipfile/blob/main/src/x7zipfile.py)
- https://github.com/UuuNyaa/x7zipfile/blob/main/src/x7zipfile.py
### Install
1. ***Place the `x7zipfile.py`*** file where you want.
2. ***Install 7-zip***.
- Windows: https://www.newsgroupreviews.com/7-zip-installation.html
- Linux: run `sudo {apt,yum,dnf,snap} install p7zip-full`
## Usage
### Simple extract example
```python
import x7zipfile
with x7zipfile.x7ZipFile('myarchive.7z') as zipfile:
for info in zipfile.infolist():
print(info.filename, info.file_size)
if info.filename == 'README':
zipfile.extract(info)
```
### Dynamic module load example
```python
import importlib
namespace = 'x7zipfile'
loader = importlib.machinery.SourceFileLoader(namespace, '/path/to/x7zipfile.py')
x7zipfile = loader.load_module(namespace)
```
## References
- Code: [markokr/rarfile](https://github.com/markokr/rarfile)
- Test archives: [miurahr/py7zr](https://github.com/miurahr/py7zr)