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
a7eb7462
Kaydet (Commit)
a7eb7462
authored
Agu 21, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #21549: Added the "members" parameter to TarFile.list().
üst
48ad7c0b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
5 deletions
+26
-5
tarfile.rst
Doc/library/tarfile.rst
+6
-2
tarfile.py
Lib/tarfile.py
+6
-3
test_tarfile.py
Lib/test/test_tarfile.py
+12
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/tarfile.rst
Dosyayı görüntüle @
a7eb7462
...
@@ -325,11 +325,15 @@ be finalized; only the internally used file object will be closed. See the
...
@@ -325,11 +325,15 @@ be finalized; only the internally used file object will be closed. See the
returned by :meth:`getmembers`.
returned by :meth:`getmembers`.
.. method:: TarFile.list(verbose=True)
.. method:: TarFile.list(verbose=True
, *, members=None
)
Print a table of contents to ``sys.stdout``. If *verbose* is :const:`False`,
Print a table of contents to ``sys.stdout``. If *verbose* is :const:`False`,
only the names of the members are printed. If it is :const:`True`, output
only the names of the members are printed. If it is :const:`True`, output
similar to that of :program:`ls -l` is produced.
similar to that of :program:`ls -l` is produced. If optional *members* is
given, it must be a subset of the list returned by :meth:`getmembers`.
.. versionchanged:: 3.5
Added the *members* parameter.
.. method:: TarFile.next()
.. method:: TarFile.next()
...
...
Lib/tarfile.py
Dosyayı görüntüle @
a7eb7462
...
@@ -1842,14 +1842,17 @@ class TarFile(object):
...
@@ -1842,14 +1842,17 @@ class TarFile(object):
tarinfo
.
devminor
=
os
.
minor
(
statres
.
st_rdev
)
tarinfo
.
devminor
=
os
.
minor
(
statres
.
st_rdev
)
return
tarinfo
return
tarinfo
def
list
(
self
,
verbose
=
True
):
def
list
(
self
,
verbose
=
True
,
*
,
members
=
None
):
"""Print a table of contents to sys.stdout. If `verbose' is False, only
"""Print a table of contents to sys.stdout. If `verbose' is False, only
the names of the members are printed. If it is True, an `ls -l'-like
the names of the members are printed. If it is True, an `ls -l'-like
output is produced.
output is produced. `members' is optional and must be a subset of the
list returned by getmembers().
"""
"""
self
.
_check
()
self
.
_check
()
for
tarinfo
in
self
:
if
members
is
None
:
members
=
self
for
tarinfo
in
members
:
if
verbose
:
if
verbose
:
_safe_print
(
stat
.
filemode
(
tarinfo
.
mode
))
_safe_print
(
stat
.
filemode
(
tarinfo
.
mode
))
_safe_print
(
"
%
s/
%
s"
%
(
tarinfo
.
uname
or
tarinfo
.
uid
,
_safe_print
(
"
%
s/
%
s"
%
(
tarinfo
.
uname
or
tarinfo
.
uid
,
...
...
Lib/test/test_tarfile.py
Dosyayı görüntüle @
a7eb7462
...
@@ -285,6 +285,18 @@ class ListTest(ReadTest, unittest.TestCase):
...
@@ -285,6 +285,18 @@ class ListTest(ReadTest, unittest.TestCase):
self
.
assertIn
(
b
'pax'
+
(
b
'/123'
*
125
)
+
b
'/longlink link to pax'
+
self
.
assertIn
(
b
'pax'
+
(
b
'/123'
*
125
)
+
b
'/longlink link to pax'
+
(
b
'/123'
*
125
)
+
b
'/longname'
,
out
)
(
b
'/123'
*
125
)
+
b
'/longname'
,
out
)
def
test_list_members
(
self
):
tio
=
io
.
TextIOWrapper
(
io
.
BytesIO
(),
'ascii'
,
newline
=
'
\n
'
)
def
members
(
tar
):
for
tarinfo
in
tar
.
getmembers
():
if
'reg'
in
tarinfo
.
name
:
yield
tarinfo
with
support
.
swap_attr
(
sys
,
'stdout'
,
tio
):
self
.
tar
.
list
(
verbose
=
False
,
members
=
members
(
self
.
tar
))
out
=
tio
.
detach
()
.
getvalue
()
self
.
assertIn
(
b
'ustar/regtype'
,
out
)
self
.
assertNotIn
(
b
'ustar/conttype'
,
out
)
class
GzipListTest
(
GzipTest
,
ListTest
):
class
GzipListTest
(
GzipTest
,
ListTest
):
pass
pass
...
...
Misc/NEWS
Dosyayı görüntüle @
a7eb7462
...
@@ -124,6 +124,8 @@ Core and Builtins
...
@@ -124,6 +124,8 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
21549
:
Added
the
"members"
parameter
to
TarFile
.
list
().
-
Issue
#
19628
:
Allow
compileall
recursion
depth
to
be
specified
with
a
-
r
-
Issue
#
19628
:
Allow
compileall
recursion
depth
to
be
specified
with
a
-
r
option
.
option
.
...
...
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