Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/harvimt/pylib7zip
Python bindings for lib7zip
https://github.com/harvimt/pylib7zip
Last synced: 30 days ago
JSON representation
Python bindings for lib7zip
- Host: GitHub
- URL: https://github.com/harvimt/pylib7zip
- Owner: harvimt
- Created: 2012-12-17T01:24:08.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2020-03-16T09:02:44.000Z (over 4 years ago)
- Last Synced: 2024-08-04T01:28:02.576Z (4 months ago)
- Language: Python
- Size: 4.63 MB
- Stars: 34
- Watchers: 3
- Forks: 20
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
python-lib7zip
==============
Python bindings for 7-Zip
~~~~~~~~~~~~~~~~~~~~~~~~~
:author: Mark Harviston
:version: 0.1pylib7zip is a direct binding to 7z.dll from the 7-zip project (7zip.org)
7z.dll uses Windows COM+ calling conventions without registering itself with the COM server
and has an over-engineered slightly pathological OOP API.Currently only works on Windows with Python 3.3.
This provides roughly the same functionality as lib7zip does for C++ and SevenZipSharp does for C#
but with a clean Pythonic API.Like lib7zip getting metadata and extracting files are the only operations supported, creating archives, or updating them in-place is not supported.
This is beta software and may crash if used in an unusual (or even a usual) way.
Dependencies
------------* 7z.so/7z.dll from http://7zip.org or p7zip on \*Nix
* CFFI_
* enum34_How To Use
----------
By default the path to 7z.dll/7z.so will be autodetected... code:: python
import io
from lib7zip import Archive, formats
#view information on supported formats
for format in formats:
print(format.name, ', '.join(format.extensions))
#type of archive will be autodetected
#pass in optional forceformat argument to force the use a particular format (use the name)
#pass in optional password argument to open encrypted archives.
with Archive('path_to.7z') as archive:
#extract all items to the directory, directory will be created if it doesn't exist
archive.extract('extract_here')
#list all items in the archive and get their metadata
for item in archive:
print( item.isdir, item.path, item.crc)
#extract a particular archive item
# like extract, accepts a password argument, useful if different
# items in the archive have different passwords
archive[0].extract('extract to here.txt')
#extract a particular archive item to a python stream object
stream = io.BytesIO()
archive[0].extract(stream)
stream.getvalue() # a bytes object containing the contents of item 0License
-------This code is licensed under the BSD 2-clause license.
7-Zip is licensed under the LGPL with the exception of the code handling rar compression.
.. _CFFI: https://cffi.readthedocs.org/en/release-0.6/
.. _enum34: https://pypi.python.org/pypi/enum34