open: Opens zipfile to write to
            Args: None
            Returns: None
340378
def open(self):
        
        self.zf = zipfile.ZipFile(self.write_to_path, self.mode)
1349050
def extract_zip(filename, extract_dir):
    
    LOG.info("Extracting %s in %s " % (filename, extract_dir))
    if not os.path.exists(extract_dir):
        try:
            os.mkdir(extract_dir)
        except IOError as err:  # pragma: no cover
            LOG.info("Could not generate the folder %s" % extract_dir)
            LOG.debug("Error: %s" % err)
            return

    if zipfile.is_zipfile(filename):
        try:
            zfile = zipfile.ZipFile(filename, "r")
            for name in zfile.namelist():
                if os.path.dirname(name):
                    curdir = os.path.join(extract_dir, os.path.dirname(name))
                    if not os.path.exists(curdir):
                        os.mkdir(curdir)
                        continue
                outfile = open(os.path.join(extract_dir, name), 'wb')
                outfile.write(zfile.read(name))
                outfile.flush()
                outfile.close()
            zfile.close()
        except IOError as err:  # pragma: no cover
            LOG.info("Error while extracting the zip archive.")
            LOG.debug("Error: %s" % err)
    else:
        try:  # pragma: no cover  We only have zipfile to test with
            tar = tarfile.open(filename)
            tar.extractall(extract_dir)
            tar.close()
        except tarfile.ReadError as err:  # pragma: no cover
            LOG.info("Error while extracting the tarball.")
            LOG.debug("Error: %s" % err)

    return extract_dir
542865
def unzipper(filename, dir_tmp):
    
    logger_zips.info("enter unzip")
    # Unzip contents to the tmp directory
    try:
        with zipfile.ZipFile(filename) as f:
            f.extractall(dir_tmp)
    except FileNotFoundError as e:
        logger_zips.debug("unzip: FileNotFound: {}, {}".format(filename, e))
        shutil.rmtree(dir_tmp)
    logger_zips.info("exit unzip")
    return
1147689
def read_zipfile(self, encoding='utf8'):
        
        from zipfile import ZipFile
        with ZipFile(self.abspath) as zipped:
            for num, zip_name in enumerate(zipped.namelist()):
                return zipped.open(zip_name).read().decode(encoding)
639588
def open(self):
        
        if self._f is not None:
            return self._f
        try:
            rv, self.should_close = open_stream(self.name, self.mode,
                                                self.encoding,
                                                self.errors,
                                                atomic=self.atomic)
        except (IOError, OSError) as e:
            from .exceptions import FileError
            raise FileError(self.name, hint=get_streerror(e))
        self._f = rv
        return rv
1112063
def WriteFileHeader(self, arcname=None, compress_type=None, st=None):
    """"""

    if not self._stream:
      raise ArchiveAlreadyClosedError(
          "Attempting to write to a ZIP archive that was already closed.")

    self.cur_zinfo = self._GenerateZipInfo(
        arcname=arcname, compress_type=compress_type, st=st)
    self.cur_file_size = 0
    self.cur_compress_size = 0

    if self.cur_zinfo.compress_type == zipfile.ZIP_DEFLATED:
      self.cur_cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION,
                                       zlib.DEFLATED, -15)
    else:
      self.cur_cmpr = None

    self.cur_crc = 0

    if not self._stream:
      raise ArchiveAlreadyClosedError(
          "Attempting to write to a ZIP archive that was already closed.")

    self.cur_zinfo.header_offset = self._stream.tell()
    # Call _writeCheck(self.cur_zinfo) to do sanity checking on zinfo structure
    # that we've constructed.
    self._zip_fd._writecheck(self.cur_zinfo)  # pylint: disable=protected-access
    # Mark ZipFile as dirty. We have to keep self._zip_fd's internal state
    # coherent so that it behaves correctly when close() is called.
    self._zip_fd._didModify = True  # pylint: disable=protected-access

    # Write FileHeader now. It's incomplete, but CRC and uncompressed/compressed
    # sized will be written later in data descriptor.
    self._stream.write(self.cur_zinfo.FileHeader())

    return self._stream.GetValueAndReset()
863601
def open(self, *args, **kwargs):
        
        with io_error_compat():
            return io.open(self, *args, **kwargs)
121142
def zipfiles(fnames, archive, mode='w', log=lambda msg: None, cleanup=False):
    
    prefix = len(os.path.commonprefix([os.path.dirname(f) for f in fnames]))
    with zipfile.ZipFile(
            archive, mode, zipfile.ZIP_DEFLATED, allowZip64=True) as z:
        for f in fnames:
            log('Archiving %s' % f)
            z.write(f, f[prefix:])
            if cleanup:  # remove the zipped file
                os.remove(f)
    log('Generated %s' % archive)
    return archive
861845
@Override
    @Trivial
    public ZipFile open() throws IOException {
        String methodName = "open";

        synchronized( zipFileLock ) {
            if ( zipFile == null ) {
                debug(methodName, "Opening");
                if ( zipFileReaper == null ) {
                    zipFile = ZipFileUtils.openZipFile(file); // throws IOException
                } else {
                    zipFile = zipFileReaper.open(path);
                }
            }

            openCount++;
            debug(methodName, "Opened");

            return zipFile;
        }
    }
1352225
def write_file(self, name, contents):
        """"""
        # TODO: find a way to make ZipFile accept a file object.
        zi = zipfile.ZipInfo(name)
        zi.date_time = time.localtime(time.time())[:6]
        zi.compress_type = zipfile.ZIP_DEFLATED
        zi.external_attr = 0777 << 16L
        self.zip_file.writestr(zi, contents)
66335
def mkopen(p, *args, **kwargs):
    
    dir = os.path.dirname(p)
    mkdir(dir)
    return open(p, *args, **kwargs)
828840
def try_open (*args, **kwargs):
    
    try:
        return io.open (*args, **kwargs)
    except IOError as e:
        if e.errno == 2:
            return None
        raise
528169
def bin_open(fname: str):
    
    if fname.endswith(".gz"):
        return gzip.open(fname, "rb")
    return open(fname, "rb")
178563
def do_write(self, args):
        

        if not self.current:
            print('There are no resources in use. Use the command "open".')
            return

        try:
            self.current.write(args)
        except Exception as e:
            print(e)
1192714
def try_opening_file(self):
        ''''''
        if os.path.isfile(self.path):
            self.file = open(self.path, 'r')
            self.file_is_opened = True
81098
def is_zipfile(filename):
    
    result = False
    try:
        if hasattr(filename, "read"):
            result = _check_zipfile(fp=filename)
        else:
            with open(filename, "rb") as fp:
                result = _check_zipfile(fp)
    except OSError:
        pass
    return result
99799
function unZipFile(zipFileName) {
  yauzl.open(zipFileName, {
    lazyEntries: true
  }, function (err, zipFile) {
    if (err) {
      throw err
    }
    zipFile.readEntry()
    zipFile.on('entry', function (entry) {
      if (targetEntry === entry.fileName) {
        mkdirp.sync(writeFolder)
        zipFile.openReadStream(entry, function (errInReadStream, readStream) {
          if (errInReadStream) {
            throw errInReadStream
          }
          readStream.pipe(fs.createWriteStream(binPath))
          readStream.on('end', function () {
            zipFile.readEntry()
            console.log('unzip completed ' + binPath)
            fs.chmodSync(binPath, '755')
            console.log('chmod 755')
          })
        })
      } else {
        zipFile.readEntry()
      }
    })
  })
}