def save_file(self): """ Save the current xml document. Prompts for a filename if one has not been set yet. Returns ------- None """ if not self.cur_fname: fname = self.get_save_name() if not fname: return else: fname = self.cur_fname fname_msg = utils.check_fname(fname) if not fname_msg == 'good': msg = "Cannot write to :\n {}.".format(fname) QMessageBox.warning(self, "Metadata Wizard", msg) return xml_utils.save_to_file(self.metadata_root._to_xml(), fname) self.last_updated = time.time() self.set_current_file(fname) self.statusBar().showMessage("File saved", 2000)
def save_file(self, e=None): if not self.cur_fname: fname = self.get_save_name() if not fname: return else: fname = self.cur_fname fname_msg = utils.check_fname(fname) if not fname_msg == 'good': msg = "Cannot write to :\n {}.".format(fname) QMessageBox.warning(self, "Metadata Wizard", msg) return xml_utils.save_to_file(self.metadata_root._to_xml(), fname) self.set_current_file(fname) self.statusBar().showMessage("File saved", 2000)
def save_file(self): """ Save the current xml document. Prompts for a filename if one has not been set yet. Returns ------- None """ if not self.cur_fname: fname = self.get_save_name() if not fname: return else: fname = self.cur_fname fname_msg = utils.check_fname(fname) if not fname_msg == "good": msg = "Cannot write to :\n {}.".format(fname) QMessageBox.warning(self, "Metadata Wizard", msg) return tool_comment = ( "Record created using version {} of the " "USGS Metadata Wizard tool. (https://github.com/usgs/" "fort-pymdwizard)".format(__version__) ) xml_contents = self.metadata_root.to_xml() comment = xml_utils.xml_node(tag="", text=tool_comment, index=0, comment=True) xml_contents.addprevious(comment) xml_utils.save_to_file(xml_contents, fname) self.last_updated = time.time() self.set_current_file(fname) self.statusBar().showMessage("File saved", 2000) if self.sb_file: self.sb_locator.put_fgdc_file()