Saves current **Script_Editor_tabWidget** Widget tab Model editor file as user chosen file.

        :return: Method success.
        :rtype: bool
430555
def save_fileAs(self):
        

        editor = self.get_current_editor()
        if not editor:
            return False

        file = umbra.ui.common.store_last_browsed_path(QFileDialog.getSaveFileName(self, "Save As:", editor.file))
        if not file:
            return False

        candidate_editor = self.get_editor(file)
        if candidate_editor:
            if not candidate_editor is editor:
                raise foundations.exceptions.UserError("{0} | '{1}' file is already opened!".format(
                    self.__class__.__name__, file))
            else:
                return self.save_file(file)

        LOGGER.info("{0} | Saving '{1}' file!".format(self.__class__.__name__, file))
        self.__lock_editor(editor)
        self.unregister_node_path(editor)
        if editor.save_fileAs(file):
            self.__model.update_authoring_nodes(editor)
            language = self.__languages_model.get_file_language(
                file) or self.__languages_model.get_language(self.__default_language)
            if editor.language.name != language.name:
                self.set_language(editor, language)
            return True
1200408
def saveAs(self, event=None):
        

        self.debug('Clicked Save as...')
        # On Linux Pers..Dlg causes the cwd to change, so get a copy of current
        curdir = os.getcwd()

        # The user wishes to save to a different name
        writeProtChoice = self._writeProtectOnSaveAs
        if capable.OF_TKFD_IN_EPAR:
            # Prompt using native looking dialog
            fname = asksaveasfilename(parent=self.top,
                    title='Save Parameter File As',
                    defaultextension=self._defSaveAsExt,
                    initialdir=os.path.dirname(self._getSaveAsFilter()))
        else:
            # Prompt. (could use tkinter's FileDialog, but this one is prettier)
            # initWProtState is only used in the 1st call of a session
            from . import filedlg
            fd = filedlg.PersistSaveFileDialog(self.top,
                         "Save Parameter File As", self._getSaveAsFilter(),
                         initWProtState=writeProtChoice)
            if fd.Show() != 1:
                fd.DialogCleanup()
                os.chdir(curdir) # in case file dlg moved us
                return
            fname = fd.GetFileName()
            writeProtChoice = fd.GetWriteProtectChoice()
            fd.DialogCleanup()

        if not fname: return # canceled

        # First check the child parameters, aborting save if
        # invalid entries were encountered
        if self.checkSetSaveChildren():
            os.chdir(curdir) # in case file dlg moved us
            return

        # Run any subclass-specific steps right before the save
        self._saveAsPreSave_Hook(fname)

        # Verify all the entries (without save), keeping track of the invalid
        # entries which have been reset to their original input values
        self.badEntriesList = self.checkSetSaveEntries(doSave=False)

        # If there were invalid entries, prepare the message dialog
        if self.badEntriesList:
            ansOKCANCEL = self.processBadEntries(self.badEntriesList,
                          self.taskName)
            if not ansOKCANCEL:
                os.chdir(curdir) # in case file dlg moved us
                return

        # If there were no invalid entries or the user says OK, finally
        # save to their stated file.  Since we have already processed the
        # bad entries, there should be none returned.
        mstr = "TASKMETA: task="+self.taskName+" package="+self.pkgName
        if self.checkSetSaveEntries(doSave=True, filename=fname, comment=mstr,
                                    set_ro=writeProtChoice,
                                    overwriteRO=True):
            os.chdir(curdir) # in case file dlg moved us
            raise Exception("Unexpected bad entries for: "+self.taskName)

        # Run any subclass-specific steps right after the save
        self._saveAsPostSave_Hook(fname)

        os.chdir(curdir)
231580
def buffer_edit(editor, location, force=False):
    
    if location is None:
        # Edit/open without a location will reload the current file, if there are
        # no changes.
        eb = editor.window_arrangement.active_editor_buffer
        if eb.location is None:
            editor.show_message(_NO_FILE_NAME)
        elif not force and eb.has_unsaved_changes:
            editor.show_message(_NO_WRITE_SINCE_LAST_CHANGE_TEXT)
        else:
            eb.reload()
    else:
        editor.file_explorer = ''
        editor.window_arrangement.open_buffer(location, show_in_current_window=True)
684796
def save(self, fname=''):
        
        if fname != '':
            with open(fname, 'w') as f:
                for t in self.lstTools:
                    self.verify(t)
                    f.write(self.tool_as_string(t))
398819
def save(self, filename=None):
        
        filename = filename or self._filename
        o = open(filename, 'w')
        o.write(self.write())
        o.close()
607215
def new_file(self):
        

        language = self.__languages_model.get_language(self.__default_script_language)
        editor = Editor(parent=self, language=language)

        file = editor.new_file()
        if not file:
            return False

        LOGGER.info("{0} | Creating '{1}' file!".format(self.__class__.__name__, file))

        if self.__model.set_authoring_nodes(editor):
            self.__store_recent_file(file)
            self.file_loaded.emit(file)
            return True
470414
def save(self):
        
        # close down the snapshot widget
        if self.hideWindow():
            self.hideWindow().hide()
        
        self.hide()
        QApplication.processEvents()
        time.sleep(1)
        
        # create the pixmap to save
        wid = QApplication.desktop().winId()
        
        if not self._region.isNull():
            x = self._region.x()
            y = self._region.y()
            w = self._region.width()
            h = self._region.height()
        else:
            x = self.x()
            y = self.y()
            w = self.width()
            h = self.height()
        
        pixmap = QPixmap.grabWindow(wid, x, y, w, h)
        pixmap.save(self.filepath())
        
        self.close()
        self.deleteLater()
        if self.hideWindow():
            self.hideWindow().show()
145001
def _save_pys(self, filepath):
        

        try:
            with Bz2AOpen(filepath, "wb",
                          main_window=self.main_window) as outfile:
                interface = Pys(self.grid.code_array, outfile)
                interface.from_code_array()

        except (IOError, ValueError), err:
            try:
                post_command_event(self.main_window, self.StatusBarMsg,
                                   text=err)
                return
            except TypeError:
                # The main window does not exist any more
                pass

        return not outfile.aborted
361355
def get_editorTab(self, editor):
        

        for i in range(self.Script_Editor_tabWidget.count()):
            if not self.get_widget(i) == editor:
                continue

            LOGGER.debug("> Editor '{0}': Tab index '{1}'.".format(editor, i))
            return i
266698
def _add_editor_buffer(self, editor_buffer, show_in_current_window=False):
        
        assert isinstance(editor_buffer, EditorBuffer) and editor_buffer not in self.editor_buffers

        # Add to list of EditorBuffers
        eb = self.active_editor_buffer
        if eb is None:
            self.editor_buffers.append(editor_buffer)
        else:
            # Append right after the currently active one.
            try:
                index = self.editor_buffers.index(self.active_editor_buffer)
            except ValueError:
                index = 0
            self.editor_buffers.insert(index, editor_buffer)

        # When there are no tabs/windows yet, create one for this buffer.
        if self.tab_pages == []:
            self.tab_pages.append(TabPage(Window(editor_buffer)))
            self.active_tab_index = 0

        # To be shown?
        if show_in_current_window and self.active_tab:
            self.active_tab.show_editor_buffer(editor_buffer)

        # Start reporter.
        editor_buffer.run_reporter()
50334
def create_widget(self):
        
        d = self.declaration
        self.widget = EditText(self.get_context(), None,
                               d.style or "@attr/editTextStyle")
225468
def save_html(self, filename=None, overwrite=False):
        

        if filename is None:
            raise ValueError('Please provide a filename, e.g. viz.save_html(filename="viz.html").')

        import os
        base = self._html
        js = self.load_embed()
        if os.path.exists(filename):
            if overwrite is False:
                raise ValueError("File '%s' exists. To ovewrite call save_html with overwrite=True."
                                 % os.path.abspath(filename))
            else:
                os.remove(filename)
        with open(filename, "wb") as f:
            f.write(base.encode('utf-8'))
            f.write('<script>' + js.encode('utf-8') + '</script>')
1103008
def script_editor_file(self, value):
        

        if value is not None:
            assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
                "script_editor_file", value)
        self.__script_editor_file = value
339399
def save(self, file=CONFIG_FILE):
        
        os.makedirs(os.path.dirname(file), exist_ok=True)
        with open(file, "w") as f:
            yaml.dump(self._settings, f, Dumper=yaml.RoundTripDumper, width=float("inf"))
421597
def script_post_save(model, os_path, contents_manager, **kwargs):
    
    from nbconvert.exporters.script import ScriptExporter

    if model['type'] != 'notebook':
        return

    global _script_exporter

    if _script_exporter is None:
        _script_exporter = ScriptExporter(parent=contents_manager)

    log = contents_manager.log

    base, ext = os.path.splitext(os_path)
    # py_fname = base + '.py'
    script, resources = _script_exporter.from_filename(os_path)
    script_fname = base + resources.get('output_extension', '.txt')
    log.info("Saving script /%s", to_api_path(script_fname, contents_manager.root_dir))

    with io.open(script_fname, 'w', encoding='utf-8') as f:
        f.write(script)
995549
def remove_editor_tab(self, editor):
        

        LOGGER.debug("> Removing tab with Editor '{0}'.".format(editor))
        self.Script_Editor_tabWidget.removeTab(self.get_editorTab(editor))
        return True
722270
def active_editor_buffer(self):
        
        if self.active_tab and self.active_tab.active_window:
            return self.active_tab.active_window.editor_buffer