'Write a file into the archive.  The contents is the string
\'bytes\'.  \'zinfo_or_arcname\' is either a ZipInfo instance or
the name of the file in the archive.'

def writestr(self, zinfo_or_arcname, bytes, compress_type=None):

    if (not isinstance(zinfo_or_arcname, ZipInfo)):
        zinfo = ZipInfo(filename=zinfo_or_arcname, date_time=time.localtime(time.time())[:6])
        zinfo.compress_type = self.compression
        zinfo.external_attr = (384 << 16)
    else:
        zinfo = zinfo_or_arcname
    if (not self.fp):
        raise RuntimeError('Attempt    to    write    to    ZIP    archive    that    was    already    closed')
    if (compress_type is not None):
        zinfo.compress_type = compress_type
    zinfo.file_size = len(bytes)
    zinfo.header_offset = self.fp.tell()
    self._writecheck(zinfo)
    self._didModify = True
    zinfo.CRC = (crc32(bytes) & 4294967295)
    if (zinfo.compress_type == ZIP_DEFLATED):
        co = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, (-15))
        bytes = (co.compress(bytes) + co.flush())
        zinfo.compress_size = len(bytes)
    else:
        zinfo.compress_size = zinfo.file_size
    zip64 = ((zinfo.file_size > ZIP64_LIMIT) or (zinfo.compress_size > ZIP64_LIMIT))
    if (zip64 and (not self._allowZip64)):
        raise LargeZipFile('Filesize    would    require    ZIP64    extensions')
    self.fp.write(zinfo.FileHeader(zip64))
    self.fp.write(bytes)
    if (zinfo.flag_bits & 8):
        fmt = ('<LQQ' if zip64 else '<LLL')
        self.fp.write(struct.pack(fmt, zinfo.CRC, zinfo.compress_size, zinfo.file_size))
    self.fp.flush()
    self.filelist.append(zinfo)
    self.NameToInfo[zinfo.filename] = zinfo
