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

def write(self, filename, arcname=None, compress_type=None):

    if (not self.fp):
        raise RuntimeError('Attempt    to    write    to    ZIP    archive    that    was    already    closed')
    st = os.stat(filename)
    isdir = stat.S_ISDIR(st.st_mode)
    mtime = time.localtime(st.st_mtime)
    date_time = mtime[0:6]
    if (arcname is None):
        arcname = filename
    arcname = os.path.normpath(os.path.splitdrive(arcname)[1])
    while (arcname[0] in (os.sep, os.altsep)):
        arcname = arcname[1:]
    if (not isinstance(arcname, unicode)):
        arcname = arcname.decode(filesystem_encoding)
    if (isdir and (not arcname.endswith('/'))):
        arcname += '/'
    zinfo = ZipInfo(arcname, date_time)
    zinfo.external_attr = ((st[0] & 65535) << 16L)
    if isdir:
        zinfo.compress_type = ZIP_STORED
    if (compress_type is None):
        zinfo.compress_type = self.compression
    else:
        zinfo.compress_type = compress_type
    zinfo.file_size = st.st_size
    zinfo.flag_bits = 0
    zinfo.header_offset = self.fp.tell()
    self._writecheck(zinfo)
    self._didModify = True
    if isdir:
        zinfo.file_size = 0
        zinfo.compress_size = 0
        zinfo.CRC = 0
        self.filelist.append(zinfo)
        self.NameToInfo[zinfo.filename] = zinfo
        self.fp.write(zinfo.FileHeader())
        return
    with open(filename, 'rb') as fp:
        zinfo.CRC = CRC = 0
        zinfo.compress_size = compress_size = 0
        zinfo.file_size = file_size = 0
        self.fp.write(zinfo.FileHeader())
        if (zinfo.compress_type == ZIP_DEFLATED):
            cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, (-15))
        else:
            cmpr = None
        while 1:
            buf = fp.read((1024 * 8))
            if (not buf):
                break
            file_size = (file_size + len(buf))
            CRC = (crc32(buf, CRC) & 4294967295)
            if cmpr:
                buf = cmpr.compress(buf)
                compress_size = (compress_size + len(buf))
            self.fp.write(buf)
    if cmpr:
        buf = cmpr.flush()
        compress_size = (compress_size + len(buf))
        self.fp.write(buf)
        zinfo.compress_size = compress_size
    else:
        zinfo.compress_size = file_size
    zinfo.CRC = CRC
    zinfo.file_size = file_size
    position = self.fp.tell()
    self.fp.seek((zinfo.header_offset + 14), 0)
    self.fp.write(struct.pack('<LLL', zinfo.CRC, zinfo.compress_size, zinfo.file_size))
    self.fp.seek(position, 0)
    self.filelist.append(zinfo)
    self.NameToInfo[zinfo.filename] = zinfo
