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

def _writecheck(self, zinfo):

    if (zinfo.filename in self.NameToInfo):
        import warnings
        warnings.warn(('Duplicate    name:    %r' % zinfo.filename), stacklevel=3)
    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, 'That    compression    method    is    not    supported'
    if (not self._allowZip64):
        requires_zip64 = None
        if (len(self.filelist) >= ZIP_FILECOUNT_LIMIT):
            requires_zip64 = 'Files    count'
        elif (zinfo.file_size > ZIP64_LIMIT):
            requires_zip64 = 'Filesize'
        elif (zinfo.header_offset > ZIP64_LIMIT):
            requires_zip64 = 'Zipfile    size'
        if requires_zip64:
            raise LargeZipFile((requires_zip64 + '    would    require    ZIP64    extensions'))
