diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2012-05-15 13:30:25 (GMT) |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2012-05-15 13:30:25 (GMT) |
commit | ffa1d0b8d53f426f1f9a0d47f25440b8994c4fb0 (patch) | |
tree | 2c5626573e004979e0c38b58ed9ce31a3c96dcb5 /Lib/tarfile.py | |
parent | 41829e82c1826dd71b64f8334959bcf7731f66fc (diff) | |
download | cpython-ffa1d0b8d53f426f1f9a0d47f25440b8994c4fb0.zip cpython-ffa1d0b8d53f426f1f9a0d47f25440b8994c4fb0.tar.gz cpython-ffa1d0b8d53f426f1f9a0d47f25440b8994c4fb0.tar.bz2 |
#14807: move undocumented tarfile.filemode() to stat.filemode(). Add tarfile.filemode alias with deprecation warning.
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r-- | Lib/tarfile.py | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 8dd4c0f..9d38421 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -274,47 +274,13 @@ def copyfileobj(src, dst, length=None): dst.write(buf) return -filemode_table = ( - ((S_IFLNK, "l"), - (S_IFREG, "-"), - (S_IFBLK, "b"), - (S_IFDIR, "d"), - (S_IFCHR, "c"), - (S_IFIFO, "p")), - - ((TUREAD, "r"),), - ((TUWRITE, "w"),), - ((TUEXEC|TSUID, "s"), - (TSUID, "S"), - (TUEXEC, "x")), - - ((TGREAD, "r"),), - ((TGWRITE, "w"),), - ((TGEXEC|TSGID, "s"), - (TSGID, "S"), - (TGEXEC, "x")), - - ((TOREAD, "r"),), - ((TOWRITE, "w"),), - ((TOEXEC|TSVTX, "t"), - (TSVTX, "T"), - (TOEXEC, "x")) -) - def filemode(mode): - """Convert a file's mode to a string of the form - -rwxrwxrwx. - Used by TarFile.list() - """ - perm = [] - for table in filemode_table: - for bit, char in table: - if mode & bit == bit: - perm.append(char) - break - else: - perm.append("-") - return "".join(perm) + """Deprecated in this location; use stat.filemode.""" + import warnings + warnings.warn("deprecated in favor of stat.filemode", + DeprecationWarning, 2) + return stat.filemode(mode) + class TarError(Exception): """Base exception.""" @@ -1891,7 +1857,7 @@ class TarFile(object): for tarinfo in self: if verbose: - print(filemode(tarinfo.mode), end=' ') + print(stat.filemode(tarinfo.mode), end=' ') print("%s/%s" % (tarinfo.uname or tarinfo.uid, tarinfo.gname or tarinfo.gid), end=' ') if tarinfo.ischr() or tarinfo.isblk(): |