diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-02-19 23:46:59 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-02-19 23:46:59 (GMT) |
commit | 2d2d08d2cc2af98219fd105ec75fa58a633d2b75 (patch) | |
tree | 2b9be4c5ca2d404945a35d3d91380e4d32d0ee21 /Lib/tarfile.py | |
parent | 7db1d1620982d8ed13363e89a86852bd8a6c8b86 (diff) | |
parent | f817a48d170e2dfb7c7154f12308e291457a2f8a (diff) | |
download | cpython-2d2d08d2cc2af98219fd105ec75fa58a633d2b75.zip cpython-2d2d08d2cc2af98219fd105ec75fa58a633d2b75.tar.gz cpython-2d2d08d2cc2af98219fd105ec75fa58a633d2b75.tar.bz2 |
Issue #22468: Merge gettarinfo() doc from 3.5
Diffstat (limited to 'Lib/tarfile.py')
-rwxr-xr-x | Lib/tarfile.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 7d43b1e..1ac7007 100755 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1757,11 +1757,13 @@ class TarFile(object): return [tarinfo.name for tarinfo in self.getmembers()] def gettarinfo(self, name=None, arcname=None, fileobj=None): - """Create a TarInfo object for either the file `name' or the file - object `fileobj' (using os.fstat on its file descriptor). You can - modify some of the TarInfo's attributes before you add it using - addfile(). If given, `arcname' specifies an alternative name for the - file in the archive. + """Create a TarInfo object from the result of os.stat or equivalent + on an existing file. The file is either named by `name', or + specified as a file object `fileobj' with a file descriptor. If + given, `arcname' specifies an alternative name for the file in the + archive, otherwise, the name is taken from the 'name' attribute of + 'fileobj', or the 'name' argument. The name should be a text + string. """ self._check("awx") @@ -1782,7 +1784,7 @@ class TarFile(object): # Now, fill the TarInfo object with # information specific for the file. tarinfo = self.tarinfo() - tarinfo.tarfile = self + tarinfo.tarfile = self # Not needed # Use os.stat or os.lstat, depending on platform # and if symlinks shall be resolved. @@ -1949,10 +1951,9 @@ class TarFile(object): def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is - given, tarinfo.size bytes are read from it and added to the archive. - You can create TarInfo objects using gettarinfo(). - On Windows platforms, `fileobj' should always be opened with mode - 'rb' to avoid irritation about the file size. + given, it should be a binary file, and tarinfo.size bytes are read + from it and added to the archive. You can create TarInfo objects + directly, or by using gettarinfo(). """ self._check("awx") |