Skip to content

Commit

Permalink
various fixes for python 2.7 and python 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
matteomattei committed Oct 11, 2016
1 parent 7213a0a commit d5d0190
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
7 changes: 5 additions & 2 deletions PySquashfsImage/PySquashfsImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ def __init__(self):
self.name="xz"

def uncompress(self, src):
import lzma
return lzma.decompress(src)
try:
import lzma
except ImportError:
from backports import lzma
return lzma.decompress(src)

_compressors = ( _Compressor(), _ZlibCompressor(), _XZCompressor() )

Expand Down
5 changes: 4 additions & 1 deletion PySquashfsImage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
from PySquashfsImage import *
from .PySquashfsImage import SquashFsImage
from .PySquashfsImage import SquashedFile
from .PySquashfsImage import SquashInode

__all__ = ['SquashFsImage','SquashedFile','SquashInode']
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ from PySquashfsImage import SquashFsImage
image = SquashFsImage('/path/to/my/image.img')
for i in image.root.findAll():
if i.getName() == 'myfilename':
with open('/tmp/'+i.getName(),'wb') as f:
print('Saving original '+i.getPath()+' in /tmp/'+i.getName()')
if i.getName() == b'myfilename':
with open(b'/tmp/'+i.getName(),'wb') as f:
print(b'Saving original '+i.getPath().encode()+b' in /tmp/'+i.getName())
f.write(i.getContent())
image.close()
```
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='PySquashfsImage',
version='0.5',
version='0.6',
description='Squashfs image parser',
long_description='This package provides a way to read and extract squashfs images.',
author='Matteo Mattei; Nicola Ponzeveroni;',
Expand Down

0 comments on commit d5d0190

Please sign in to comment.