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. `members' is optional and must be a subset of the list returned by getmembers().
(self, verbose=True, *, members=None)
| 2102 | return tarinfo |
| 2103 | |
| 2104 | def list(self, verbose=True, *, members=None): |
| 2105 | """Print a table of contents to sys.stdout. If `verbose' is False, only |
| 2106 | the names of the members are printed. If it is True, an `ls -l'-like |
| 2107 | output is produced. `members' is optional and must be a subset of the |
| 2108 | list returned by getmembers(). |
| 2109 | """ |
| 2110 | self._check() |
| 2111 | |
| 2112 | if members is None: |
| 2113 | members = self |
| 2114 | for tarinfo in members: |
| 2115 | if verbose: |
| 2116 | if tarinfo.mode is None: |
| 2117 | _safe_print("??????????") |
| 2118 | else: |
| 2119 | _safe_print(stat.filemode(tarinfo.mode)) |
| 2120 | _safe_print("%s/%s" % (tarinfo.uname or tarinfo.uid, |
| 2121 | tarinfo.gname or tarinfo.gid)) |
| 2122 | if tarinfo.ischr() or tarinfo.isblk(): |
| 2123 | _safe_print("%10s" % |
| 2124 | ("%d,%d" % (tarinfo.devmajor, tarinfo.devminor))) |
| 2125 | else: |
| 2126 | _safe_print("%10d" % tarinfo.size) |
| 2127 | if tarinfo.mtime is None: |
| 2128 | _safe_print("????-??-?? ??:??:??") |
| 2129 | else: |
| 2130 | _safe_print("%d-%02d-%02d %02d:%02d:%02d" \ |
| 2131 | % time.localtime(tarinfo.mtime)[:6]) |
| 2132 | |
| 2133 | _safe_print(tarinfo.name + ("/" if tarinfo.isdir() else "")) |
| 2134 | |
| 2135 | if verbose: |
| 2136 | if tarinfo.issym(): |
| 2137 | _safe_print("-> " + tarinfo.linkname) |
| 2138 | if tarinfo.islnk(): |
| 2139 | _safe_print("link to " + tarinfo.linkname) |
| 2140 | print() |
| 2141 | |
| 2142 | def add(self, name, arcname=None, recursive=True, *, filter=None): |
| 2143 | """Add the file `name' to the archive. `name' may be any type of file |