Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
2d2d08d2
Kaydet (Commit)
2d2d08d2
authored
Şub 19, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #22468: Merge gettarinfo() doc from 3.5
üst
7db1d162
f817a48d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
20 deletions
+28
-20
tarfile.rst
Doc/library/tarfile.rst
+17
-10
tarfile.py
Lib/tarfile.py
+11
-10
No files found.
Doc/library/tarfile.rst
Dosyayı görüntüle @
2d2d08d2
...
@@ -456,21 +456,28 @@ be finalized; only the internally used file object will be closed. See the
...
@@ -456,21 +456,28 @@ be finalized; only the internally used file object will be closed. See the
.. method:: TarFile.addfile(tarinfo, fileobj=None)
.. method:: TarFile.addfile(tarinfo, fileobj=None)
Add the :class:`TarInfo` object *tarinfo* to the archive. If *fileobj* is given,
Add the :class:`TarInfo` object *tarinfo* to the archive. If *fileobj* is given,
it should be a :term:`binary file`, and
``tarinfo.size`` bytes are read from it and added to the archive. You can
``tarinfo.size`` bytes are read from it and added to the archive. You can
create :class:`TarInfo` objects using :meth:`gettarinfo`.
create :class:`TarInfo` objects directly, or by using :meth:`gettarinfo`.
.. note::
On Windows platforms, *fileobj* should always be opened with mode ``'rb'`` to
avoid irritation about the file size.
.. method:: TarFile.gettarinfo(name=None, arcname=None, fileobj=None)
.. method:: TarFile.gettarinfo(name=None, arcname=None, fileobj=None)
Create a :class:`TarInfo` object for either the file *name* or the :term:`file
Create a :class:`TarInfo` object from the result of :func:`os.stat` or
object` *fileobj* (using :func:`os.fstat` on its file descriptor). You can modify
equivalent on an existing file. The file is either named by *name*, or
some of the :class:`TarInfo`'s attributes before you add it using :meth:`addfile`.
specified as a :term:`file object` *fileobj* with a file descriptor. If
If given, *arcname* specifies an alternative name for the file in the archive.
given, *arcname* specifies an alternative name for the file in the
archive, otherwise, the name is taken from *fileobj*’s
:attr:`~io.FileIO.name` attribute, or the *name* argument. The name
should be a text string.
You can modify
some of the :class:`TarInfo`’s attributes before you add it using :meth:`addfile`.
If the file object is not an ordinary file object positioned at the
beginning of the file, attributes such as :attr:`~TarInfo.size` may need
modifying. This is the case for objects such as :class:`~gzip.GzipFile`.
The :attr:`~TarInfo.name` may also be modified, in which case *arcname*
could be a dummy string.
.. method:: TarFile.close()
.. method:: TarFile.close()
...
...
Lib/tarfile.py
Dosyayı görüntüle @
2d2d08d2
...
@@ -1757,11 +1757,13 @@ class TarFile(object):
...
@@ -1757,11 +1757,13 @@ class TarFile(object):
return
[
tarinfo
.
name
for
tarinfo
in
self
.
getmembers
()]
return
[
tarinfo
.
name
for
tarinfo
in
self
.
getmembers
()]
def
gettarinfo
(
self
,
name
=
None
,
arcname
=
None
,
fileobj
=
None
):
def
gettarinfo
(
self
,
name
=
None
,
arcname
=
None
,
fileobj
=
None
):
"""Create a TarInfo object for either the file `name' or the file
"""Create a TarInfo object from the result of os.stat or equivalent
object `fileobj' (using os.fstat on its file descriptor). You can
on an existing file. The file is either named by `name', or
modify some of the TarInfo's attributes before you add it using
specified as a file object `fileobj' with a file descriptor. If
addfile(). If given, `arcname' specifies an alternative name for the
given, `arcname' specifies an alternative name for the file in the
file in the archive.
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"
)
self
.
_check
(
"awx"
)
...
@@ -1782,7 +1784,7 @@ class TarFile(object):
...
@@ -1782,7 +1784,7 @@ class TarFile(object):
# Now, fill the TarInfo object with
# Now, fill the TarInfo object with
# information specific for the file.
# information specific for the file.
tarinfo
=
self
.
tarinfo
()
tarinfo
=
self
.
tarinfo
()
tarinfo
.
tarfile
=
self
tarinfo
.
tarfile
=
self
# Not needed
# Use os.stat or os.lstat, depending on platform
# Use os.stat or os.lstat, depending on platform
# and if symlinks shall be resolved.
# and if symlinks shall be resolved.
...
@@ -1949,10 +1951,9 @@ class TarFile(object):
...
@@ -1949,10 +1951,9 @@ class TarFile(object):
def
addfile
(
self
,
tarinfo
,
fileobj
=
None
):
def
addfile
(
self
,
tarinfo
,
fileobj
=
None
):
"""Add the TarInfo object `tarinfo' to the archive. If `fileobj' is
"""Add the TarInfo object `tarinfo' to the archive. If `fileobj' is
given, tarinfo.size bytes are read from it and added to the archive.
given, it should be a binary file, and tarinfo.size bytes are read
You can create TarInfo objects using gettarinfo().
from it and added to the archive. You can create TarInfo objects
On Windows platforms, `fileobj' should always be opened with mode
directly, or by using gettarinfo().
'rb' to avoid irritation about the file size.
"""
"""
self
.
_check
(
"awx"
)
self
.
_check
(
"awx"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment