Persist the notebook to the given file.

        :param fn: the file name
499398
def _save( self, fn ):
        """"""

        # create JSON object
        j = json.dumps({ 'description': self.description(),
                         'pending': self._pending,
                         'results': self._results },
                       indent = 4,
                       cls = MetadataEncoder)

        # write to file
        with open(fn, 'w') as f:
            f.write(j)
991452
function (filename, fn) {

		fn = fn || function () {};

		this._image.pack().pipe(fs.createWriteStream(filename)).once('close', function () {
			this._image.removeListener('error', fn);
			fn(undefined, this);
		}.bind(this)).once('error', function (err) {
			this._image.removeListener('close', fn);
			fn(err, this);
		}.bind(this));
	}
318166
def save_file(self, filename, text):
        """"""
        if not filename.endswith('.py'):
            filename += '.py'
        path = os.path.join(self.currentpath, filename)
        with open(path, 'w', encoding="utf-8") as file_:
            file_.write(text)
498307
def _save_nb(nb_name):
    
    display(Javascript('IPython.notebook.save_checkpoint();'))
    display(Javascript('IPython.notebook.save_notebook();'))
    print('Saving notebook...', end=' ')

    if _wait_for_save(nb_name):
        print("Saved '{}'.".format(nb_name))
    else:
        logging.warning(
            "Could not save your notebook (timed out waiting for "
            "IPython save). Make sure your notebook is saved "
            "and export again."
        )
1282477
def save(self, fp, mode='wb'):
        
        if hasattr(fp, 'write'):
            self._record.write(fp)
        else:
            with open(fp, mode) as f:
                self._record.write(f)
1181861
def saveNetwork(self, filename, makeWrapper = 1, mode = "pickle", counter = None):
        
        self.saveNetworkToFile(filename, makeWrapper, mode, counter)
404126
def persist(name, value, config='/etc/sysctl.conf'):
    '''
    
    '''
    nlines = []
    edited = False
    value = six.text_type(value)

    with salt.utils.files.fopen(config, 'r') as ifile:
        for line in ifile:
            line = salt.utils.stringutils.to_unicode(line).rstrip('\n')
            if not line.startswith('{0}='.format(name)):
                nlines.append(line)
                continue
            else:
                key, rest = line.split('=', 1)
                if rest.startswith('"'):
                    _, rest_v, rest = rest.split('"', 2)
                elif rest.startswith('\''):
                    _, rest_v, rest = rest.split('\'', 2)
                else:
                    rest_v = rest.split()[0]
                    rest = rest[len(rest_v):]
                if rest_v == value:
                    return 'Already set'
                new_line = _formatfor(key, value, config, rest)
                nlines.append(new_line)
                edited = True
    if not edited:
        nlines.append("{0}\n".format(_formatfor(name, value, config)))
    with salt.utils.files.fopen(config, 'w+') as ofile:
        nlines = [salt.utils.stringutils.to_str(_l) + '\n' for _l in nlines]
        ofile.writelines(nlines)
    if config != '/boot/loader.conf':
        assign(name, value)
    return 'Updated'
1137974
def save(self, fname: str):
        
        obj = copy.deepcopy(self)
        obj.__del_frozen()
        with open(fname, 'w') as out:
            yaml.dump(obj, out, default_flow_style=False)
1356275
def save_file(self, file=None):
        

        editor = file and self.get_editor(file) or self.get_current_editor()
        if not editor:
            return False

        LOGGER.info("{0} | Saving '{1}' file!".format(self.__class__.__name__, editor.file))
        self.__lock_editor(editor)
        if not editor.is_untitled and foundations.common.path_exists(editor.file):
            return editor.save_file()
        else:
            return self.save_fileAs()
915718
def write_data_file(self, data, fn, sort_cols=False, data_format=None):
        
        report.saved_raw_data[fn] = data
        util_functions.write_data_file(data, fn, sort_cols, data_format)
358760
def save(self, f):
        """"""
        return pickle.dump((self.perceptron.weights, self.tagdict, self.classes, self.clusters), f, protocol=pickle.HIGHEST_PROTOCOL)
