Esempio n. 1
0
    def load(self):
        pageFullPath = self.getPagePath()
        self.l.debug('Loading page at {} '.format(pageFullPath))

        pageDir = self.getPageDir()
        if not os.path.isfile(pageFullPath):
            self.l.debug('Page does not exist, creating empty document ...')

            rootFrame = Frame()
            p1 = Paragraph(0, ('title', 'level', '1'))
            title = TextFragment(None)
            title.setText(self.pageId)
            p1.add(title)
            p2 = Paragraph(0, ('para', None, None))
            rootFrame.add(p1)
            rootFrame.add(p2)

            docFac = DocumentFactory(pageDir, self.notepad.formatManager)
            self.document = docFac.createDocument(rootFrame)

            self.links = []
        else:
            importer = XMLImporter(pageDir, self.getFilename(),
                                   self.notepad.getFormatManager())
            importer.importDocument()
            self.document = importer.getDocument()
            self.links = importer.getLinks()
Esempio n. 2
0
    def load(self):
        pageFullPath = self.getPagePath()
        self.l.debug('Loading page at {} '.format(pageFullPath))

        pageDir = self.getPageDir()
        if not os.path.isfile(pageFullPath):
            self.l.debug('Page does not exist, creating empty document ...')

            rootFrame = Frame()
            p1 = Paragraph(0, ('title', 'level', '1'))
            title = TextFragment(None)
            title.setText(self.pageId)
            p1.add(title)
            p2 = Paragraph(0, ('para', None, None))
            rootFrame.add(p1)
            rootFrame.add(p2)

            docFac= DocumentFactory(pageDir, self.notepad.formatManager)
            self.document = docFac.createDocument(rootFrame)

            self.links = []
        else:
            importer = XMLImporter(pageDir, self.getFilename(), self.notepad.getFormatManager())
            importer.importDocument()
            self.document = importer.getDocument()
            self.links = importer.getLinks()
Esempio n. 3
0
    def importFromFile(self, fileDesc):
        # Step 1: read the XML file and create the document structure with the 
        # corresponding styles
        parser = xml.sax.make_parser()
        handler = Handler(self.contentPath)
        parser.setContentHandler(handler)
        parser.parse(fileDesc)

        self.links = sorted(handler.keywordLinks)
        documentModel = handler.result

        # Step 2: Create a QTextDocument from the document tree 
        df = DocumentFactory(self.contentPath, self.formatManager)
        self.document = df.createDocument(documentModel)
Esempio n. 4
0
    def importFromFile(self, fileDesc):
        # Step 1: read the XML file and create the document structure with the
        # corresponding styles
        parser = xml.sax.make_parser()
        handler = Handler(self.contentPath)
        parser.setContentHandler(handler)
        parser.parse(fileDesc)

        self.links = sorted(handler.keywordLinks)
        documentModel = handler.result

        # Step 2: Create a QTextDocument from the document tree
        df = DocumentFactory(self.contentPath, self.formatManager)
        self.document = df.createDocument(documentModel)