コード例 #1
0
 def visitNode_body(self, node):
     tocs=domhelpers.locateNodes([node], 'class', 'toc')
     domhelpers.clearNode(node)
     if len(tocs):
         toc=tocs[0]
         node.appendChild(toc)
     self.visitNodeDefault(node)
コード例 #2
0
ファイル: latex.py プロジェクト: levanhong05/MeshMagic
 def visitNode_body(self, node):
     tocs = domhelpers.locateNodes([node], 'class', 'toc')
     domhelpers.clearNode(node)
     if len(tocs):
         toc = tocs[0]
         node.appendChild(toc)
     self.visitNodeDefault(node)
コード例 #3
0
    def test_clearNode(self):
        doc1 = self.dom.parseString('<a><b><c><d/></c></b></a>')
        a_node = doc1.documentElement
        domhelpers.clearNode(a_node)
        self.assertEqual(a_node.toxml(), self.dom.Element('a').toxml())

        doc2 = self.dom.parseString('<a><b><c><d/></c></b></a>')
        b_node = doc2.documentElement.childNodes[0]
        domhelpers.clearNode(b_node)
        actual = doc2.documentElement.toxml()
        expected = self.dom.Element('a')
        expected.appendChild(self.dom.Element('b'))
        self.assertEqual(actual, expected.toxml())
コード例 #4
0
 def setUp(self, request, node, data):
     if isinstance(data, StringType):
         node.tagName = self.tagName
         node.attributes["href"] = data
     else:
         data = self.model
         txt = data.getSubmodel(request, "text").getData(request)
         if not isinstance(txt, Node):
             txt = document.createTextNode(txt)
         lnk = data.getSubmodel(request, "href").getData(request)
         self['href'] = lnk
         node.tagName = self.tagName
         domhelpers.clearNode(node)
         node.appendChild(txt)
コード例 #5
0
ファイル: widgets.py プロジェクト: UstadMobile/eXePUB
 def setUp(self, request, node, data):
     # TODO: we ought to support Deferreds here for both text and href!
     if isinstance(data, StringType):
         node.tagName = self.tagName
         node.attributes["href"] = data
     else:
         data = self.model
         txt = data.getSubmodel(request, "text").getData(request)
         if not isinstance(txt, Node):
             txt = document.createTextNode(txt)
         lnk = data.getSubmodel(request, "href").getData(request)
         self['href'] = lnk
         node.tagName = self.tagName
         domhelpers.clearNode(node)
         node.appendChild(txt)
コード例 #6
0
    def test_clearNode(self):
        doc1 = self.dom.parseString('<a><b><c><d/></c></b></a>')
        a_node = doc1.documentElement
        domhelpers.clearNode(a_node)
        self.assertEqual(
            a_node.toxml(),
            self.dom.Element('a').toxml())

        doc2 = self.dom.parseString('<a><b><c><d/></c></b></a>')
        b_node = doc2.documentElement.childNodes[0]
        domhelpers.clearNode(b_node)
        actual = doc2.documentElement.toxml()
        expected = self.dom.Element('a')
        expected.appendChild(self.dom.Element('b'))
        self.assertEqual(actual, expected.toxml())
コード例 #7
0
ファイル: widgets.py プロジェクト: fxia22/ASM_xf
 def setUp(self, request, node, data):
     # TODO: we ought to support Deferreds here for both text and href!
     if isinstance(data, StringType):
         node.tagName = 'a'
         node.setAttribute("href", data)
     else:
         data = self.model
         txt = data.getSubmodel("text").getData(request)
         if not isinstance(txt, Node):
             txt = document.createTextNode(txt)
         lnk = data.getSubmodel("href").getData(request)
         self['href'] = lnk
         node.tagName = 'a'
         domhelpers.clearNode(node)
         node.appendChild(txt)
コード例 #8
0
ファイル: widgets.py プロジェクト: fxia22/ASM_xf
 def generateDOM(self, request, node):
     node = Widget.generateDOM(self, request, node)
     listHeader = self.getPattern('listHeader', None)
     listFooter = self.getPattern('listFooter', None)
     emptyList = self.getPattern('emptyList', None)
     domhelpers.clearNode(node)
     if not listHeader is None:
         node.appendChild(listHeader)
     data = self.getData(request)
     if data:
         self._iterateData(node, self.submodel, data)
     elif not emptyList is None:
         node.appendChild(emptyList)
     if not listFooter is None:
         node.appendChild(listFooter)
     return node
コード例 #9
0
 def generateDOM(self, request, node):
     node = Widget.generateDOM(self, request, node)
     listHeaders = self.getAllPatterns('listHeader', None)
     listFooters = self.getAllPatterns('listFooter', None)
     emptyLists = self.getAllPatterns('emptyList', None)
     domhelpers.clearNode(node)
     if listHeaders:
         node.childNodes.extend(listHeaders)
         for n in listHeaders: n.parentNode = node
     data = self.getData(request)
     if data:
         self._iterateData(node, self.submodel, data)
     elif emptyLists:
         node.childNodes.extend(emptyLists)
         for n in emptyLists: n.parentNode = node
     if listFooters:
         node.childNodes.extend(listFooters)
         for n in listFooters: n.parentNode = node
     return node
