Skip to content

Commit

Permalink
Added LZMA support (issue srossross#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Torsten Sachse committed Apr 25, 2016
1 parent 0f0c642 commit f6773dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions rpmfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io
import gzip
import struct
from backports import lzma
from rpmfile import cpiofile
from functools import wraps
from rpmfile.io_extra import _SubFile
Expand All @@ -15,7 +16,7 @@ class RPMInfo(object):
'''
Informational class which holds the details about an
archive member given by an RPM entry block.
RPMInfo objects are returned by RPMFile.getmember() and
RPMInfo objects are returned by RPMFile.getmember() and
RPMFile.getmembers() and are
usually created internally.
'''
Expand Down Expand Up @@ -65,7 +66,7 @@ class RPMFile(object):
'''
Open an RPM archive `name'. `mode' must be 'r' to
read from an existing archive.
If `fileobj' is given, it is used for reading or writing data. If it
can be determined, `mode' is overridden by `fileobj's mode.
`fileobj' is not closed, when TarFile is closed.
Expand Down Expand Up @@ -157,7 +158,10 @@ def gzip_file(self):
'Return the uncompressed raw CPIO data of the RPM archive'
if self._gzip_file is None:
fileobj = _SubFile(self._fileobj, self.data_offset)
self._gzip_file = gzip.GzipFile(fileobj=fileobj)
if self.headers['archive_compression'] == 'xz':
self._gzip_file = lzma.LZMAFile(fileobj)
else:
self._gzip_file = gzip.GzipFile(fileobj=fileobj)
return self._gzip_file

def open(name=None, mode='rb', fileobj=None):
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
setup(
name='rpmfile',
description='Read rmp archive files',
version="0.1.4",
version="0.1.5",
author='Sean Ross-Ross',
author_email='srossross@gmail.com',
url='https://github.com/srossross/rpmfile',
license='MIT',
long_description=long_description,
packages=find_packages(),
install_requires=[
'backports.lzma>=0.0.3',
],
)

0 comments on commit f6773dc

Please sign in to comment.