tarfile.TarFile.add()

TarFile.add(name, arcname=None, recursive=True, exclude=None, *, filter=None)

Add the file name to the archive. name may be any type of file (directory, fifo, symbolic link, etc.). If given, arcname specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting recursive to False. If exclude is given, it must be a function that takes one filename argument and returns a boolean value. Depending on this value the respective file is either excluded (True) or added (False). If filter is specified it must be a keyword argument. It should be a function that takes a TarInfo object argument and returns the changed TarInfo object. If it instead returns None the TarInfo object will be excluded from the archive. See Examples for an example.

Changed in version 3.2: Added the filter parameter.

Deprecated since version 3.2: The exclude parameter is deprecated, please use the filter parameter instead.

doc_python
2016-10-07 17:44:08
Comments
Leave a Comment

Please login to continue.