當前位置: 首頁>>代碼示例>>Python>>正文


Python html_builder.HTMLBuilder類代碼示例

本文整理匯總了Python中regulations.generator.html_builder.HTMLBuilder的典型用法代碼示例。如果您正苦於以下問題:Python HTMLBuilder類的具體用法?Python HTMLBuilder怎麽用?Python HTMLBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了HTMLBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_process_node_appliers

    def test_process_node_appliers(self):
        node = {
            "text": "Text text text.",
            "children": [],
            "label": ["123", "aaa"],
            'node_type': REGTEXT
        }

        inline = Mock()
        inline.get_layer_pairs.return_value = []
        par = Mock()
        par.apply_layers.return_value = node
        sr = Mock()
        sr.get_layer_pairs.return_value = []

        builder = HTMLBuilder(inline, par, sr)
        builder.process_node(node)

        self.assertTrue(inline.get_layer_pairs.called)
        self.assertEqual("123-aaa",
                         inline.get_layer_pairs.call_args[0][0])
        self.assertEqual("Text text text.",
                         inline.get_layer_pairs.call_args[0][1])

        self.assertTrue(par.apply_layers.called)
        self.assertEqual(node, par.apply_layers.call_args[0][0])
開發者ID:theresaanna,項目名稱:regulations-site,代碼行數:26,代碼來源:html_builder_test.py

示例2: test_list_level_regulations_no_level

    def test_list_level_regulations_no_level(self):
        builder = HTMLBuilder(None, None, None)

        parts = ['101', '1']
        node_type = REGTEXT

        result = builder.list_level(parts, node_type)
        self.assertEquals(result, None)
開發者ID:theresaanna,項目名稱:regulations-site,代碼行數:8,代碼來源:html_builder_test.py

示例3: generate_html_tree

def generate_html_tree(subtree):
    """Use the HTMLBuilder to generate a version of this subtree with
    appropriate markup. Currently, includes no layers"""
    builder = HTMLBuilder(*LayerCreator().get_appliers())
    builder.tree = subtree
    builder.generate_html()

    return {'node': builder.tree,
            'markup_page_type': 'reg-section'}
開發者ID:jmcarp,項目名稱:regulations-site,代碼行數:9,代碼來源:preamble.py

示例4: test_node_title_no_diff

 def test_node_title_no_diff(self):
     builder = HTMLBuilder()
     node = {
         "label_id": "204",
         "title": "abcd",
         'node_type': APPENDIX
     }
     builder.process_node_title(node)
     self.assertTrue('header' in node)
     self.assertEqual(node['title'], 'abcd')
開發者ID:eregs,項目名稱:regulations-site,代碼行數:10,代碼來源:html_builder_test.py

示例5: test_is_collapsed

    def test_is_collapsed(self):
        for label, text in ((['111', '22', 'a'], '(a) '),
                            (['111', '22', 'xx'], ' (xx) '),
                            (['111', '22', 'a', '5'], '(5)')):
            node = {'label': label, 'text': text}
            self.assertTrue(HTMLBuilder.is_collapsed(node))

        for label, text in ((['111', '22', 'a'], '(b) '),
                            (['111', '22', ''], '(a) Some text'),
                            (['111', '22', 'a'], '  ')):
            node = {'label': label, 'text': text}
            self.assertFalse(HTMLBuilder.is_collapsed(node))
開發者ID:eregs,項目名稱:regulations-site,代碼行數:12,代碼來源:html_builder_test.py

示例6: test_process_node_title_diff

 def test_process_node_title_diff(self):
     builder = HTMLBuilder()
     diff = {'204': {'title': [('delete', 0, 2), ('insert', 4, 'AAC')],
                     'text':  [('delete', 0, 2), ('insert', 4, 'AAB')],
                     'op': ''}}
     da = diff_applier.DiffApplier(diff, None)
     node = {
         "label_id": "204",
         "title": "abcd",
         'node_type': APPENDIX
     }
     builder.diff_applier = da
     builder.process_node_title(node)
     self.assertEqual('<del>ab</del>cd<ins>AAC</ins>', node['header'])
開發者ID:eregs,項目名稱:regulations-site,代碼行數:14,代碼來源:html_builder_test.py

示例7: test_process_node_title_section_space_diff

 def test_process_node_title_section_space_diff(self):
     """" Diffs and sections spaces need to place nicely together. """
     builder = HTMLBuilder(None, None, None)
     diff = {'204': {'title': [('delete', 7, 9), ('insert', 10, 'AAC')],
                     'text':  [('delete', 0, 2), ('insert', 4, 'AAB')],
                     'op': ''}}
     da = diff_applier.DiffApplier(diff, None)
     node = {
         "label_id": u"204",
         "title": u"§ 101.6 abcd",
         'node_type': APPENDIX
     }
     builder.diff_applier = da
     builder.process_node_title(node)
     self.assertEqual(
         u'§&nbsp;101.6<del> a</del>b<ins>AAC</ins>cd', node['header'])
開發者ID:theresaanna,項目名稱:regulations-site,代碼行數:16,代碼來源:html_builder_test.py

示例8: test_list_level_interpretations

    def test_list_level_interpretations(self):
        builder = HTMLBuilder(None, None, None)

        parts = ['101', '12', 'a', 'Interp', '1']
        node_type = INTERP

        result = builder.list_level(parts, node_type)
        self.assertEquals(result, 1)

        parts.append('j')
        result = builder.list_level(parts, node_type)
        self.assertEquals(result, 2)

        parts.append('B')
        result = builder.list_level(parts, node_type)
        self.assertEquals(result, 3)
開發者ID:theresaanna,項目名稱:regulations-site,代碼行數:16,代碼來源:html_builder_test.py

