코드가 하는 일을 읽고, 가려진 빈칸에 직접 이름을 지어 넣으세요. 빈칸 폭이 원본 이름의 글자 수입니다.
1def (path: str) -> str: 2 3 if os.path.exists(path): 4 5 return path 6 7 archive, member = os.path.split(path) 8 while archive and not os.path.exists(archive): 9 archive, prefix = os.path.split(archive) 10 if not prefix: 11 12 break 13 member = "/".join([prefix, member]) 14 15 if not zipfile.is_zipfile(archive): 16 return path 17 18 zip_file = zipfile.ZipFile(archive) 19 if member not in zip_file.namelist(): 20 return path 21 22 suffix = os.path.splitext(member.split("/")[-1])[-1] 23 fd, extracted_path = tempfile.mkstemp(suffix=suffix) 24 try: 25 os.write(fd, zip_file.read(member)) 26 finally: 27 os.close(fd) 28 29 return extracted_path