patool/doc/development.txt

79 lines
2.7 KiB
Plaintext
Raw Normal View History

2012-05-11 18:07:50 +00:00
Development with the patoolib library
======================================
The patool funtionality can also be used in other Python programs.
To do this, install the patool program, import the library and
use one or more of the convenience functions.
import patoolib
if patoolib.extract("myarchive.zip", verbose=True) == 0:
print "Success."
else:
print "Error."
General rules for all convenience functions:
* All convenience function return zero when no error occurred, else
an integer unequal zero.
* Error messages are printed on stderr, informative messages
are printed on stdout.
* All file arguments are filenames. File objects are not accepted
as input.
* Filenames can be relative or absolute.
The convenience functions are:
* ``def extract(archive, verbose=False, outdir=None)``
2012-05-12 10:57:01 +00:00
Extracts the given archive filename to the current working directory
or if specified to the given directory name in outdir.
2012-05-11 18:07:50 +00:00
If verbose operation is set to True, additional output of the archive
program is shown.
2012-05-12 10:57:01 +00:00
Checks that the archive exists and is readable before extracting it.
2012-05-11 18:07:50 +00:00
* ``def list(archive, verbose=False)``
2012-05-12 10:57:01 +00:00
Lists the contents of the given archive filename on stdout.
2012-05-11 18:07:50 +00:00
If verbose operation is set to True, additional output of the archive
program is shown.
2012-05-12 10:57:01 +00:00
Checks that the archive exists and is readable before listing it.
2012-05-11 18:07:50 +00:00
* ``def test(archive, verbose=False)``
2012-05-12 10:57:01 +00:00
Tests the given archive filename.
2012-05-11 18:07:50 +00:00
If verbose operation is set to True, additional output of the archive
program is shown.
2012-05-12 10:57:01 +00:00
Checks that the archive exists and is readable before testing it.
2012-05-11 18:07:50 +00:00
* ``def create(archive, *filenames, **kwargs)``
2012-05-12 10:57:01 +00:00
Creates a new archive. The type of archive is determined
by the archive filename extension.
2012-05-11 18:07:50 +00:00
If verbose operation is set to True, additional output of the archive
program is shown.
2012-05-12 10:57:01 +00:00
Checks that the archive is not already existing to avoid overwriting it.
Also checks that the filename list is not empty and that all files exist
and are readable.
2012-05-11 18:07:50 +00:00
* ``def diff(archive1, archive2, verbose=False)``
2012-05-11 19:09:32 +00:00
This function lists differences in the content of the two archives.
Both archives are extracted and the contents are compared
recursively with the diff(1) program.
If verbose operation is set to True, additional output of the archive
program is shown.
2012-05-12 10:57:01 +00:00
Checks that both archives exist and are readable.
2012-05-11 18:07:50 +00:00
* ``def repack(archive1, archive2, verbose=False)``
2012-05-11 19:09:32 +00:00
This function extracts the contents of archive1 and packs them
into archive2.
If verbose operation is set to True, additional output of the archive
program is shown.
2012-05-12 10:57:01 +00:00
Checks that archive1 exists and is readable. Also checks that
archive2 does not exist to avoid overwriting it.
2012-05-11 18:07:50 +00:00