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

Method close

tools/python-3.11.9-amd64/Lib/zipfile.py:1896–1916  ·  view source on GitHub ↗

Close the file, and for mode 'w', 'x' and 'a' write the ending records.

(self)

Source from the content-addressed store, hash-verified

1894 self.close()
1895
1896 def close(self):
1897 """Close the file, and for mode 'w', 'x' and 'a' write the ending
1898 records."""
1899 if self.fp is None:
1900 return
1901
1902 if self._writing:
1903 raise ValueError("Can't close the ZIP file while there is "
1904 "an open writing handle on it. "
1905 "Close the writing handle before closing the zip.")
1906
1907 try:
1908 if self.mode in ('w', 'x', 'a') and self._didModify: # write ending records
1909 with self._lock:
1910 if self._seekable:
1911 self.fp.seek(self.start_dir)
1912 self._write_end_record()
1913 finally:
1914 fp = self.fp
1915 self.fp = None
1916 self._fpclose(fp)
1917
1918 def _write_end_record(self):
1919 for zinfo in self.filelist: # write central directory

Callers 15

_unpack_zipfileFunction · 0.95
__exit__Method · 0.95
__del__Method · 0.95
test_prune_file_listMethod · 0.95
test_add_defaultsMethod · 0.95
test_simple_builtMethod · 0.95
create_zipfileMethod · 0.95
get_exe_prefixesFunction · 0.95
make_zipfileFunction · 0.95
unarchiveFunction · 0.95
__exit__Method · 0.95
closeMethod · 0.45

Calls 3

_write_end_recordMethod · 0.95
_fpcloseMethod · 0.95
seekMethod · 0.45

Tested by 3

test_prune_file_listMethod · 0.76
test_add_defaultsMethod · 0.76
test_simple_builtMethod · 0.76