def open(self, file_path=None): try: if file_path is None or file_path is False: file_path = File.showOpenFileDialog() if file_path != "": self.documents_controller.openDocument(file_path) except Exception as e: Dialogs.showError(e)
def open(self, file_path=None): try: if file_path is None: file_path = File.showOpenFileDialog() if file_path != "": self.documents_controller.openDocument(file_path) except Exception, e: Dialogs.showError(e)
def title(self): """ The title of a document is the file name of the document or "Untitled [ID]" if the document is untitled. """ if self.isUntitled(): title = "Untitled %d" % self.id else: title = File.getFileNameFromFilePath(self.file_path) return title
def open(self): """ To open the document, we read the content from the file path and un- dirty the document. """ try: if File.exists(self.file_path): (self.preamble, self.source) = documentIO.readPreambleAndSourceFromFilePath(self.file_path) self.dirty = False except Exception as e: raise DocumentError("The document cannot be opened: %s" % str(e))
def open(self): """ To open the document, we read the content from the file path and un- dirty the document. """ try: if File.exists(self.file_path): (self.preamble, self.source) = documentIO.readPreambleAndSourceFromFilePath( self.file_path) self.dirty = False except Exception as e: raise DocumentError("The document cannot be opened: %s" % str(e))
def _readFileLines(self): content = File.readContentFromFilePath(self.file_path) self.file_lines = content.split("\n")
def _checkFileExists(self): if not File.exists(self.file_path): raise DocumentReaderError("The file does not exist")
def _writeSourceCodeToFile(self): File.writeContentToFilePath(self.latex_source, self.source_file_path)
def writeDocumentToFilePath(template, document, file_path): content = buildFileContentFromDocument(template, document) File.writeContentToFilePath(content, file_path)
def saveAs(self): file_path = File.showSaveFileDialog(self.view, self._getDocumentFileName()) if file_path: self.model.file_path = file_path self.model.save()
def initController(self): self.view.setImage(":/icon_about.png") self.view.setInfoHTML(File.readContentFromFilePath(":/about.html"))