示例9: test_interp_node_with_citations

    def test_interp_node_with_citations(self):
        inline, p, sr = Mock(), Mock(), Mock()
        builder = HTMLBuilder(inline, p, sr)

        node = {
            'text': 'Interpretation with a link',
            'children': [],
            'node_type': INTERP,
            'label': ['999', '5', 'Interp']
        }
        p.apply_layers.return_value = node
        inline.get_layer_pairs.return_value = []
        sr.get_layer_pairs.return_value = []
        builder.process_node(node)
        layer_parameters = inline.get_layer_pairs.call_args[0]
        self.assertEqual('Interpretation with a link', layer_parameters[1])
        self.assertEqual('999-5-Interp', layer_parameters[0])
開發者ID:theresaanna,項目名稱:regulations-site,代碼行數:17,代碼來源:html_builder_test.py

示例10: test_header_parsing

    def test_header_parsing(self):
        builder = HTMLBuilder(None, None, None)

        node = {
            "label": ["234", "a", "1"],
            "title": "Title (Regulation R)",
            'node_type': APPENDIX
        }
        titleless_node = {
            "title": "Title",
            'node_type': REGTEXT
        }

        parsed_title = builder.parse_doc_title(node['title'])
        no_title = builder.parse_doc_title(titleless_node['title'])

        self.assertEqual("(Regulation R)", parsed_title)
        self.assertEqual(no_title, None)
開發者ID:theresaanna,項目名稱:regulations-site,代碼行數:18,代碼來源:html_builder_test.py

示例11: test_list_level_regulations

    def test_list_level_regulations(self):
        builder = HTMLBuilder(None, None, None)

        parts = ['101', '1', 'a']
        node_type = REGTEXT

        result = builder.list_level(parts, node_type)
        self.assertEquals(result, 1)

        parts.append('2')
        result = builder.list_level(parts, node_type)
        self.assertEquals(result, 2)

        parts.append('k')
        result = builder.list_level(parts, node_type)
        self.assertEquals(result, 3)

        parts.append('B')
        result = builder.list_level(parts, node_type)
        self.assertEquals(result, 4)
開發者ID:theresaanna,項目名稱:regulations-site,代碼行數:20,代碼來源:html_builder_test.py

示例12: test_list_level_appendices

    def test_list_level_appendices(self):
        builder = HTMLBuilder(None, None, None)

        parts = ['101', 'A', '1', 'a']
        node_type = APPENDIX

        result = builder.list_level(parts, node_type)
        self.assertEquals(result, 1)

        parts.append('2')
        result = builder.list_level(parts, node_type)
        self.assertEquals(result, 2)

        parts.append('k')
        result = builder.list_level(parts, node_type)
        self.assertEquals(result, 3)

        parts.append('B')
        result = builder.list_level(parts, node_type)
        self.assertEquals(result, 4)
開發者ID:theresaanna,項目名稱:regulations-site,代碼行數:20,代碼來源:html_builder_test.py

示例13: test_modify_interp_node

    def test_modify_interp_node(self):
        node = {
            'node_type': INTERP,
            'label': ['872', '22', 'Interp'],
            'children': [{'label': ['872', '22', 'Interp', '1']},
                         {'label': ['872', '22', 'a', 'Interp']},
                         {'label': ['872', '22', 'b', 'Interp']}]
        }
        builder = HTMLBuilder(None, None, None)
        builder.modify_interp_node(node)
        self.assertTrue(node['section_header'])
        self.assertEqual(node['header_children'],
                         [{'label': ['872', '22', 'a', 'Interp']},
                          {'label': ['872', '22', 'b', 'Interp']}])
        self.assertEqual(node['par_children'],
                         [{'label': ['872', '22', 'Interp', '1']}])

        node['label'] = ['872', '222', 'a', 'Interp']
        builder.modify_interp_node(node)
        self.assertFalse(node['section_header'])
開發者ID:theresaanna,項目名稱:regulations-site,代碼行數:20,代碼來源:html_builder_test.py

示例14: test_modify_interp_node_header

    def test_modify_interp_node_header(self):
        node = {
            'children': [],
            'header': 'This interprets 22(a), a paragraph',
            'label': ['872', '22', 'a', 'Interp'],
            'node_type': INTERP,
        }
        icl = InternalCitationLayer(None)
        icl.sectional = True
        ila = InlineLayersApplier()
        ila.add_layer(icl)
        builder = HTMLBuilder(ila, None, None)

        builder.modify_interp_node(node)
        self.assertEqual('This interprets '
                         + icl.render_url(['872', '22', 'a'], '22(a)')
                         + ', a paragraph', node['header_markup'])

        node['label'] = ['872', '22']
        builder.modify_interp_node(node)
        self.assertEqual(node['header'], node['header_markup'])
開發者ID:theresaanna,項目名稱:regulations-site,代碼行數:21,代碼來源:html_builder_test.py

示例15: test_process_node_header

    def test_process_node_header(self):
        builder = HTMLBuilder()
        node = {'text': '', 'children': [], 'label': ['99', '22'],
                'node_type': REGTEXT}
        builder.process_node(node)
        self.assertFalse('header' in node)

        node = {'text': '', 'children': [], 'label': ['99', '22'],
                'title': 'Some Title', 'node_type': REGTEXT}
        builder.process_node(node)
        self.assertTrue('header' in node)
        self.assertEqual('Some Title', node['header'])

        node = {'text': '', 'children': [], 'label': ['99', '22'],
                'title': u'§ 22.1 Title', 'node_type': REGTEXT}
        builder.process_node(node)
        self.assertTrue('header' in node)
開發者ID:eregs,項目名稱:regulations-site,代碼行數:17,代碼來源:html_builder_test.py


注:本文中的regulations.generator.html_builder.HTMLBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。