MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / extractall

Method extractall

tools/python-3.11.9-amd64/Lib/tarfile.py:2236–2279  ·  view source on GitHub ↗

Extract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the li

(self, path=".", members=None, *, numeric_owner=False,
                   filter=None)

Source from the content-addressed store, hash-verified

2234 raise ValueError(f"filter {filter!r} not found") from None
2235
2236 def extractall(self, path=".", members=None, *, numeric_owner=False,
2237 filter=None):
2238 """Extract all members from the archive to the current working
2239 directory and set owner, modification time and permissions on
2240 directories afterwards. `path' specifies a different directory
2241 to extract to. `members' is optional and must be a subset of the
2242 list returned by getmembers(). If `numeric_owner` is True, only
2243 the numbers for user/group names are used and not the names.
2244
2245 The `filter` function will be called on each member just
2246 before extraction.
2247 It can return a changed TarInfo or None to skip the member.
2248 String names of common filters are accepted.
2249 """
2250 directories = []
2251
2252 filter_function = self._get_filter_function(filter)
2253 if members is None:
2254 members = self
2255
2256 for member in members:
2257 tarinfo = self._get_extract_tarinfo(member, filter_function, path)
2258 if tarinfo is None:
2259 continue
2260 if tarinfo.isdir():
2261 # For directories, delay setting attributes until later,
2262 # since permissions can interfere with extraction and
2263 # extracting contents can reset mtime.
2264 directories.append(tarinfo)
2265 self._extract_one(tarinfo, path, set_attrs=not tarinfo.isdir(),
2266 numeric_owner=numeric_owner)
2267
2268 # Reverse sort directories.
2269 directories.sort(key=lambda a: a.name, reverse=True)
2270
2271 # Set correct owner, mtime and filemode on directories.
2272 for tarinfo in directories:
2273 dirpath = os.path.join(path, tarinfo.name)
2274 try:
2275 self.chown(tarinfo, dirpath, numeric_owner=numeric_owner)
2276 self.utime(tarinfo, dirpath)
2277 self.chmod(tarinfo, dirpath)
2278 except ExtractError as e:
2279 self._handle_nonfatal_error(e)
2280
2281 def extract(self, member, path="", set_attrs=True, *, numeric_owner=False,
2282 filter=None):

Callers 3

_unpack_tarfileFunction · 0.45
mainFunction · 0.45

Calls 11

_get_filter_functionMethod · 0.95
_get_extract_tarinfoMethod · 0.95
_extract_oneMethod · 0.95
chownMethod · 0.95
utimeMethod · 0.95
chmodMethod · 0.95
isdirMethod · 0.45
appendMethod · 0.45
sortMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected