(filepath, output_dir)
| 287 | |
| 288 | |
| 289 | def _extract_tar(filepath, output_dir): |
| 290 | with tarfile.open(filepath, "r") as tar_file: |
| 291 | for member in tar_file.getmembers(): |
| 292 | safe_path = safe_extract_member(member, output_dir) |
| 293 | if not member.isfile(): |
| 294 | continue |
| 295 | os.makedirs(os.path.dirname(safe_path), exist_ok=True) |
| 296 | source = tar_file.extractfile(member) |
| 297 | if source is not None: |
| 298 | with source: |
| 299 | with open(safe_path, "wb") as target: |
| 300 | shutil.copyfileobj(source, target) |
| 301 | |
| 302 | |
| 303 | def extractall( |
no test coverage detected
searching dependent graphs…