コード例 #10
0
 def setUp(self, request, node, data):
     pattern = self.getPattern('columnListRow', clone=0)
     if self.end:
         listSize = self.end - self.start
         if listSize > len(data):
             listSize = len(data)
     else:
         listSize = len(data)
     for itemNum in range(listSize):
         if itemNum % self.columns == 0:
             row = self.getPattern('columnListRow')
             domhelpers.clearNode(row)
             node.appendChild(row)
         newNode = self.getPattern('columnListItem')
         appendModel(newNode, itemNum + self.start)
         if not newNode.attributes.get("view"):
             newNode.attributes["view"] = "DefaultWidget"
         row.appendChild(newNode)
     node.removeChild(pattern)
     return node
コード例 #11
0
ファイル: widgets.py プロジェクト: UstadMobile/eXePUB
    def setUp(self, request, node, data):
        pattern = self.getPattern('columnListRow', clone=0)
        if self.end:
            listSize = self.end - self.start
            if listSize > len(data):
                listSize = len(data)
        else:
            listSize = len(data)
        for itemNum in range(listSize):
            if itemNum % self.columns == 0:
                row = self.getPattern('columnListRow')
                domhelpers.clearNode(row)
                node.appendChild(row)

            newNode = self.getPattern('columnListItem')

            appendModel(newNode, itemNum + self.start)
            if not newNode.attributes.get("view"):
                newNode.attributes["view"] = "DefaultWidget"
            row.appendChild(newNode)
        node.removeChild(pattern)
        return node
コード例 #12
0
ファイル: widgets.py プロジェクト: UstadMobile/eXePUB
 def generateDOM(self, request, node):
     node = Widget.generateDOM(self, request, node)
     listHeaders = self.getAllPatterns('listHeader', None)
     listFooters = self.getAllPatterns('listFooter', None)
     emptyLists = self.getAllPatterns('emptyList', None)
     domhelpers.clearNode(node)
     if listHeaders:
         node.childNodes.extend(listHeaders)
         for n in listHeaders:
             n.parentNode = node
     data = self.getData(request)
     if data:
         self._iterateData(node, self.submodel, data)
     elif emptyLists:
         node.childNodes.extend(emptyLists)
         for n in emptyLists:
             n.parentNode = node
     if listFooters:
         node.childNodes.extend(listFooters)
         for n in listFooters:
             n.parentNode = node
     return node
コード例 #13
0
    def test_clearNode(self):
        doc1=microdom.parseString('<a><b><c><d/></c></b></a>')
        a_node=doc1.documentElement
        domhelpers.clearNode(a_node)
        actual=doc1.documentElement.toxml()
        expected='<a></a>'
        assert actual==expected, 'expected %s, got %s' % (expected, actual)
 
        doc2=microdom.parseString('<a><b><c><d/></c></b></a>')
        b_node=doc2.documentElement.childNodes[0]
        domhelpers.clearNode(b_node)
        actual=doc2.documentElement.toxml()
        expected='<a><b></b></a>'
        assert actual==expected, 'expected %s, got %s' % (expected, actual)

        doc3=microdom.parseString('<a><b><c><d/></c></b></a>')
        c_node=doc3.documentElement.childNodes[0].childNodes[0]
        domhelpers.clearNode(c_node)
        actual=doc3.documentElement.toxml()
        expected='<a><b><c></c></b></a>'
        assert actual==expected, 'expected %s, got %s' % (expected, actual)
コード例 #14
0
    def test_clearNode(self):
        doc1 = microdom.parseString('<a><b><c><d/></c></b></a>')
        a_node = doc1.documentElement
        domhelpers.clearNode(a_node)
        actual = doc1.documentElement.toxml()
        expected = '<a></a>'
        assert actual == expected, 'expected %s, got %s' % (expected, actual)

        doc2 = microdom.parseString('<a><b><c><d/></c></b></a>')
        b_node = doc2.documentElement.childNodes[0]
        domhelpers.clearNode(b_node)
        actual = doc2.documentElement.toxml()
        expected = '<a><b></b></a>'
        assert actual == expected, 'expected %s, got %s' % (expected, actual)

        doc3 = microdom.parseString('<a><b><c><d/></c></b></a>')
        c_node = doc3.documentElement.childNodes[0].childNodes[0]
        domhelpers.clearNode(c_node)
        actual = doc3.documentElement.toxml()
        expected = '<a><b><c></c></b></a>'
        assert actual == expected, 'expected %s, got %s' % (expected, actual)