-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Python 3 and just few examples
- Loading branch information
1 parent
23740c7
commit 5527c1a
Showing
4 changed files
with
106 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
PySquashfsImage is a lightweight library for reading squashfs image files in Python. | ||
It provides a way to read squashfs images header and to retrieve encapsulated binaries. | ||
It is compatible with Python2 and Python3. | ||
|
||
Examples: | ||
--------- | ||
|
||
List all elements in the image: | ||
------------------------------- | ||
``` | ||
from PySquashfsImage import SquashFsImage | ||
image = SquashFsImage('/path/to/my/image.img') | ||
for i in image.root.findAll(): | ||
print(i.getName()) | ||
image.close() | ||
``` | ||
|
||
Print all files and folder with human readable path: | ||
---------------------------------------------------- | ||
``` | ||
from PySquashfsImage import SquashFsImage | ||
image = SquashFsImage('/path/to/my/image.img') | ||
for i in image.root.findAllPaths(): | ||
print(i) | ||
image.close() | ||
``` | ||
|
||
Print only files: | ||
----------------- | ||
``` | ||
from PySquashfsImage import SquashFsImage | ||
image = SquashFsImage('/path/to/my/image.img') | ||
for i in image.root.findAll(): | ||
if not i.isFolder(): | ||
print(i.getPath()) | ||
image.close() | ||
``` | ||
|
||
Save the content of a file: | ||
--------------------------- | ||
``` | ||
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()') | ||
f.write(i.getContent()) | ||
image.close() | ||
``` | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters