Write a binary file to the MOJO archive.
14309
protected final void writeblob(String filename, byte[] blob) throws IOException {
    ZipEntry archiveEntry = new ZipEntry(targetdir + filename);
    archiveEntry.setSize(blob.length);
    zos.putNextEntry(archiveEntry);
    zos.write(blob);
    zos.closeEntry();
  }
1225862
def _write_report(report, file_path):
        """"""
        with open(file_path, mode='wb') as f:
            if not isinstance(report, binary_type):
                report = report.encode('utf-8')
            f.write(report)
849199
def write_file(self, file, verbose=False):
        """"""
        dat = self.get_midi_data()
        try:
            f = open(file, 'wb')
        except:
            print "Couldn't open '%s' for writing." % file
            return False
        try:
            f.write(dat)
        except:
            print 'An error occured while writing data to %s.' % file
            return False
        f.close()
        if verbose:
            print 'Written %d bytes to %s.' % (len(dat), file)
        return True
866167
def write(self, arg, **kwargs):
        """"""
        if hasattr(arg, 'seek'):
            self._tofile(arg, **kwargs)
        else:
            with open(arg, 'wb') as fid:
                self._tofile(fid, **kwargs)
766062
def write_Composition(composition, filename, zip=False):
    """"""
    text = from_Composition(composition)
    if not zip:
        f = open(filename + '.xml', 'w')
        f.write(text)
        f.close()
    else:
        import zipfile
        import os
        zf = zipfile.ZipFile(filename + '.mxl', mode='w',
                             compression=zipfile.ZIP_DEFLATED)
        zi = zipfile.ZipInfo('META-INF' + os.sep + 'container.xml')
        zi.external_attr = 0660 << 16L
        zf.writestr(zi,
                    "<?xml version='1.0' encoding='UTF-8'?>"
                    "<container><rootfiles><rootfile full-path='{0}.xml'/>"
                    "</rootfiles></container>".format(filename))
        zi = zipfile.ZipInfo(filename + '.xml')
        zi.external_attr = 0660 << 16L
        zf.writestr(zi, text)
        zf.close()
113532
def write(self):
        """"""
        self._assure_writable("write")
        if not self._dirty:
            return

        if isinstance(self._file_or_files, (list, tuple)):
            raise AssertionError("Cannot write back if there is not exactly a single file to write to, have %i files"
                                 % len(self._file_or_files))
        # end assert multiple files

        if self._has_includes():
            log.debug("Skipping write-back of configuration file as include files were merged in." +
                      "Set merge_includes=False to prevent this.")
            return
        # end

        fp = self._file_or_files

        # we have a physical file on disk, so get a lock
        is_file_lock = isinstance(fp, string_types + (FileType, ))
        if is_file_lock:
            self._lock._obtain_lock()
        if not hasattr(fp, "seek"):
            with open(self._file_or_files, "wb") as fp:
                self._write(fp)
        else:
            fp.seek(0)
            # make sure we do not overwrite into an existing file
            if hasattr(fp, 'truncate'):
                fp.truncate()
            self._write(fp)
197664
def write(dest)
      path = destination(dest)
      FileUtils.mkdir_p(File.dirname(path))
      File.write(path, output, :mode => "wb")

      trigger_hooks(:post_write)
    end
419257
def _write_to_file(self, filename, bytesvalue):
        """"""
        fh, tmp = tempfile.mkstemp()
        with os.fdopen(fh, self._flag) as f:
            f.write(self._dumps(bytesvalue))
        rename(tmp, filename)
        os.chmod(filename, self._mode)
311359
def save_binary(self, fname, silent=True):
        
        _check_call(_LIB.XGDMatrixSaveBinary(self.handle,
                                             c_str(fname),
                                             int(silent)))
408073
def write(self, fn=None):
        """"""
        fn = fn or self.fn
        if not os.path.exists(os.path.dirname(fn)):
            os.makedirs(os.path.dirname(fn))
        f = open(self.fn, 'rb')
        b = f.read()
        f.close()
        f = open(fn, 'wb')
        f.write(b)
        f.close()
829283
def encode(binary):
    """"""
    encoded = io.BytesIO()
    gzip_file = dict(mode='wb', fileobj=encoded, compresslevel=LEVEL)
    with gzip.GzipFile(**gzip_file) as file_:
        file_.write(binary)
    encoded.seek(0)
    return encoded.read()
840345
def write_output(output, text=True, output_path=None):
    """"""

    if output_path is None and text is False:
        print("ERROR: You must specify an output file using -o/--output for binary output formats")
        sys.exit(1)

    if output_path is not None:
        if text:
            outfile = open(output_path, "w", encoding="utf-8")
        else:
            outfile = open(output_path, "wb")
    else:
        outfile = sys.stdout

    try:
        if text and isinstance(output, bytes):
            output = output.decode('utf-8')

        outfile.write(output)
    finally:
        if outfile is not sys.stdout:
            outfile.close()
521040
def write_directory (zfile, directory):
    """"""
    for dirpath, dirnames, filenames in os.walk(directory):
        zfile.write(dirpath)
        for filename in filenames:
            zfile.write(os.path.join(dirpath, filename))
1040905
def save_bin(self, bin_form, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinAdminSession.update_bin
        if bin_form.is_for_update():
            return self.update_bin(bin_form, *args, **kwargs)
        else:
            return self.create_bin(bin_form, *args, **kwargs)
1235503
def write_pkg_to_file(self, name, objects, path='.', filename=None):
        """"""
        # Kibana uses an array of docs, do the same
        # as opposed to a dict of docs
        pkg_objs = []
        for _, obj in iteritems(objects):
            pkg_objs.append(obj)
        sorted_pkg = sorted(pkg_objs, key=lambda k: k['_id'])
        output = self.json_dumps(sorted_pkg) + '\n'
        if filename is None:
            filename = self.safe_filename('Pkg', name)
        filename = os.path.join(path, filename)
        self.pr_inf("Writing to file: " + filename)
        with open(filename, 'w') as f:
            f.write(output)
        return filename
93250
def write(self):
        
        if not os.path.isdir(self._dirs['source_dir']):
            os.mkdir(self._dirs['source_dir'])

        fout = codecs.open(self._dirs['source_filename'], 'w', encoding="utf-8", errors="xmlcharrefreplace")
        fout.write(self._config_to_text())
        if self._content:
            fout.write('\n')
            fout.write(self._content)
            fout.write('\n')
        fout.close()
919018
def write(path, data, binary=False):
    
    mode = "w"
    if binary:
        mode = "wb"
    with open(path, mode) as f:
        f.write(data)
    f.close()