337873
def save(self, file, contents, name=None, overwrite=False):
        """"""
        if name is None:
            name = self.format_from_extension(op.splitext(file)[1])
        file_format = self.file_type(name)
        if file_format == 'text':
            _write_text(file, contents)
        elif file_format == 'json':
            _write_json(file, contents)
        else:
            write_function = self._formats[name].get('save', None)
            if write_function is None:
                raise IOError("The format must declare a file type or "
                              "load/save functions.")
            if op.exists(file) and not overwrite:
                print("The file already exists, please use overwrite=True.")
                return
            write_function(file, contents)
977219
def save(self, name):
        
        with open(name, 'wb+') as f:
            while True:
                buf = self._fileobj.read()
                if not buf:
                    break
                f.write(buf)
1130615
def save_params_to_file(self, fname: str):
        
        arg_params, aux_params = self.module.get_params()
        self.module.set_params(arg_params, aux_params)
        self.params = arg_params
        self.aux_params = aux_params
        super().save_params_to_file(fname)
72182
def insert_file(self, f, namespace, timestamp):
        
        doc = f.get_metadata()
        doc["content"] = f.read()
        self.doc_dict[f._id] = Entry(doc=doc, ns=namespace, ts=timestamp)
819050
def fh_to_record(self, f):
        """"""

        fn_path = self.file_name
        fr = self.record
        fr.path = fn_path

        fr.update_contents(f.read(), 'text/plain')

        fr.source_hash = self.fs_hash
        fr.synced_fs = self.fs_modtime
        fr.modified = self.fs_modtime
499322
def save(self, model, path=''):
        """"""
        if model['type'] != 'notebook':
            return super(TextFileContentsManager, self).save(model, path)

        nbk = model['content']
        try:
            metadata = nbk.get('metadata')
            rearrange_jupytext_metadata(metadata)
            jupytext_metadata = metadata.setdefault('jupytext', {})
            jupytext_formats = jupytext_metadata.get('formats') or self.default_formats(path)

            if not jupytext_formats:
                text_representation = jupytext_metadata.get('text_representation', {})
                ext = os.path.splitext(path)[1]
                fmt = {'extension': ext}

                if ext == text_representation.get('extension') and text_representation.get('format_name'):
                    fmt['format_name'] = text_representation.get('format_name')

                jupytext_formats = [fmt]

            jupytext_formats = long_form_multiple_formats(jupytext_formats, metadata)

            # Set preferred formats if not format name is given yet
            jupytext_formats = [preferred_format(fmt, self.preferred_jupytext_formats_save) for fmt in jupytext_formats]

            base, fmt = find_base_path_and_format(path, jupytext_formats)
            self.update_paired_notebooks(path, fmt, jupytext_formats)
            self.set_default_format_options(jupytext_metadata)

            if not jupytext_metadata:
                metadata.pop('jupytext')

            # Save as ipynb first
            return_value = None
            value = None
            for fmt in jupytext_formats[::-1]:
                if fmt['extension'] != '.ipynb':
                    continue

                alt_path = full_path(base, fmt)
                self.create_prefix_dir(alt_path, fmt)
                self.log.info("Saving %s", os.path.basename(alt_path))
                value = super(TextFileContentsManager, self).save(model, alt_path)
                if alt_path == path:
                    return_value = value

            # And then to the other formats, in reverse order so that
            # the first format is the most recent
            for fmt in jupytext_formats[::-1]:
                if fmt['extension'] == '.ipynb':
                    continue

                alt_path = full_path(base, fmt)
                self.create_prefix_dir(alt_path, fmt)
                if 'format_name' in fmt and fmt['extension'] not in ['.Rmd', '.md']:
                    self.log.info("Saving %s in format %s:%s",
                                  os.path.basename(alt_path), fmt['extension'][1:], fmt['format_name'])
                else:
                    self.log.info("Saving %s", os.path.basename(alt_path))
                with mock.patch('nbformat.writes', _jupytext_writes(fmt)):
                    value = super(TextFileContentsManager, self).save(model, alt_path)
                    if alt_path == path:
                        return_value = value

            # Update modified timestamp to match that of the pair #207
            return_value['last_modified'] = value['last_modified']
            return return_value

        except Exception as err:
            raise HTTPError(400, str(err))