The modules described in this chapter support data compression with the zlib,
gzip, and bzip2 algorithms, and the creation of ZIP- and tar-format archives.
+See also :ref:`archiving-operations` provided by the :mod:`shutil` module.
.. toctree::
It implements a complete file interface, one-shot (de)compression functions, and
types for sequential (de)compression.
-For other archive formats, see the :mod:`gzip`, :mod:`zipfile`, and
-:mod:`tarfile` modules.
-
Here is a summary of the features offered by the bz2 module:
* :class:`BZ2File` class implements a complete file interface, including
:program:`gzip` and :program:`gunzip` programs, such as those produced by
:program:`compress` and :program:`pack`, are not supported by this module.
-For other archive formats, see the :mod:`bz2`, :mod:`zipfile`, and
-:mod:`tarfile` modules.
-
The module defines the following items:
are not copied.
+.. _file-operations:
+
Directory and files operations
------------------------------
.. versionadded:: 2.3
-.. _shutil-example:
+.. _copytree-example:
copytree example
::::::::::::::::
copytree(source, destination, ignore=_logpath)
-Archives operations
--------------------
+.. _archiving-operations:
+
+Archiving operations
+--------------------
+
+High-level utilities to create and read compressed and archived files are also
+provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
.. function:: make_archive(base_name, format, [root_dir, [base_dir, [verbose, [dry_run, [owner, [group, [logger]]]]]]])
.. versionadded:: 2.7
+.. _archiving-example:
+
Archiving example
:::::::::::::::::
-rw------- tarek/staff 1675 2008-06-09 13:26:54 ./id_rsa
-rw-r--r-- tarek/staff 397 2008-06-09 13:26:54 ./id_rsa.pub
-rw-r--r-- tarek/staff 37192 2010-02-06 18:23:10 ./known_hosts
-
-
The :mod:`tarfile` module makes it possible to read and write tar
archives, including those using gzip or bz2 compression.
-(:file:`.zip` files can be read and written using the :mod:`zipfile` module.)
+Use the :mod:`zipfile` module to read or write :file:`.zip` files, or the
+higher-level functions in :ref:`shutil <archiving-operations>`.
Some facts and figures:
create an encrypted file. Decryption is extremely slow as it is
implemented in native Python rather than C.
-For other archive formats, see the :mod:`bz2`, :mod:`gzip`, and
-:mod:`tarfile` modules.
-
The module defines the following items:
.. exception:: BadZipfile
consult the zlib manual at http://www.zlib.net/manual.html for authoritative
information.
-For reading and writing ``.gz`` files see the :mod:`gzip` module. For
-other archive formats, see the :mod:`bz2`, :mod:`zipfile`, and
-:mod:`tarfile` modules.
+For reading and writing ``.gz`` files see the :mod:`gzip` module.
The available exception and functions in this module are: