-
Notifications
You must be signed in to change notification settings - Fork 0
Python development
libgzipf comes with Python-bindings named pygzipf.
Below are examples how use pygzipf. They assume you have a working version of pygzipf on your system. To build pygzipf see Building.
To be able to use pygzipf in your Python scripts add the following import:
import pygzipf
The get_version() module function can be used to retrieve the version of the pygzipf.
pygzipf.get_version()
This will return a textual string (Unicode) that contains the libgzipf version. Since pygzipf is a wrapper around libgzipf it does not have a separate version.
gzipf_file = pygzipf.file()
gzipf_file.open("first.gz")
...
gzipf_file.close()
The explicit call to gzipf_file.close() is not required. Close only must be called once all operations on the file have been completed.
file_object = open("first.gz", "rb")
gzipf_file = pygzipf.file()
gzipf_file.open_file_object(file_object)
...
gzipf_file.close()
The explicit call to gzipf_file.close() is not required. Close only must be called once all operations on the file have been completed and will not close the file-like object itself.
import pygzipf
help(pygzipf)
help(pygzipf.file)