diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-08-21 07:01:16 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-08-21 07:01:16 (GMT) |
commit | a7eb74627826e389dd78bd5a7a3b0878f4e3dde6 (patch) | |
tree | c0b9b7c3d2da3fc8945e7a31b59aebaead0c9cc1 /Lib/tarfile.py | |
parent | 48ad7c0b01de1be182c3894e1691861ccffb82ea (diff) | |
download | cpython-a7eb74627826e389dd78bd5a7a3b0878f4e3dde6.zip cpython-a7eb74627826e389dd78bd5a7a3b0878f4e3dde6.tar.gz cpython-a7eb74627826e389dd78bd5a7a3b0878f4e3dde6.tar.bz2 |
Issue #21549: Added the "members" parameter to TarFile.list().
Diffstat (limited to 'Lib/tarfile.py')
-rwxr-xr-x | Lib/tarfile.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 9e291c2..4b4e0d3 100755 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1842,14 +1842,17 @@ class TarFile(object): tarinfo.devminor = os.minor(statres.st_rdev) 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 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() - for tarinfo in self: + if members is None: + members = self + for tarinfo in members: if verbose: _safe_print(stat.filemode(tarinfo.mode)) _safe_print("%s/%s" % (tarinfo.uname or tarinfo.uid, |