'Check for errors before writing a file to the archive.'

def _writecheck(self, zinfo):

    if (zinfo.filename in self.NameToInfo):
        if self.debug:
            print 'Duplicate    name:', zinfo.filename
    if (self.mode not in ('w', 'a')):
        raise RuntimeError('write()    requires    mode    "w"    or    "a"')
    if (not self.fp):
        raise RuntimeError('Attempt    to    write    ZIP    archive    that    was    already    closed')
    if ((zinfo.compress_type == ZIP_DEFLATED) and (not zlib)):
        raise RuntimeError('Compression    requires    the    (missing)    zlib    module')
    if (zinfo.compress_type not in (ZIP_STORED, ZIP_DEFLATED)):
        raise RuntimeError(('The    compression    method    %s    is    not    supported' % zinfo.compress_type))
    if (zinfo.file_size > ZIP64_LIMIT):
        if (not self._allowZip64):
            raise LargeZipFile('Filesize    would    require    ZIP64    extensions')
    if (zinfo.header_offset > ZIP64_LIMIT):
        if (not self._allowZip64):
            raise LargeZipFile('Zipfile    size    would    require    ZIP64    extensions')
