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

Method write

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

Put the bytes from filename into the archive under the name arcname.

(self, filename, arcname=None,
              compress_type=None, compresslevel=None)

Source from the content-addressed store, hash-verified

1781 " would require ZIP64 extensions")
1782
1783 def write(self, filename, arcname=None,
1784 compress_type=None, compresslevel=None):
1785 """Put the bytes from filename into the archive under the name
1786 arcname."""
1787 if not self.fp:
1788 raise ValueError(
1789 "Attempt to write to ZIP archive that was already closed")
1790 if self._writing:
1791 raise ValueError(
1792 "Can't write to ZIP archive while an open writing handle exists"
1793 )
1794
1795 zinfo = ZipInfo.from_file(filename, arcname,
1796 strict_timestamps=self._strict_timestamps)
1797
1798 if zinfo.is_dir():
1799 zinfo.compress_size = 0
1800 zinfo.CRC = 0
1801 self.mkdir(zinfo)
1802 else:
1803 if compress_type is not None:
1804 zinfo.compress_type = compress_type
1805 else:
1806 zinfo.compress_type = self.compression
1807
1808 if compresslevel is not None:
1809 zinfo._compresslevel = compresslevel
1810 else:
1811 zinfo._compresslevel = self.compresslevel
1812
1813 with open(filename, "rb") as src, self.open(zinfo, 'w') as dest:
1814 shutil.copyfileobj(src, dest, 1024*8)
1815
1816 def writestr(self, zinfo_or_arcname, data,
1817 compress_type=None, compresslevel=None):

Callers 13

make_zipfileFunction · 0.95
create_zipfileMethod · 0.95
make_zipfileFunction · 0.95
archiveMethod · 0.95
writeMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45
_open_to_writeMethod · 0.45
writestrMethod · 0.45
mkdirMethod · 0.45
_write_end_recordMethod · 0.45
writepyMethod · 0.45

Calls 5

mkdirMethod · 0.95
openMethod · 0.95
openFunction · 0.70
from_fileMethod · 0.45
is_dirMethod · 0.45

Tested by

no test coverage detected