Wrapper for UnRAR library, ctypes-based.
Project description
python-unrar
Work with RAR archive files through unrar library using ctypes.
Install UnRAR library
python-unrar requires UnRAR library. You can download UnRAR library sources from:
http://www.rarlab.com/rar_add.htm
and compile (you may need to rename the makefile that you want to use according to your OS) and install it from there:
$ make lib
$ make install-lib
(latest tested sources: http://www.rarlab.com/rar/unrarsrc-5.2.6.tar.gz)
For Windows you can also download the already compiled library (http://www.rarlab.com/rar/UnRARDLL.exe).
If you prefer not to install the library, you should make it "findable" by adding the library file to a directory where libraries are searched (or change required environment variable).
As an alternative, you can also set UNRAR_LIB_PATH variable in your environment to the library path and python-unrar will try to load the UnRAR library from there.
Testing without installing
You can build from source with:
$ python setup.py build
And then run a Python shell with unrar available:
$ PYTHONPATH=`pwd`/build/lib python
Or you could also directly add the unrar
directory from this repo to your PYTHONPATH
. In any case you will still need to make the unrar library available as mentioned above.
Install python-unrar
To install python-unrar:
$ pip install unrar
Examples
>>> from unrar import rarfile
>>> rar = rarfile.RarFile('sample.rar')
>>> rar.namelist()
[u'test_file.txt']
>>> rar.printdir()
File Name Modified Size
test_file.txt 2013-04-14 08:20:28 17
>>> rar.testrar()
>>> info = rar.infolist()[0]
>>> info.filename
u'test_file.txt'
>>> info.file_size
17L
>>> info.date_time
(2013L, 4L, 14L, 8L, 20L, 28L)
>>> rar.extractall()
>>> rar.read('test_file.txt')
'This is for test.'
Docs
Check full documentation in http://python-unrar.readthedocs.org.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file unrar-0.4.tar.gz
.
File metadata
- Download URL: unrar-0.4.tar.gz
- Upload date:
- Size: 36.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b24447a5b93024be600ef8255668ba23a30f451176577b691559ea1359f7d164 |
|
MD5 | 6d78245a417fb97e48029fefc8b41eec |
|
BLAKE2b-256 | ead6b53a4216d73a10602f524cf728c3c272b2e1f524b62f46589303225564c0 |
File details
Details for the file unrar-0.4-py3-none-any.whl
.
File metadata
- Download URL: unrar-0.4-py3-none-any.whl
- Upload date:
- Size: 25.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ce03e28bfa90415ee1a92c8d38cad8ea244427a59a8a39c0d42bac8727cfaa0 |
|
MD5 | 1a7301a7f9238a200941f8139fd18be5 |
|
BLAKE2b-256 | bb0b53130ccd483e3db8c8a460cb579bdb21b458d5494d67a261e1a5b273fbb9 |