parameters: (self, filename, arcname=None,
                compress_type=None, compresslevel=None)
docstring: Put the bytes from filename into the archive under the name
          arcname.
docstring_summary: Put the bytes from filename into the archive under the name
          arcname.
docstring_tokens: Put the bytes from filename into the archive under the name arcname .
function: def write(self, filename, arcname=None,
                compress_type=None, compresslevel=None):
          """Put the bytes from filename into the archive under the name
          arcname."""
          if not self.fp:
              raise ValueError(
                  "Attempt to write to ZIP archive that was already closed")
          if self._writing:
              raise ValueError(
                  "Can't write to ZIP archive while an open writing handle exists"
              )
  
          zinfo = ZipInfo.from_file(filename, arcname)
  
          if zinfo.is_dir():
              zinfo.compress_size = 0
              zinfo.CRC = 0
          else:
              if compress_type is not None:
                  zinfo.compress_type = compress_type
              else:
                  zinfo.compress_type = self.compression
  
              if compresslevel is not None:
                  zinfo._compresslevel = compresslevel
              else:
                  zinfo._compresslevel = self.compresslevel
  
          if zinfo.is_dir():
              with self._lock:
                  if self._seekable:
                      self.fp.seek(self.start_dir)
                  zinfo.header_offset = self.fp.tell()  # Start of header bytes
                  if zinfo.compress_type == ZIP_LZMA:
                  # Compressed data includes an end-of-stream (EOS) marker
                      zinfo.flag_bits |= 0x02
  
                  self._writecheck(zinfo)
                  self._didModify = True
  
                  self.filelist.append(zinfo)
                  self.NameToInfo[zinfo.filename] = zinfo
                  self.fp.write(zinfo.FileHeader(False))
                  self.start_dir = self.fp.tell()
          else:
              with open(filename, "rb") as src, self.open(zinfo, 'w') as dest:
                  shutil.copyfileobj(src, dest, 1024*8)
function_tokens: def write ( self , filename , arcname = None , compress_type = None , compresslevel = None ) : if not self . fp : raise ValueError ( "Attempt to write to ZIP archive that was already closed" ) if self . _writing : raise ValueError ( "Can't write to ZIP archive while an open writing handle exists" ) zinfo = ZipInfo . from_file ( filename , arcname ) if zinfo . is_dir ( ) : zinfo . compress_size = 0 zinfo . CRC = 0 else : if compress_type is not None : zinfo . compress_type = compress_type else : zinfo . compress_type = self . compression if compresslevel is not None : zinfo . _compresslevel = compresslevel else : zinfo . _compresslevel = self . compresslevel if zinfo . is_dir ( ) : with self . _lock : if self . _seekable : self . fp . seek ( self . start_dir ) zinfo . header_offset = self . fp . tell ( ) # Start of header bytes if zinfo . compress_type == ZIP_LZMA : # Compressed data includes an end-of-stream (EOS) marker zinfo . flag_bits |= 0x02 self . _writecheck ( zinfo ) self . _didModify = True self . filelist . append ( zinfo ) self . NameToInfo [ zinfo . filename ] = zinfo self . fp . write ( zinfo . FileHeader ( False ) ) self . start_dir = self . fp . tell ( ) else : with open ( filename , "rb" ) as src , self . open ( zinfo , 'w' ) as dest : shutil . copyfileobj ( src , dest , 1024 * 8 )